pixi icon indicating copy to clipboard operation
pixi copied to clipboard

feat: new `pixi global`

Open Hofer-Julian opened this issue 1 year ago • 1 comments

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
⚠️  You don't have a global manifest yet.
Do you want to create one based on your existing installation?
ENTER!!

# 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

Hofer-Julian avatar Aug 19 '24 07:08 Hofer-Julian

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.

ruben-arts avatar Aug 21 '24 09:08 ruben-arts

I have some messy left-overs from an earlier try.

I have files like:

#!/bin/sh
export PATH="/Users/wolfv/.pixi/envs/baz/bin:${PATH}"
export CONDA_PREFIX="/Users/wolfv/.pixi/envs/baz"
"/Users/wolfv/.pixi/envs/baz/bin/pip" "$@"

Where the .pixi/envs/baz does not exist anymore. I think we can / should check if the path still exists, and if not, we could also delete the shell script that links to the environment as a clean up.

EDIT by @Hofer-Julian: Should be fixed by https://github.com/prefix-dev/pixi/pull/2234

wolfv avatar Oct 08 '24 11:10 wolfv

When running for the first time:

$ pixi global list
⚠️  You don't have a global manifest yet.
Do you want to create one based on your existing installation?
⚠️  You don't have a global manifest yet.
Do you want to create one based on your existing installation?
Your existing installation will be removed if you decide against it. yes
  × Failed to create global manifest from existing installation
  ├─▶ Failed to extract exposed binaries from existing installation please clean up your installation.
  ├─▶ failed to read directory `/Users/tdejager/.pixi/envs/rattler-build/conda-meta`
  ╰─▶ No such file or directory (os error 2)

I don't remember doing anything with that folder? Maybe a bad global remove?

EDIT by @Hofer-Julian: Should be fixed by https://github.com/prefix-dev/pixi/pull/2234

tdejager avatar Oct 08 '24 11:10 tdejager

When updating multiple envs, I don't know which one is currently updating (just see the name of the last one that was updated)

Screenshot 2024-10-08 at 13 59 12

wolfv avatar Oct 08 '24 11:10 wolfv

I was scared when it told me that we would remove everything. Maybe not have this option?

EDIT by @Hofer-Julian: Should be fixed by https://github.com/prefix-dev/pixi/pull/2234

tdejager avatar Oct 08 '24 12:10 tdejager

As a user starting out I don't really have an idea that it's using a manifest and that there are some more features. Maybe with the migration it could give me some information in the console?

tdejager avatar Oct 08 '24 12:10 tdejager

Also it told me it remove the installation folder, but sync still seems to remove some things.

tdejager avatar Oct 08 '24 12:10 tdejager

Ohhh I want to see that shiny new manifest! How do I know what the path is? Can I use pixi global edit to open it in my $EDITOR?

EDIT by @Hofer-Julian: Will be fixed by https://github.com/prefix-dev/pixi/pull/2219

tdejager avatar Oct 08 '24 12:10 tdejager

Screenshot 2024-10-08 at 14 04 06

Doesn't show me version numbers which makes me saaaad :)

wolfv avatar Oct 08 '24 12:10 wolfv

I was looking at pixi global add --help and the it's a bit hard to read the examples, like they all seem grouped together:

Adds dependencies to an environment

Example: pixi global add --environment python numpy pixi global add --environment my_env pytest pytest-cov --expose pytest=pytest

EDIT by @Hofer-Julian: fixed

tdejager avatar Oct 08 '24 12:10 tdejager

I try to install older versions of rattler build which seems to either do nothing or be insanely fast. It at least doesn't give me much feedback.

Screenshot 2024-10-08 at 14 05 59

wolfv avatar Oct 08 '24 12:10 wolfv

Ahhh this kind of makes me think I can install pypi stuff as well, this is from the add command help:

      --pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
          Specifies if we want to use uv keyring provider
          
          [possible values: disabled, subprocess]

tdejager avatar Oct 08 '24 12:10 tdejager

When I do pixi global install rattler-build=0.19 and then do pixi global install rattler-build it also seems to update rattler-build?

wolfv avatar Oct 08 '24 12:10 wolfv

Can I see the location of the pixi toml as well in list?

╰─ pixi global list                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ─╯
Global environments at /Users/tdejager/.pixi:
├── bat: 0.24.0
├── ipython: 8.28.0
│   └─ exposes: ipython, ipython3
├── keyring: 25.4.1
└── nvim: 0.10.2

tdejager avatar Oct 08 '24 12:10 tdejager

When I do this:

 pixi global a --environment keyring keyrings.google-artifactregistry-auth                                                                                                                                                                                                                                                                                                                                                                                                                             
✔ Added package 'keyrings.google-artifactregistry-auth=1.1.1=pyhd8ed1ab_0'

I think I'd rather see:

pixi global a --environment keyring keyrings.google-artifactregistry-auth
├── keyring
    └── dependencies: keyring 25.4.1, keyrings.google-artifactregistry-auth 1.1.1

Cause I'll probably always use pixi global list as a sanity check if it works.

tdejager avatar Oct 08 '24 12:10 tdejager

I wonder if we should change the output:

╰─$ ixi global install "rattler-build 0.19"
✔ Added executable 'generate-cli-docs'.

To something that prints ✔ Added executable <color>generate-cli-docs</color>

wolfv avatar Oct 08 '24 12:10 wolfv

Should we add the global manifest and the global bin dir to the output of pixi info?

wolfv avatar Oct 08 '24 12:10 wolfv

I noticed that pixi global expose remove foo needs an env although there should probably be only a single foo anyways.

wolfv avatar Oct 08 '24 12:10 wolfv

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.

wolfv avatar Oct 10 '24 22:10 wolfv

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.

wolfv avatar Oct 11 '24 06:10 wolfv

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

ruben-arts avatar Oct 11 '24 06:10 ruben-arts

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

chawyehsu avatar Oct 11 '24 10:10 chawyehsu

Oh nice find @chawyehsu!

Hofer-Julian avatar Oct 11 '24 12:10 Hofer-Julian