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

dependency dependant on python version #5955

Closed
coldcoff opened this issue Sep 28, 2023 · 3 comments
Closed

dependency dependant on python version #5955

coldcoff opened this issue Sep 28, 2023 · 3 comments

Comments

@coldcoff
Copy link

I have a project running with Python 3.6 - 3.11.

When installing with Python 3.6 and 3.7 it now fails with "flake8", as flake 8 dropped support for Python < 3.8.

So for these old Pythons to work I need to fixate the flake version to be < 6. Easy.
But: On Python >= 3.8 flake8 could be any version, why not use the latest...

I read about markers and tried to write a Pipfile to reflect that:

...
flake8 = {markers="python_version < '3.8'", version = "<6"}
flake8 = {markers="python_version >= '3.8'", version = "*"}
...

but that fails

...
pipenv.vendor.tomlkit.exceptions.KeyAlreadyPresent: Key "flake8" already exists.

How to solve that? Can I specify that in one line somehow?
Is there some syntax to specify package versions per python version?

Or should I play with different Pipfiles per Python version?

PIPENV_PIPFILE=path/to/pipfile pipenv install

and duplicate the Pipfile(s) in the project?

What's the best practice here?

@matteius
Copy link
Member

Possibly helpful for what you are trying to do is this prototype PR that allows specifying which python/system information you want the resolver to operate against with respect to markers: #5931

@matteius
Copy link
Member

Worth noting there is not support to lock different versions of the same package based on python version or system platform -- you basically get the one resolved version.

@coldcoff
Copy link
Author

Thank you, that PR looks really interesting!

Meanwhile I was able to avoid that "conditional" and solve that indirectly by specifying constraints for older python versions for the problematic sub-dependency only. The resolver does the right thing, then.

That works.

[dev-packages]

flake8 = "*"

# needed for flake8 for Python 3.6 and Python 3.7
importlib-metadata = { version = ">=1.1.0,<4.3", markers = "python_version < '3.8'"}

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants