-
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
Poetry does not properly resolve install-requires for certain GIT packages #8774
Comments
Transferring from #4325 (comment): Here, we only use the information from setup.py if it is "complete" (otherwise we do a build): poetry/src/poetry/inspection/info.py Lines 583 to 586 in 48a76fd
So the question is why don't we try a build even though we were not able to parse Nevertheless, it might make more sense to convince projects to specifiy their dependencies in a more static way when using setuptools. |
Would it be reasonable to add a field to the git dependency specification that indicates "hey, this repo does some funky stuff, skip the heuristics, just build it and get the dependencies and other metadata from the output, I'm okay with that being slower" ? While I agree that static configuration is "the right way (tm)", at least from my experience, a large chunk of the ecosystem hasn't, and has no interest in switching. The pragmatic approach would be to have some sort of "escape hatch" like this. Otherwise, poetry is basically unusable if one has to fork such a project. |
Unnecessary complexity. If this is something you're interested in, it would be just as simple to fix it. Somewhere round about here, poetry is just ignoring things that it doesn't understand. Instead have it signal that it can't understand them: by returning |
I will readily admit that I am a total novice to poetry's code base but in general I feel that having heuristics that "produce the wrong result" is probably not a great behavior. I agree with @dimbleby that at a minimum, a failure to parse should raise an exception (it would at least inform the user that poetry cannot be used safely/correctly with that repository). My personal preference though would be:
It does seem that right now, in some cases, the package is built just not in all failure modes. I think this is what @radoering is saying -- ie: the heuristic is failing to detect that it couldn't parse the information properly. The behavior of "fallback to build" is the right one imho, but failure cases need to be more properly detected. |
The code already falls back to building, if reading But this is open source: someone who wants this has to do the work! |
To be frank, relying on heuristics while demanding others rework their project to use static configuration for reliability and repeatability seems at least a little hypocritical, especially when the justification for both is "it works now, why change?". Heuristics are great up until they don't do what you want or do what you don't want. Being able to statically configure what you expect from poetry, and have it fail if it can't follow through seems like the best choice. The problem with heuristics is that there will always be edge cases that you can't predict, and there is always the possibility that a user might want to force a build for reasons that cannot be conceived of right now. If it failed here, even with this fix, what gives you confidence it won't fail in other ways? Simplicity is great, unless you're simply wrong. |
This isn't a question of heuristics, it's a straight bug. Poetry is trying to read setup.py, thinks it knows what it is doing, and it gets it wrong. If this is important to you, please submit a pull request. |
if encountering something we don't understand, best assume that we can't get the right answer fixes python-poetry#8774
if encountering something we don't understand, best assume that we can't get the right answer fixes python-poetry#8774
This remains an issue in 1.8.1 . Add |
@meln5674 please raise a new issue. Thank you. |
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) and have included the output below.Issue
The issue is that when determining the install-requires dependency, it analyzes the setup.py file and notices that there is a install-requires but cannot parse it (it's a list comprehension and not a list). The end result is that this is then silently ignored here: https://github.com/python-poetry/poetry/blob/master/src/poetry/inspection/info.py#L565 because it doesn't check if install-requires is filled (and in fairness, shouldn't since some packages don't have that).
The crux of the issue is basically that in the SetupReader, there is no distinction between "value absent" and "value can't be read".
The proper behavior is probably to fallback to building the package if allowed in the case when the field exists but can't be extracted.
Steps to reproduce:
If you look at the CLIP project, you will see it has some requirements like torch but the poetry lock file lists no such thing and looks like this:
The text was updated successfully, but these errors were encountered: