`sysconfig.get_path` points to venv path when in build-isolation
Description
This is an issue we've found in scikit-build-core ^1 with @henryiii , where we were printing sysconfig.get_path("purelib") from within scikit-build-core scripts, which should be running within the build issolated environment. When running within build-isolation with pip installed in a venv then it points to the venv's site-packages folder. But when I run it indirectly with python3 -m build or using up pip install then it points to the correct build-isolation path only.
Expected behavior
sysconfig.get_path("purelib") should be printing the build-isolated site-packages: e.g. /tmp/build-env-z0u0zzpr/lib/python3.13/site-packages
pip version
24.2
Python version
3.x
OS
Fedora 41
How to Reproduce
Get any project that uses scikit-build-core and then try to build with verbose options to show the debug message:
$ git clone https://github.com/spglib/spglib
$ cd spglib
$ python3 -m venv venv
$ source venv/bin/activate
$ pip -v install . --config-settings=logging.level=DEBUG
$ pip install build uv
$ python3 -m build -v --config-setting=logging.level=DEBUG
$ uv pip -v install . --config-setting=logging.level=DEB
Output
Incorrect output:
2024-09-24 15:45:25,744 - scikit_build_core - DEBUG - SITE_PACKAGES: /home/lecris/CLionProjects/spglib/venv/lib/python3.13/site-packages
2024-09-24 15:45:25,744 - scikit_build_core - DEBUG - Extra SITE_PACKAGES: /tmp/pip-build-env-7al1zz2v/overlay/lib/python3.13/site-packages
2024-09-24 15:45:25,744 - scikit_build_core - DEBUG - PATH: ['/home/lecris/CLionProjects/spglib/venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process', '/tmp/pip-build-env-7al1zz2v/site', '/usr/lib64/python313.zip', '/usr/lib64/python3.13', '/usr/lib64/python3.13/lib-dynload', '/tmp/pip-build-env-7al1zz2v/overlay/lib/python3.13/site-packages', '/tmp/pip-build-env-7al1zz2v/overlay/lib64/python3.13/site-packages', '/tmp/pip-build-env-7al1zz2v/normal/lib/python3.13/site-packages', '/tmp/pip-build-env-7al1zz2v/normal/lib64/python3.13/site-packages', '/tmp/pip-build-env-7al1zz2v/normal/lib/python3.13/site-packages/setuptools/_vendor']
Correct output (slightly altered to print more debug information):
2024-09-24 15:48:39,616 - scikit_build_core - DEBUG - SITE_PACKAGES: /tmp/build-env-z0u0zzpr/lib/python3.13/site-packages
2024-09-24 15:48:39,617 - scikit_build_core - DEBUG - Extra SITE_PACKAGES: /tmp/build-env-z0u0zzpr/lib/python3.13/site-packages
2024-09-24 15:48:39,617 - scikit_build_core - DEBUG - PATH: ['/home/lecris/CLionProjects/spglib/venv/lib/python3.13/site-packages/pyproject_hooks/_in_process', '/usr/lib64/python313.zip', '/usr/lib64/python3.13', '/usr/lib64/python3.13/lib-dynload', '/tmp/build-env-z0u0zzpr/lib64/python3.13/site-packages', '/tmp/build-env-z0u0zzpr/lib/python3.13/site-packages', '/tmp/build-env-z0u0zzpr/lib64/python3.13/site-packages/setuptools/_vendor']
The relevant debug statements there are found at: https://github.com/scikit-build/scikit-build-core/blob/f0ae31922ff802b179fce3327a9c93ff65934a23/src/scikit_build_core/builder/builder.py#L150-L157
Code of Conduct
- [X] I agree to follow the PSF Code of Conduct.