Skip to content
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

Strange skipping of dependencies when python requirement is specified ("Not needed for the current environment") #2187

Closed
3 tasks done
adithyabsk opened this issue Mar 14, 2020 · 6 comments · Fixed by #2361
Labels
kind/bug Something isn't working as expected
Milestone

Comments

@adithyabsk
Copy link

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Poetry Debug Info

Poetry
Version: 1.0.5
Python:  3.6.8

Virtualenv
Python:         3.6.8
Implementation: CPython
Path:           /Users/adithyabalaji/.pyenv/versions/3.6.8/envs/test368
Valid:          True

System
Platform: darwin
OS:       posix
Python:   /Users/adithyabalaji/.pyenv/versions/3.6.8

MVP Erroring pyproject.toml

[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Adithya"]

[tool.poetry.dependencies]
python = "^3.6.1"

[tool.poetry.dev-dependencies]
seed-isort-config = { version = "^2.1.0", python = "^3.6.1"}

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue

When I run poetry install I expect all packages to be installed when running python 3.6.8, that doesn't seem to happen and I get the following output. It does work if I remove the python requirement on the dependency.

While this configuration doesn't make much sense in this case, consider the case where multiple python versions need to be supported (ie in my case I'm making the last release for python 2.7 for a package and thus, need to support multiple python versions at least for one more release.

I also know that this bug isn't isolated to seed-isort-config, I tried a few other packages just to be safe and found it produces the same result for flake8, etc... So it seems to be a poetry issue.

$ poetry install -vvv
Using virtualenv: /Users/adithyabalaji/.pyenv/versions/3.6.8/envs/test368
Installing dependencies from lock file

No dependencies to install or update

  - Skipping cached-property (1.5.1) Not needed for the current environment
  - Skipping aspy.refactor-imports (2.1.0) Not needed for the current environment
  - Skipping seed-isort-config (2.1.0) Not needed for the current environment
@adithyabsk adithyabsk added the kind/bug Something isn't working as expected label Mar 14, 2020
@adithyabsk
Copy link
Author

adithyabsk commented Mar 14, 2020

Might be related to #2177

Although the issues are unrelated, I tried the suggested resolution and it didn't work in my case as well. #2177 (comment)

@adithyabsk
Copy link
Author

I just went through and tested all prior poetry versions down to 0.12.13 which is where I gave up and the bug seems to exist in each of those releases.

@adithyabsk
Copy link
Author

Okay, I think I've figured out the bug after some debugging. Basically, dependency resolution that includes a python patch version breaks down in a weird way due to the difference between the python_version and python_full_version

@adithyabsk
Copy link
Author

The short-term solution to my problem is to not use patch versions.

Looking at the codebase it seems that it will be somewhat difficult to refactor the codebase to allow for patch version python version constraints. The concept of python_version is hardcoded in a lot of places and manifests itself in the lock file as well. Someone with a better understanding of the project will have to chime in to note whether fixing this is even feasible.

An example of why this might be difficult to re-factor is here. It's where I left off and if someone decides to take this up, what needs to be done, as far as I understand it, is to modify the create_nested_marker function to determine what the "name" of the constraint is if it is not passed in so it can determine whether to use python_version or python_full_version. I'd also note that there seem to be two versions of the function in the codebase:

create_nested_marker in utils and the private _created_nested_marker in the Dependency class.

if not markers:

            if not markers:
                marker = AnyMarker()
                if python_versions:
                    dependency.python_versions = python_versions
                    marker = marker.intersect(
                        parse_marker(
                            create_nested_marker(
                                "python_version", dependency.python_constraint
                            )
                        )
                    )

@dimbleby
Copy link
Contributor

This was duplicated by #3347, and is now long since fixed.

@Secrus Secrus closed this as completed May 21, 2022
Copy link

github-actions bot commented Mar 2, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants