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

Consider using ~= as the default instead of .* #285

Closed
baszalmstra opened this issue Aug 22, 2023 · 8 comments · Fixed by #536
Closed

Consider using ~= as the default instead of .* #285

baszalmstra opened this issue Aug 22, 2023 · 8 comments · Fixed by #536
Labels
✨ enhancement Feature request

Comments

@baszalmstra
Copy link
Contributor

baszalmstra commented Aug 22, 2023

Problem description

Currently pixi determines the latest version for all platforms and then inserts

foo = "1.2.3.*"

to the pixi.toml.

The problem with this approach is that we basically pin the dependency to a very narrow version range.

1.2.4 doesn't match 1.2.3.* for instance. Only "subversion" (1.2.3.1) would match it. I think this is a too narrow range.

Proposal

I propose that we use the ~= operator instead of the starts with postfix. ~=1.2.3 is the same as >=1.2.3,<1.3. So we would have:

foo = "~=1.2.3"
@baszalmstra baszalmstra added ✨ enhancement Feature request 👋 good first issue Good for newcomers labels Aug 22, 2023
@baszalmstra baszalmstra changed the title Consider using ~= as the default Consider using ~= as the default instead of .* Aug 22, 2023
@baszalmstra
Copy link
Contributor Author

We could also do (following the example above):

foo = "1.2.*"

if the latest version is 1.2.3. But that would also select 1.2.1 and 1.2.2 which might not be what you want.

@ruben-arts
Copy link
Contributor

I prefer the ~= over the * on the patch. But the more verbose version(>=1.2.3,<1.3) is a little more readable because the ~= might be unknown to a lot of people.

@YeungOnion
Copy link

I concur that the ~= will not be as familiar. But I think the implementation for matching on a "compatible with" operator need not be a logical AND of those comparisons behind the scenes. It doesn't expand to that in rattler.

What are your thoughts on still using ~= and also generates an inline comment that specifies what ~= is logically equivalent to when pixi add is used without a spec?

@dhirschfeld
Copy link
Contributor

But the more verbose version(>=1.2.3,<1.3) is a little more readable because the ~= might be unknown to a lot of people.

Even people who know about ~= might still have to double check the docs to make sure!

Given that, I think the explicit >=1.2.3,<1.3 is preferable. It also has the added benefit of being more easily manually adjusted after the fact if you want to pin to more tightly/loosely.

@SanchitMahajan236
Copy link

I want to contribute to this issue but I am not clear what I should do after reading this conversation. Can someone please help ?

@ruben-arts
Copy link
Contributor

He @SanchitMahajan236,

We didn't yet come to a consensus, what the version should look like. So I don't think it needs any work right now.

@baszalmstra
Copy link
Contributor Author

So let's make a decision here. I think there is more enthusiasm to use >=x.y.z,<x.(y+1). So lets go with that for now! @ruben-arts are you ok with that?

@ruben-arts
Copy link
Contributor

For sure!

ruben-arts pushed a commit that referenced this issue 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:

```toml
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:

```toml
python = ">=3.12.0,<3.13"
```

For the issue described in #526, this becomes:

```toml
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](https://prefix.dev/channels/robostack-humble/packages/ros-humble-rosbridge-server).

Fix #526 
Fix #285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement Feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants