-
Notifications
You must be signed in to change notification settings - Fork 430
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
run
environment gets old setuptools from wrong Python
#1539
Comments
In jaraco/pipx-1539@57411d4, I attempted to create a minimal reproducer, but in that minimal environment, the issue doesn't reproduce, so there's some other factor at play. |
In this run (from jaraco/pipx-1539@c120c9e), I've replicated the issue minimally, only using |
For posterity, here's the workflow: name: tests
on:
push:
jobs:
test:
strategy:
fail-fast: false
matrix:
python:
- "3.12"
platform:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Run tests for ${{ matrix.python }} (${{ runner.os }})
run: pipx run --python ${{ matrix.python}} --spec setuptools python -c "import setuptools" And here's the output:
|
I tried replicating the issue using Docker, but even using ubuntu:jammy and installing python3-setuptools and pipx using apt, the issue doesn't replicate. Curiously there, |
Aha! Using the latest pipx, I'm able to replicate the issue in a Docker image: FROM ubuntu:jammy
RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN apt-add-repository -y ppa:deadsnakes
RUN apt update
# Disable interactive on the installs below
ENV DEBIAN_FRONTEND=noninteractive
# Set TZ to avoid spurious errors from Sphinx (nektos/act#1853)
ENV TZ=UTC
# Install Pythons
RUN apt install -y python3.10 python3.10-dev python3.10-venv
RUN apt install -y python3.12 python3.12-dev python3.12-venv
RUN apt install -y python3-setuptools python3-pip
RUN python3 -m pip install pipx
CMD pipx run --python 3.12 --spec setuptools python -c "import setuptools" |
I can see that when launching python,
|
I thought maybe site-packages was relevant, as that affects
I see that the python3.10 path doesn't appear there. But then I realized that the main reason that that the distutils shim doesn't take effect is it's an older version of setuptools whose I did notice that setting I guess My question to the pipx team - is it reasonable/expected for pipx shared libs for the wrong Python version to end up on the Python path for the package installation and app invocation? |
I've confirmed that |
run
environment gets old setuptools from wrong Python
In #1078, it appears as if someone has attempted to remove setuptools and wheel from the shared libraries, but that appears not to be the case. |
It appears that pipx gets setuptools as the default behavior for |
I could potentially work around this issue by updating the Ubuntu image to 24.04, which bumps the default python3 to 3.12, which produces a venv without setuptools. However, that won't address the issue for the Windows host. |
Workaround for pypa/pipx#1539. Generated by Gemini (https://g.co/gemini/share/be240bbc9a1c).
I'm so dang close to having a usable workaround. In jaraco/pipx-1539@c2a124f, I have a GitHub action that works around the issue on Linux by running a script to uninstall setuptools. The same script, however, fails to run on Windows due to |
In https://github.com/jaraco/pipx-1539/actions/runs/10752003994, I have a run that succeeds... and all it requires to work around the issue is to add the following to the github workflow:
Still, it would be nice if pipx had a more permanent, integrated solution. |
Sorry for the oversight. What would you recommend? Uninstalling |
That's what I was thinking. Other options to consider:
My preference is uninstall or avoid installing.
That seems the least disruptive option. And the cost is small comparable to the cost of already installing an unwanted package. |
In coherent-oss/system#17 (comment), we've adopted
pipx
to run a cli tool (coherent.test
). The command is simple:One of the dependencies of
coherent.test
issetuptools
(by way ofsetuptools-scm
).Nevertheless, setuptools fails to import:
As you can see from the traceback, even though Python 3.12 was indicated, the dependency on
setuptools
was satisfied by the pipx install under Python 3.10. Under Python 3.10, one might expect distutils to be supplied by the stdlib, so might install Setuptools in such a way that it relies on the stdlib, but on Python 3.12, distutils is gone, so relies entirely on the vendored copy of distutils.It seems a bug to me that pipx would allow any dependency to be satisfied by an environment for another Python version, especially if
--system-site-packages
wasn't part of the command.This issue occurs on both Ubuntu and Windows in GitHub CI, so a fairly standard environment, but not one over which I have much control.
Any advice on why the wrong Setuptools is being involved here?
The text was updated successfully, but these errors were encountered: