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: new pixi global #1833

Merged
merged 85 commits into from
Oct 16, 2024
Merged

feat: new pixi global #1833

merged 85 commits into from
Oct 16, 2024

Conversation

Hofer-Julian
Copy link
Contributor

@Hofer-Julian Hofer-Julian commented Aug 19, 2024

This adds functionality as described in https://pixi.sh/dev/design_proposals/pixi_global_manifest/

Test it locally by doing the following:

# Clone the repository
git clone https://github.com/prefix-dev/pixi.git

# Navigate into the repository
cd pixi

# Checkout a specific branch
git switch feature/pixi-global

# Install the Rust project with a custom binary name
pixi run install-as pixid

Helpful tests for us:

# Make sure that your current setup is loaded into a manifest in $HOME/.pixi/manifests/pixi_global.toml
> pixi global sync

# Make sure running install adds a package and exposed the binaries
> pixi global install nushell
> nu

# Make sure binaries can be properly exposed as specials
> pixi global install "python==3.10.*" --expose python310=python
> python310

This adds functionality and tests to parse the `pixi-global.toml` as
described in the
[proposal](https://pixi.sh/dev/design_proposals/pixi_global_manifest/)
@Hofer-Julian Hofer-Julian changed the title feature: Pixi global manifest feat: Pixi global manifest Aug 19, 2024
@Hofer-Julian Hofer-Julian changed the title feat: Pixi global manifest feat: pixi global manifest Aug 19, 2024
@ruben-arts ruben-arts changed the title feat: pixi global manifest feat: new pixi global Aug 19, 2024
@ruben-arts ruben-arts added this to the New `pixi global` milestone Aug 20, 2024
@baszalmstra baszalmstra added the area:global Related to pixi global label Aug 20, 2024
@ruben-arts
Copy link
Contributor

Nitpick: I'm not a fan of the project directory as this has nothing to do with the "pixi projects". I would just move all the code into the src/global. And then you could move the manifest into its own module for instance.

Hofer-Julian and others added 10 commits September 2, 2024 09:11
Main features:
- minimal implementation of `pixi global sync`
- it creates environments if they are on the manifest but not on the
systsem
- it deletes environments if they are not in the manifest
- It adds binaries that are exposed in the manifest
- It removes binares that are not exposed in the manifest
- it doesn´t check yet whether environments already exist to avoid
double work
- it doesn´t import from existing environments on the system yet

Side features:
- Add `sort_channels_by_priority` function
- Heavily refactor structs in `common.rs`
- Add many tests

How to test:

Create `~/.pixi/manifests/pixi-global.toml` with:

```toml
# The name of the environment is `python`
[envs.python]
channels = ["conda-forge"]
# optional, defaults to your current OS
# platform = "osx-64"
# It will expose python, python3 and python3.11, but not pip
[envs.python.dependencies]
python = "3.11.*"
pip = "*"

[envs.python.exposed]
python = "python"
python3 = "python3"
"python3.11" = "python3.11"

# The name of the environment is `python3-10`
[envs.python3-10]
channels = ["https://fast.prefix.dev/conda-forge"]
# It will expose python3.10
[envs.python3-10.dependencies]
python = "3.10.*"

[envs.python3-10.exposed]
"python3.10" = "python"
```

---------

Co-authored-by: nichmor <nmorkotilo@gmail.com>
As soon as we implement it, this marker should throw an error
@ruben-arts ruben-arts linked an issue Sep 20, 2024 that may be closed by this pull request
Hofer-Julian and others added 6 commits September 20, 2024 16:04
It now informs you if `pixi global sync` did nothing
Some missing things:

- [x] : public doc strings
- [x] : tests
- [x] : better errors
- [x] : running pixi global sync at the end

it is also should be merged after
#1975 lands first

---------

Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com>
Co-authored-by: Julian Hofer <julianhofer@gnome.org>
Cleaning up the creation of the manifest from existing environments.
Improving error.
@wolfv
Copy link
Member

wolfv commented Oct 10, 2024

When updating or instlaling I would like to see the new version that was installed afterwards.

Screenshot 2024-10-11 at 00 09 07

Also I had a situation where I did:

pixi global install rattler-build=0.23   # not the latest
pixi global update rattler-build  # did not do anything 

For the latter, I think it migth be good to print something. I know that might be more work though. Let's think about it tomorrow.

ruben-arts and others added 2 commits October 11, 2024 08:13
Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com>
@wolfv
Copy link
Member

wolfv commented Oct 11, 2024

And one last little one: I tried to figure out what version of rattler-build I had installed, but I think pixi global list does not let me filter right now? I tried pixi global list rattler and pixi global list rattler-build. My assumption was, that, like search it would show me things starting with these letters.

@ruben-arts ruben-arts removed the ci:free With this label only the free ci runners are used label Oct 11, 2024
@ruben-arts
Copy link
Contributor

@wolfv pixi g list -e rattler-build gives more info

Hofer-Julian and others added 2 commits October 11, 2024 09:19
Users will get an error message when they attempt to use `pixi global
upgrade` or `pixi global upgrade-all`

---------

Co-authored-by: Ruben Arts <ruben@prefix.dev>
@chawyehsu
Copy link
Contributor

chawyehsu commented Oct 11, 2024

Packages having underscore in their name get ignored

$ pixi g list
Global install location: C:\[redacted]\
├── conda-smithy 3.41.1
|   └─ exec: feedstocks.bat, conda-smithy.bat
├── huggingface_hub 0.25.1
|   └─ exec: huggingface-cli.bat
├── rattler-build 0.23.0
|   └─ exec: rattler-build.bat, generate-cli-docs.bat
└── uv 0.4.17
   └─ exec: uvx.bat, uv.bat

$ pixi-next g list
WARN Failed to parse environment name 'huggingface_hub', please use only lowercase letters, numbers and dashes
Global environments as specified in 'C:\[redacted]\manifests\pixi-global.toml'
├── conda-smithy: 3.41.1
│   └─ exposes: feedstocks, conda-smithy
├── rattler-build: 0.23.0
│   └─ exposes: generate-cli-docs, rattler-build
└── uv: 0.4.17
   └─ exposes: uvx, uv

@Hofer-Julian
Copy link
Contributor Author

Oh nice find @chawyehsu!

Hofer-Julian and others added 13 commits October 14, 2024 10:33
Normalize input in `EnvironmentName::from_str`
Only error on non-unique exposed names when the already existing exposed
name is in a different environment
Fixes on windows:
```
pixi global edit code
```


Aligns `edit` cli:
```
pixi config edit -g code
```
Extend them and make them more consistent
I thought that it would be nice to name it the same as we have it in
`pixi exec`

---------

Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com>
clap-rs/clap#4507 (comment)
`num_args = 1.. ` don't make packages a mandatory argument.
This PR aims to fix this, and some other stylistic usage of report
instead of computing println message
fixes:
```
pixi global install python

pixi global install python==3.10
Error can't find exposed `python3.13`
```

---------

Co-authored-by: Julian Hofer <julianhofer@gnome.org>
Give a more helpful error message if `--environment` is missing
Doesn't change reporting, but the code is now a bit more logical
It isn't reliable on Windows

---------

Co-authored-by: nichmor <nmorkotilo@gmail.com>
@ruben-arts ruben-arts marked this pull request as ready for review October 16, 2024 07:25
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 work 🚀

@Hofer-Julian Hofer-Julian enabled auto-merge (rebase) October 16, 2024 07:27
auto-merge was automatically disabled October 16, 2024 07:46

Rebase failed

@Hofer-Julian Hofer-Julian merged commit 1fdc406 into main Oct 16, 2024
44 checks passed
@Hofer-Julian Hofer-Julian deleted the feature/pixi-global branch October 16, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:global Related to pixi global
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pixi global inject
7 participants