mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
37a1a70a52
This patch resolves cases like the following: 1. The system Python has `zstandard`. 2. `MOZ_AUTOMATION=1 ./mach python --virtualenv psutil <script>` is run, adding `psutil` to the import scope. 3. `<script>` runs Mach a _second_ time, and this time Mach needs to be able to import `zstandard` (in this case, it should be able to fetch it from the system Python's site-packages). The previous behaviour would add the "site-packages" of the //invoking// Python interpreter, but ancestor packages would get dropped. To rectify this issue, this patch changes "import inheritance" to keep more of the `sys.path`, rather than just `<external-python>.all_site_packages_dirs()`. Note: the original implementation of this patch passed forward *all* of the `sys.path` when creating virtualenvs. However, this caused issues when Mach ran `pip`, because `pip` was no longer able to discover the "standard library" (it was failing because it assumed all paths defined in a virtualenv's site were non-standard-library paths, and the original implementation broke that assumption). As part of this, a distinction was defined between the "current" Python interpreter (external_python) and the top-level Python interpreter (original_python). This was needed to enable discovering which paths are "standard library paths". Differential Revision: https://phabricator.services.mozilla.com/D134201 |
||
---|---|---|
.. | ||
mach_commands.py |