System setuptools leaks into isolated build environment
See original GitHub issueDescription
My project uses a custom in-tree build backend that wraps setuptools.build_meta
and its build-system hooks implementation. I’m trying to add support for editable installs. I’m running on a Fedora 36 box, and the system has setuptools 59 installed via the system package manager. Therefore, I request a higher setuptools version in pyproject.toml
. Looks like pip
actually installs the higher setuptools, but eventually the older one from the system is picked.
Expected behavior
pip
should use the requested version of setuptools.
pip version
22.2.2
Python version
3.10
OS
Fedora Linux 36
How to Reproduce
pyproject.toml
[project]
name = "foo"
version = "0.0.1"
[build-system]
requires = ["setuptools >= 64"]
build-backend = "builder"
backend-path = ["."]
builder.py
def get_requires_for_build_editable(config_settings=None):
import setuptools
assert 0, f"{setuptools.__version__} {setuptools}"
from setuptools import build_meta as backend
return backend.get_requires_for_build_editable(
config_settings,
)
def prepare_metadata_for_build_editable(
metadata_directory,
config_settings=None,
):
from setuptools import build_meta as backend
return backend.prepare_metadata_for_build_editable(
metadata_directory,
config_settings,
)
def build_editable(
wheel_directory,
config_settings=None,
metadata_directory=None,
):
from setuptools import build_meta as backend
return backend.build_editable(
wheel_directory,
config_settings,
metadata_directory,
)
Note the line assert 0, f"{setuptools.__version__} {setuptools}"
in get_requires_for_build_editable()
!
I need that line to easily show the root of the issue.
Output
Use `pip` to install in editable mode:
$ pip install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/dalcinl/tmp/pip-bug
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... error
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
Traceback (most recent call last):
File "/home/dalcinl/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/home/dalcinl/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/dalcinl/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 144, in get_requires_for_build_editable
return hook(config_settings)
File "/home/dalcinl/tmp/pip-bug/builder.py", line 3, in get_requires_for_build_editable
assert 0, f"{setuptools.__version__} {setuptools}"
AssertionError: 59.6.0 <module 'setuptools' from '/usr/lib/python3.10/site-packages/setuptools/__init__.py'>
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Note the AssertionError
line:
AssertionError: 59.6.0 <module 'setuptools' from '/usr/lib/python3.10/site-packages/setuptools/__init__.py'>
I requested "setuptools >= 64"
in my requirement, but the older system-wide setuptools is being used.
### Code of Conduct
- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).
Issue Analytics
- State:
- Created a year ago
- Comments:18 (11 by maintainers)
It’s not an oversight. Making users explicitly opt in is an intentional choice.
Regardless of what you say, you’re expected to follow the PSF CoC while interacting in this project’s online spaces (and setuptools’). If you violate the CoC in your interactions here at any point, we’ll take action according to the CoC as well. If you have concerns around that, you’re free to not interact with the project. 😃
Consolidating this into https://github.com/pypa/pip/issues/6264.