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

feat: ability to override versions in constraints file #1116

Open
aryarm opened this issue Apr 19, 2023 · 5 comments
Open

feat: ability to override versions in constraints file #1116

aryarm opened this issue Apr 19, 2023 · 5 comments

Comments

@aryarm
Copy link

aryarm commented Apr 19, 2023

Use-case

I am trying to test my project against different versions of python. Unfortunately, one of the dependencies in my lock file only supports a subset of the python versions that I'd like to test.

For example, in my particular situation, I'd like to test my project against python 3.7 and 3.11. numpy is a dependency of my project.
My lock file contains numpy v1.21.1, which is compatible with python 3.7 but not 3.11. I could upgrade my lock file to a version compatible with 3.11 (like numpy v1.23.2), but unfortunately, those versions are no longer compatible with 3.7

Feature request

I would like to be able to do something like this:

if python_version == '3.11':
    session.install(".", f"numpy==1.23.2")
else:
    session.install(".")

But I think this will fail because pip does not allow for overriding constraints files like this.
Is there anything that I can do in this situation? Is there a way for me to override constraints from my lock file in nox-poetry?

Related to

@patrick91
Copy link

@aryarm as a work around I did this:

session._session.install(f"django=={django}")

@aryarm
Copy link
Author

aryarm commented Jul 11, 2023

@patrick91, great thanks! I'll try it out

can you say a bit more about why this works?

@patrick91
Copy link

@aryarm session._session.install(f"django=={django}") uses nox install command (which is just pip install ...) while session.install from nox-poetry uses pip --constraints ... install ... which will use the lock file (if I understood correctly) so it forces you to use specific versions, which is not what I/we want in this case 😊

@aryarm
Copy link
Author

aryarm commented Jul 11, 2023

ah, I see! thanks

but I suppose the downside of this would be that none of the other dependencies would be locked, right?

@aryarm
Copy link
Author

aryarm commented Nov 30, 2023

ok, I think I found a better approach to the problem using Nox's parametrization of python. Will this also work with nox-poetry, though? I want all except the parametrized versions to be locked.

image

aryarm added a commit to CAST-genomics/haptools that referenced this issue Dec 22, 2023
from cjolowicz/nox-poetry#1116 (comment)
since py3.11 is the most recent version we support anyway, so it's ok
if it uses the most recent versions of all our dependencies
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