-
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 add
and init
can create incompatible settings in pyproject.toml
#707
Comments
Poetry should select the proper constraint for Django by using the Python constraint of the project. So in this case it should use "^1.8" (So your point 3.). Point 1 would seem odd since you would get an error later on saying that the current project is not compatible with the currently activated Python version. So 3 would provide the most intuitive experience. |
@sdispater thanks for responding so quickly. Yes I see your point. I was thinking that maybe you consider the project itself (as defined by But I agree that would be pretty frustrating for most normal cases, where you'd definitely want to set up the project and then immediately start using it. So, yes, |
add
and init
can create incompatible settings in pyproject.toml
I don't think that the problem. What I see is that poetry will always resolve to the latest version and try to install it. Take this example:
I create a new repository and set the python version to 3.7.*. Next, I add django as a dependency. Django dropped support for Python 3.7 with Django 4.0 (docs). Poetry defaults to resolve to the latest available version. It then tries to install django in that version, but realises that it is not compatible to version 3.7. And instead of finding a compatible version, which would be <4.0, it just gives up. It even suggests to remove the Python version marker, which is the exact opposite of what I want to do. This behaviour is not helpful. Instead of supporting me in my endeavour, I'm expected to adapt to the tool. But then I ask myself, what do I need poetry for, when it just adds to tool-bloat, when I could just use pip with the same effort. Instead of giving up, poetry should get the highest compatible version to the previous dependency (which is python 3.7.*) and install that. This does also not only apply to Django, but to basically every package you add to a project. |
Completely agree with #707 (comment) above. Yesterday I found this makes working with older versions of Python a pain. Is this behavior intended or are we running into a bug here? |
I guess I have some fundamental misunderstanding of intended usage. The main docs page says
What is the recommended way to e.g., use the most recent set of compatible versions for all dependencies? My failure and workaround is probably not hitting on those most recent versions. |
Your issue is not the resolver but the semantics of |
The docs for
Which later is followed up by
So I would expect Regarding my current use case - I am trying to install the package numpy for python 3.8.* using poetry. The newest version of numpy requires python3.9, so Something to note is that Pycharm for example (haven't tested vscode yet), also uses Edit |
docs improvements are a great way to contribute, please go ahead |
Hello, Just to confirm after reading all the comments: is there a roadmap for solving this issue? It seems like the comments above clearly define the issue. My personal two cents: |
Just to mention - with |
-vvv
option).Issue
If I try to create a
pyproject.toml
with Python2 but with Django as a dependency, it creates apyproject.toml
that is incompatible:This is because these two requirements are fundamentally not quite compatible:
I understand that this might be difficult for Poetry to resolve as it might not have the information that Django 2.1 doesn't work on python < 3.5 at the time it's creating the
pyproject.toml
. But it's unfortunate that this means that the setup experience for a poetry-based Django project requires such deeper understanding.Possible solutions could be:
poetry init --dependency django
would set the version of python inpyproject.toml
to^3.5
(maybe with a warning that your current version of python is lower than that)poetry init --dependency django
would error if the current python version was unsupportedpoetry init --dependency django
would select the most recent version of Django supported by the current version of pythonI think the nicest experience would be 1. - as you might want to generate a valid
pyproject.toml
with any version of python, in the full knowledge that you can't actually run the project with that version.The text was updated successfully, but these errors were encountered: