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: use range when adding requirement #536

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

baszalmstra
Copy link
Contributor

@baszalmstra baszalmstra commented Dec 4, 2023

Implements the behavior described in #285 .

When running pixi add python we would previously look at all platforms, add the requirement, and solve the environment. We would then take the lowest version between all platforms and pin that. So currently for python that would result in the requirement:

python = "3.12.0.*"

This is a very strict requirement. And would also fail to resolve if this version (or a higher version) is not available for all platforms (see #526 ).

This PR changes the behavior by instead adding a range requirement that allows change in the last segment of the version. And allowing for multiple versions if a version is not available for all platforms.

For python this would become:

python = ">=3.12.0,<3.13"

For the issue described in #526, this becomes:

ros-humble-rosbridge-server = ">=1.2.0,<1.4"

Note that 1.4 is selected instead of 1.3. This is because 1.2 is not available for all platforms.

Fix #526
Fix #285

@ruben-arts
Copy link
Contributor

While testing this i got this situation. Not sure if this has anything to do with this pr yet. Just putting it here.

I get this error:

❯ pixi add python --build -p linux-64
  × Cannot solve the request because of: The following packages are incompatible
  │ |-- ros-humble-rosbridge-server >=1.2.0,<1.4 can be installed with any of the following options:
  │     |-- ros-humble-rosbridge-server 1.2.0 | 1.2.0 would require
  │         |-- python_abi 3.9.*, which can be installed with any of the following options:
  │             |-- python_abi 3.9
  │             |-- python_abi 3.9
  │ |-- python >=3.12.0,<3.13 cannot be installed because there are no viable options:
  │     |-- python 3.12.0 would constrain
  │         |-- python_abi 3.12.* *_cp312 , which conflicts with any installable versions previously reported
  │ 

On this initial pixi.toml file:

[project]
name = "range"
channels = ["conda-forge", "robostack-humble"]
platforms = ["linux-64", "osx-arm64", "osx-64"]

[tasks]

[dependencies]
ros-humble-rosbridge-server = ">=1.2.0,<1.4"
python = ">=3.9.15,<3.10"

It does add the following part to the pixi.toml but then fails the solve. Which is a known issue.

[target.linux-64.build-dependencies]
python = ">=3.12.0,<3.13"

But the version seems weird as that will not match with the ros-humble requirement

@ruben-arts
Copy link
Contributor

Found it, this has nothing to do with this PR. But sits in the way we deal with the --build and --host in the fn add_specs_to_project:

let current_specs = match spec_type {
            SpecType::Host => project.host_dependencies(platform)?,
            SpecType::Build => project.build_dependencies(platform)?,
            SpecType::Run => project.dependencies(platform)?,
        };

This should not be done as we are solving them together. Will make a different PR to fix this.

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.

Awesome, works for me!

@ruben-arts ruben-arts merged commit e69f31e into prefix-dev:main Dec 4, 2023
9 checks passed
baszalmstra pushed a commit that referenced this pull request Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants