-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project with path dependency cannot be installed with pip install .
(or via requirements file) due to "RequirementParseError: Invalid URL"
#5273
Comments
Hi. As with release 1.2, |
Thanks for checking in, @Secrus. The problem still exists with poetry 1.2 (on the master branch) plus I'll update the issue. |
poetry export
/pip install -r ...
pip install .
(or via requirements file) due to Invalid URL
pip install .
(or via requirements file) due to Invalid URLpip install .
(or via requirements file) due to "RequirementParseError: RequirementParseErroInvalid URL"
pip install .
(or via requirements file) due to "RequirementParseError: RequirementParseErroInvalid URL"pip install .
(or via requirements file) due to "RequirementParseError: Invalid URL"
this pip issue might be related. They said poetry itself should be followed pip's way 'file://' and should not allow relative path. |
I have the feeling this is a duplicate of #3148 , there is a workaround mentioned there in a comment #3148 (comment) |
Just got same issue, i was able to install correctly with:
|
Looks like this is languishing for lack of interest and indeed I don't myself really understand why it's wanted. But it looks pretty trivial to fix this so that it always uses an absolute path, so if anyone is motivated to put together a pull request... |
The use-case I have for this is wheels that are built into a known location as part of a Dockerfile stage, and then installed from that location by a later stage from a fresh base using Our current workaround is to use Once challenge in this use-case that is orthogonal to this issue is that the absolute paths generated would need to be the lower-level wheel paths, rather than the absolute path of the source in the monorepo. It only just now occurred to me that if we used |
I get the feeling that most folks using path dependencies are working with some sort of monorepo setup. There are two use cases I've seen for path dependencies in these workflows:
For the first case I think the logical thing to do is to treat a In other words, for the example given in this issue doing [tool.poetry]
name = "b"
packages = [{include = "a", from = "../a"}]
[tool.poetry.dependencies]
python = "^3.9"
# all of a's dependencies
The second case is a bit more complex. There's questions about what version to use and such. Not unsolvable issues, but requiring discussion. And I think this is the minority of the use cases (also not this issue) so worth discussing elsewhere. All of this would only work if the path dependency is a poetry project, but that seems like a reasonable limitation. |
I think another common and legitimate use case is when working with git submodules. That's my case at least, and it would be great to be able pip install/publish my projects w/o requiring users to learn how to use poetry. |
@adriangb the use case you are tracking is tracked in #4583 -- it has technical challenges, but there is a user trying to implement it in python-poetry/poetry-core#273, more or less. The second is tracked at #2270. This issue specifically is tracking relative path dependencies in a non-monorepo setting and the ability to build a wheel from that -- the known path case in Docker above is likely the main use case (secondarily, NFS shares) and is the only issue not tracked somewhere else/described by the original issue. |
Thanks for linking me to those issues. #4583 seems like a really nice solution. It seems like no one has attempted to implement it yet; I suspect the main challenge will be the same as python-poetry/poetry-core#356: we'll need to re-write the I think that python-poetry/poetry-core#273 isn't a true replacement for these other issues. Introducing workspace support into [tool.workspaces]
members = ["projects/foo"] Into: [tool.poetry.groups.foo.dependencies]
foo = {path = "projects/foo", develop = true} I would like to also do the transformation proposed in #5273 (comment) so that the individual sub-packages can be built and/or published but that's not possible because of the bug/behavior in this issue. That is to say, I think if we can get #4583 or python-poetry/poetry-core#356 working it will open up the door to plugins (including the one that prompted python-poetry/poetry-core#273) that do most if not all of what python-poetry/poetry-core#273 wants to do without introducing a workspace concept into |
@nathanpainchaud, that's #2828, which could be argued is a specialized variant of #4583 if submodules are used. |
if you are going as far as monkey-patching around this in plugins you really might as well submit the MR in poetry-core to have it use absolute paths... |
@adriangb, I am conceptualizing python-poetry/poetry-core#273 as a successor to python-poetry/poetry-core#356 -- I think the shape of it will have to change to be something in the middle, ideally implementing #4583. Maybe it would be better to close that PR and re-open it as an explicit attempt at #4583, taking the best parts of the code and dropping the "workspace" marker bit (which is the only part that relates to workspaces at all -- the more I've thought about it, the more I think it's unnecessary). We're looking at dropping Essentially, I am of the opinion that #4583 answers most of these use cases and forcing explicit This issue is trivial to solve, if anyone wants to submit a PR to poetry-core to force the use of absolute paths. Many of the users here need #4583, but for the users who just want to be able to build a valid distfile (and let the consequences of absolute paths be what they may), we can solve that easily enough today. |
Well yes, I agree, that's what python-poetry/poetry-core#273 is attempting to do. I'm just saying that if #4583 or python-poetry/poetry-core#356 were fixed (hence closing the issue we are currently discussing) that monkey patching would not be needed, so introducing workspaces into
I agree that trying to focus on just fixing the
👍🏻 yep makes sense. From the time I spent on python-poetry/poetry-core#356 rewriting the paths in |
I think the bit of confusion here is the author of python-poetry/poetry-core#273 did a demo for project maintainers last week, and it turned out to basically be what I would consider to be a partial attempt at #4583 -- the workspace bit is really a red herring as it's only a marker file that prevents further path traversal. Critically, that PR does not (look at the code, since the body is still a bit confusing since the author is from a different ecosystem) canonicalize path dependencies (dependencies, not |
yep, the discussion here has drifted significantly but I think that what this issue about is just that poetry-core puts relative paths in metadata, and this is easily fixed by anyone who cares: tweak this code to use an absolute version of the full path that is already known to the directory dependency. (and similar for file dependency) |
duplicate #3148 |
This issue is more descriptive and has more discussion, I'm going to duplicate in the other direction. Thanks for the link. |
Facing a similar error when adding a local path to extras. [tool.poetry]
name = "poetrylib"
version = "0.0.1"
[tool.poetry.dependencies]
python = "^3.8, <3.11"
testlib = {path = "path/testlib", optional = true}
[tool.poetry.extras]
testlib = ["testlib"]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map
During handling of the above exception, another exception occurred:
raise RequirementParseError(str(e))
pip._vendor.pkg_resources.RequirementParseError: Parse error at "'extra =='": Expected string_end |
too fast, too careless: but this still isn't the same thing that this issue describes! |
Can you point me to where my issue is coming from then? Should I open a new issue page?
testlib's pyproject is just a simple: [tool.poetry]
name = "testlib"
version = "0.0.1"
packages = [
{ include = "*" },
]
[tool.poetry.dependencies]
python = "^3.8, <3.11"
numpy = "*" # for example
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" The error happens with both |
This issue is for a very specific issue relating to |
This issue has more discussion than #3148, but the discussion here went into a significantly different way than the discussion there. Here, we are talking mostly about dealing with workspaces and etc. and it's nice and important (and also discussed in many other issues as well), but the particular Simply having any kind of valid string compliant to PEP 508 is enough to let Workspaces and discussions related to that are trying to find ways to solve how So, my suggestion is to just fix this specific invalid URL in metadata issue with either the absolute URL or no URL at all, regardless of workspaces. If some future need requires one of the two specific options, then it can be changed later, but at least those who don't care about the URL don't need to wait for the fix. |
Nobody here has suggested that we don't fix the relative path issue or that it something else needs to be addressed first -- feel free to send a PR that makes the paths absolute. All that has happened is that no one who has participated here/expressed interest in fixing a low-hanging bug has sent a patch and gotten it/its tests through code review. |
bumping this comment to the end of the thread again
if the next person who gets here and cares about this would be good enough simply to submit an MR, that would be great! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
We're working within a monorepo where we have several projects that depend on each other via
path = "..."
relative dependencies. Installing such a project directly withpip install
fails withpip._vendor.pkg_resources.RequirementParseError: Invalid URL: ../a
.Why are we trying to do this? We want to have access to
pip install --target
to install packages to a specific directory, when packaging for an AWS Lambda .zip file. This means we're exporting to a requirements file and installing that.This is potentially caused by only absolute paths being turned into a URL, in https://github.com/python-poetry/poetry-core/blob/c5f4cda45402c38bb87ab73d0e32de509ba68f41/src/poetry/core/packages/directory_dependency.py#L125
Potentially related issues:
Example
https://github.com/huonw/poetry-path-deps-issue contains a full reproducible example:
cd /tmp git clone https://github.com/huonw/poetry-path-deps-issue.git pip install poetry-path-deps-issue/b
The core layout is:
Where
b/pyproject.toml
contains a dependencya = { path = "../a" }
(c
is left over from an older version of this issue, see below).The
pip install .
fails with:Click for older details using poetry export
c/pyproject.toml
contains a dependencyb = { path = "../b" }
.Commands:
After running those commands, the requirements.txt contains something like:
And the pip install output is:
Workaround
We're preprocessing all
pyproject.toml
files to remove the path dependencies, after exporting the requirements, but before installing them (viafind -name pyproject.toml | xargs sed -i '/path =/d'
). The export should contain all of the dependencies required, so we don't them to be re-read out of eachpyproject.toml
.Full output
The text was updated successfully, but these errors were encountered: