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

updating setuptools causes pip to no longer import as a module successfully #10737

Closed
1 task done
kevinushey opened this issue Dec 20, 2021 · 5 comments
Closed
1 task done
Labels
project: setuptools Related to setuptools type: bug A confirmed bug or unintended behavior

Comments

@kevinushey
Copy link

Description

After upgrading setuptools, I'm no longer able to import pip as a module within a Python REPL. This is on macOS, using Python 3.9.9 from Homebrew.

/opt/homebrew/bin/python3 -m venv /tmp/venv
/tmp/venv/bin/python -m pip install --upgrade setuptools
/tmp/venv/bin/python -c 'import pip; print(pip.__version__)'

Running this, I see:

$ /tmp/venv/bin/python -c 'import pip; print(pip.__version__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/private/tmp/venv/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 83, in find_spec
    return method()
  File "/private/tmp/venv/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 104, in spec_for_pip
    if self.pip_imported_during_build():
  File "/private/tmp/venv/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 115, in pip_imported_during_build
    return any(
  File "/private/tmp/venv/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 116, in <genexpr>
    frame.f_globals['__file__'].endswith('setup.py')
KeyError: '__file__'

Expected behavior

Ideally, pip should load as a module without issue.

pip version

21.3.1

Python version

3.9.9

OS

macOS 12.1

How to Reproduce

See above.

Output

See above.

Code of Conduct

@kevinushey kevinushey added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Dec 20, 2021
@kevinushey
Copy link
Author

The official documentation suggests keeping these up-to-date together:

https://packaging.python.org/en/latest/tutorials/installing-packages/#ensure-pip-setuptools-and-wheel-are-up-to-date

That said, I'm not sure whether this would be considered an issue in pip or setuptools.

@pfmoore
Copy link
Member

pfmoore commented Dec 20, 2021

That _distutils_hack file isn't part of pip, so this isn't a pip issue. It looks like the file is installed by setuptools, so maybe report this to setuptools?

@pfmoore
Copy link
Member

pfmoore commented Dec 20, 2021

Actually, see pypa/setuptools#2941

@kevinushey
Copy link
Author

Thanks! I just spotted that as well; it does indeed appear to be a setuptools issue. Sorry for the noise.

@pfmoore
Copy link
Member

pfmoore commented Dec 20, 2021

No worries, thanks for reporting it, it's good to have visibility of it in case others report it here too.

@DiddiLeija DiddiLeija added project: setuptools Related to setuptools and removed S: needs triage Issues/PRs that need to be triaged labels Dec 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
project: setuptools Related to setuptools type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants