Open ngoldbaum opened 1 month ago
And if I put the path to the uv-managed python at the front of my PATH environment variable, and then try to install something into its environment with uv pip install --system
, I get errors like:
error: The interpreter at /home/runner/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu is externally managed, and indicates the following:
This Python installation is managed by uv and should not be modified.
Consider creating a virtual environment with `uv venv`.
The way I've worked around this is by activating the virtualenv once, then inserting the updated PATH into GITHUB_ENV:
- uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d
- run: |
uv python install 3.13t
uv venv --python 3.13t
uv pip install pip
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
It looks like the setup-pixi
action has an activate-envrionment
option that does the same thing with a bit nicer of UX. Might it make sense for setup-uv
to do add a similar feature?
Could you please add a bit of context on the bigger picture and what you are trying to achieve?
My understanding is, that you want to use uv to install packages into your system (faster than with pip) to then use those packages without a venv. Is that correct?
EDIT: Saw the linked issue in numpy. I also tried a bit around and got to the same conclusions as you so far. Will keep you posted
Ah, great, glad you were ultimately able to figure out what I meant.
I agree it's a bit confusing, at the moment I'm going with:
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install package
run: uv pip install --quiet --system .[test]
But it doesn't seems like the recommended approach.
I feel like I'm going against the grain here and maybe that's the issue.
I'd like to replace
setup-python
withsetup-uv
. Our existing CI usespython
fromsetup-python
directly, without setting up a virtualenv.Is it possible to use
uv
in a similar way? Basically, I'd like to install directly into the global environment associated with auv python install
command. When I try to actually do that, I see errors like:Is the right thing to do here to put uv's python at the front of the
PATH
and then pass--system
? Or just use a virtualenv? If it's the latter, then this is not quite a drop-in replacement for setup-python, since that's not necessary with setup-python.