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

fix: improve version conversion #1201

Merged
merged 3 commits into from
Apr 17, 2024
Merged

Conversation

wolfv
Copy link
Member

@wolfv wolfv commented Apr 16, 2024

This improves the logic a little bit.

Python versions like ==3.11.* now get parsed to 3.11.* which works better for conda requirements.

We warn the user if there is both a requires-python and a python dependency in the tool.pixi.dependencies section.

We prefer the requires-python over a value in the pixi deps.

cc @olivier-lacroix

fixes #1193

@olivier-lacroix
Copy link
Contributor

Thanks @wolfv ! I am not sure of what order of precedence we should have (if any). When I thought about it, it seemed more logical to me to let the solver handle various constraints, coming from various tables

@wolfv
Copy link
Member Author

wolfv commented Apr 16, 2024

@olivier-lacroix that works, theoretically! Unfortunately calling add_dependency puts the dependency into a hash table that can have only a single entry for Python ...

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the python dependencies this looks good

version_or_url_to_nameless_matchspec(&pythonspec).unwrap(),
SpecType::Run,
);
if !target.has_dependency("python", Some(SpecType::Run)) || python_spec.is_some() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not make the requires-python be more important then the pixi one. This won't let the user overwrite it if they want a different version from what the build package is allowed to use. e.g.

requires-python = `>=3.7` 

Will always give you the latest version but users might want to run their environment on 3.9 and then they can't overwrite that in the tool.pixi section.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we also don't want a warning, in that case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, it will get annoying fast. Possibly an tracing::info

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to not do anything for other interpreters? Pypy, etc…

@ruben-arts ruben-arts self-requested a review April 16, 2024 07:17
@olivier-lacroix
Copy link
Contributor

@olivier-lacroix that works, theoretically! Unfortunately calling add_dependency puts the dependency into a hash table that can have only a single entry for Python ...

Ah. Then indeed, I think it would make sense to have the pixi.dependency table take precedence over the require-python

@wolfv wolfv force-pushed the requires-python branch from 44b28b7 to b65b662 Compare April 17, 2024 08:05
@wolfv wolfv force-pushed the requires-python branch from b65b662 to 92557cd Compare April 17, 2024 08:05
@ruben-arts ruben-arts merged commit 61c5ce5 into prefix-dev:main Apr 17, 2024
10 checks passed
@ruben-arts ruben-arts changed the title fix: make requires-python take precedence, improve version conversion fix: improve version conversion Apr 17, 2024
@olivier-lacroix
Copy link
Contributor

Great! Thanks @wolfv !

@wolfv
Copy link
Member Author

wolfv commented Apr 17, 2024

Just to note - this overrides the requires-python constraint for the moment (with whatever comes from the pixi dependencies.

It would be a future improvement to take both constraints into account.

@MatusGasparik
Copy link

Just to note - this overrides the requires-python constraint for the moment (with whatever comes from the pixi dependencies.

It would be a future improvement to take both constraints into account.

Just, to make sure: The fact that I have this in the pyproject.toml:

#  cat pyproject.toml | grep "requires-python"
requires-python = "~= 3.11"

But my "default" pixi environment is:

# pixi run python -V
Python 3.12.3

...is an expected behavior? Do I need to add the same constraint to [tool.pixi.dependencies] to make it work?

@olivier-lacroix
Copy link
Contributor

You should not need to. But the conversion between pypi & conda constraints is pretty simple at the moment. Basically, your requires-python need to be interpretable as a conda constraint. Maybe try something like ==3.11.*

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

Successfully merging this pull request may close these issues.

Pixi updates python without being asked
4 participants