Comments (14)
Can you not use the Python -S
flag to prevent the import of the site
module, which will prevent the parsing of pyvenv.cfg
? You can then manipulate PYTHONPATH
normally, by breaking out of the virtual environment. Although not importing site
might have other implications that I'm not aware of.
from build.
You mean PEP 405 was a breaking change? When PEPs propose a change Python semantics, they're never implemented in minor versions. Looks like PEP 405 was introduced in Python 3.3 (Python does not use semver — backwards-incompatible changes are allowed in point releases like 3.2 → 3.3).
Yes, but AFAIK you don't change behaviors, you deprecate stuff and remove them, but I might be wrong. Changing how something behaves is very problematic.
In this case, I see absolutely no reason for pyvenv.cfg
to be the first step of the search.
This is a somewhat vague description of the problem. I don't really understand the isolation / environment code well enough to understand why this would be a problem. From what I can tell,
PYTHONHOME
refers to the location of the standard library, but the problem we're having is not from the standard library, it's from site-packages. I'll note that it's entirely possible to prevent access to these by removing the relevant directories fromsys.path
(though I'm not sure if it's possible to do that with environment variables).
Okay, this is the issue:
(on /usr/bin/python
, no pyvenv.cfg
is found)
$ PYTHONHOME=/tmp/build-env-kit8jz7e PYTHONPATH=/usr/lib/python38.zip:/usr/lib/python3.8:/usr/lib/python3.8/lib-dynload:/usr/lib/python3.8/site-packages:/tmp/build-env-kit8jz7e/lib/python3.8/site-packages:/tmp/build-env-kit8jz7e/lib/python3.8/site-packages /usr/bin/python -m sysconfig | head -n 15
Platform: "linux-x86_64"
Python version: "3.8"
Current installation scheme: "posix_prefix"
Paths:
data = "/tmp/build-env-kit8jz7e"
include = "/tmp/build-env-kit8jz7e/include/python3.8"
platinclude = "/tmp/build-env-kit8jz7e/include/python3.8"
platlib = "/tmp/build-env-kit8jz7e/lib/python3.8/site-packages"
platstdlib = "/tmp/build-env-kit8jz7e/lib/python3.8"
purelib = "/tmp/build-env-kit8jz7e/lib/python3.8/site-packages"
scripts = "/tmp/build-env-kit8jz7e/bin"
stdlib = "/tmp/build-env-kit8jz7e/lib/python3.8"
(on a virtual environment, pyvenv.cfg
is found)
$ PYTHONHOME=/tmp/build-env-kit8jz7e PYTHONPATH=/usr/lib/python38.zip:/usr/lib/python3.8:/usr/lib/python3.8/
lib-dynload:/usr/lib/python3.8/site-packages:/tmp/build-env-kit8jz7e/lib/python3.8/site-packages:/tmp/build-env-kit8jz7e/lib/python3.8/site-packages ~/.virtualenvs/test-env/bin/python -m sysconfig | head -n 15
Platform: "linux-x86_64"
Python version: "3.8"
Current installation scheme: "posix_prefix"
Paths:
data = "/home/anubis/.virtualenvs/test-env"
include = "/tmp/build-env-kit8jz7e/include/python3.8"
platinclude = "/tmp/build-env-kit8jz7e/include/python3.8"
platlib = "/home/anubis/.virtualenvs/test-env/lib/python3.8/site-packages"
platstdlib = "/home/anubis/.virtualenvs/test-env/lib/python3.8"
purelib = "/home/anubis/.virtualenvs/test-env/lib/python3.8/site-packages"
scripts = "/home/anubis/.virtualenvs/test-env/bin"
stdlib = "/tmp/build-env-kit8jz7e/lib/python3.8"
So, if pyvenv.cfg
is present, even if I provide a PYTHONHOME
, which should relocate the Python installation to other path, the paths gets overridden. PYTHONHOME
should override the prefix, but for some reason pyvenv.cfg
gets precedence, making PYTHONHOME
useless.
With PEP 405, the Python interpreter is not self-contained, it depends on external environment variables we might not control. I chose PYTHONHOME
because it did not require us to run a different interpreter, but it turns out it does. I think PEP 405, which was motivated by the lack of symlink support in Windows, in its attempt to make things better killed this use case, I wish just a little bit of more thought had been put into it.
from build.
Hum, I am pretty sure I was passing --ignore-installed
to pip, maybe that got removed in one of the reviews. Can you check if it fixes your issue?
from build.
Hum, I am pretty sure I was passing
--ignore-installed
to pip, maybe that got removed in one of the reviews. Can you check if it fixes your issue?
That would only partially fix the issue — pip
probably shouldn't need --ignore-installed
because it shouldn't be seeing any packages installed in the isolated environment when it's invoked. It probably would solve the issue of the default upgrading behavior, but it won't solve the other issue I mentioned, which is that packages installed in the outer environment are visible in the isolated environment (see the example about dateutil
in my earlier post here).
from build.
I will keep this short, otherwise I will rant about this. It happens because of the presence of pyvenv.cfg
which overrides the PYTHONHOME
behavior.
from build.
Opened pypa/pyproject-hooks#92 which is required to fix this issue.
from build.
Keeping it short. IMO PYTHONHOME
should override pyvenv.cfg
. PEP 405 tried to improve things by introducing pyvenv.cfg
but it made PYTHONHOME
unreliable. I would actually call this a breaking change, it should have never happened between minor versions. I am very bummed out from finding out about this.
from build.
I would actually call this a breaking change, it should have never happened between minor versions.
You mean PEP 405 was a breaking change? When PEPs propose a change Python semantics, they're never implemented in minor versions. Looks like PEP 405 was introduced in Python 3.3 (Python does not use semver — backwards-incompatible changes are allowed in point releases like 3.2 → 3.3).
Keeping it short. IMO
PYTHONHOME
should overridepyvenv.cfg
. PEP 405 tried to improve things by introducingpyvenv.cfg
but it madePYTHONHOME
unreliable.
This is a somewhat vague description of the problem. I don't really understand the isolation / environment code well enough to understand why this would be a problem. From what I can tell, PYTHONHOME
refers to the location of the standard library, but the problem we're having is not from the standard library, it's from site-packages. I'll note that it's entirely possible to prevent access to these by removing the relevant directories from sys.path
(though I'm not sure if it's possible to do that with environment variables).
Opened pypa/pep517#92 which is required to fix this issue.
One possible (very hacky) workaround in the meantime might be to monkey-patch sys.executable
during the run in versions of pep517
that don't support using a custom executable.
from build.
Interesting, I wonder if it's worth tweaking the documentation to make it more clear that PYTHONHOME
/ pyvenv.cfg
's home
value is setting the base path for a whole bunch of stuff, not just the standard library. Maybe that's more obvious to people familiar with the way all those other paths are derived?
from build.
That does work, yes.
Paths:
data = "/tmp/build-env-65qowjyv"
include = "/tmp/build-env-65qowjyv/include/python3.8"
platinclude = "/tmp/build-env-65qowjyv/include/python3.8"
platlib = "/tmp/build-env-65qowjyv/lib/python3.8/site-packages"
platstdlib = "/tmp/build-env-65qowjyv/lib/python3.8"
purelib = "/tmp/build-env-65qowjyv/lib/python3.8/site-packages"
scripts = "/tmp/build-env-65qowjyv/bin"
stdlib = "/tmp/build-env-65qowjyv/lib/python3.8"
from build.
@pganssle can you confirm that the current master fixes the issue for you?
from build.
Ping. Should this be closed now?
from build.
I think so.
from build.
Okay, we can reopen if needed.
from build.
Related Issues (20)
- ModuleNotFoundError: No module named 'wheel' HOT 3
- Terminal size error with 1.2.0 HOT 2
- Add `--jobs` option to `build` HOT 5
- types in release 1.2.1 exclude "editable"
- Different behavior between pyproject-build and pyproject-build -w HOT 1
- `build` compiles multiple times HOT 12
- Behaviour change on hyphen in package names with build 1.2.x? HOT 1
- I would appreciate a less verbose build option HOT 4
- getting error FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-bs6licvb-build/setup.py' HOT 5
- How to specify packages in pyproject.toml - build fails HOT 4
- Add Github action HOT 4
- [Need Help😢] Import path issues after linking declarative lib files
- Print artifact digest after build process is completed HOT 6
- Document support for build_editable HOT 1
- setup.py downloads missing from 1.1.0+ HOT 10
- python3 -m pip install package-name
- multiple definitions for std:label:python--m-build--v HOT 9
- `build --sdist` propagating `egg.info/SOURCES.txt` despite being excluded via `MANIFEST.in` HOT 2
- Can't install with conda ? HOT 2
- Misfeature: universal wheel filename has "-py2.py3" even with `requires-python=">=3"` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from build.