macOS tests see the wrong path in sys.executable
Categories
(Testing :: Python Test, defect, P2)
Tracking
(firefox72 fixed)
Tracking | Status | |
---|---|---|
firefox72 | --- | fixed |
People
(Reporter: mars, Assigned: mars)
References
Details
Attachments
(1 file)
Tests run on macOS see sys.executable
as /usr/local/bin/python3
even if the testrunner is called with an explicit interpreter, such as the interpreter installed by pipenv or by mach. This forcing of sys.executable
can be observed in the Python 3 unit test suite of any macOS Try run:
/Users/cltbld/tasks/task_1574357108/checkouts/gecko/python/mozbuild/mozpack/test/test_chrome_flags.py
============================= test session starts ==============================
platform darwin -- Python 3.7.4, pytest-3.6.2, py-1.5.4, pluggy-0.6.0 -- /usr/local/bin/python3
On Linux and Windows the test interpreter path appears like this:
/builds/worker/checkouts/gecko/python/mozbuild/mozpack/test/test_chrome_flags.py
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.6.2, py-1.5.4, pluggy-0.6.0 -- /builds/worker/checkouts/gecko/obj-x86_64-pc-linux-gnu/_virtualenvs/gecko-QUm8IANb-3/bin/python
This different path messes with the mozbuild virtualenv handling code because our code tests sys.executable
to see if we are running in a virtualenv. The incorrect virtualenv runtime checks can cause our code to attempt to re-initialize virtualenvs, which triggers more bugs.
The reason for the odd sys.executable
behaviour could be homebrew forcing it's own sys.executable setting using sitecustomize.py. Luckily programs can override this behaviour using the PYTHONEXECUTABLE environment variable.
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
Homebrew on OS X will change Python's sys.executable to a custom value
which messes with mach's virtualenv handling code. Override Homebrew's
changes with the correct sys.executable value.
Pushed by mfogels@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5f74b733f694 Fix sys.executable in the macOS Python tests r=ahal
Comment 3•5 years ago
|
||
bugherder |
Description
•