Bug 1739177: Add requirements.pths_as_absolute() r=ahal

There were a bunch of locations where we were doing path shenanigans
with `requirements.pth/.vendored` items.

There was a bit of complexity because we were specifically making each
`pthfile` line be a relative path to support moving the Firefox
topsrcdir without causing issues.

However, now that we're more intelligent about checking if `pthfile`
lines are up-to-date (and since moving your topsrcdir will still require
re-generating the Mach virtualenv), this behaviour became less useful.

So, generalize `MachEnvRequirements` -> "sys.path lines" logic and
reuse it everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D129693
This commit is contained in:
Mitchell Hentges
2021-11-04 14:35:08 +00:00
parent 1053cdb21d
commit ceb702e5d5
4 changed files with 15 additions and 40 deletions

View File

@@ -260,11 +260,7 @@ def _activate_python_environment(topsrcdir, state_dir):
# (optional) dependencies are not installed.
_scrub_system_site_packages()
sys.path[0:0] = [
os.path.join(topsrcdir, pth.path)
for pth in requirements.pth_requirements
+ requirements.vendored_requirements
]
sys.path[0:0] = requirements.pths_as_absolute(topsrcdir)
elif is_mach_virtualenv:
# We're running in the Mach virtualenv - check that it's up-to-date.
# Note that the "pip package check" exists to ensure that a virtualenv isn't
@@ -284,11 +280,7 @@ def _activate_python_environment(topsrcdir, state_dir):
# Remove global site packages from sys.path to improve isolation accordingly.
_scrub_system_site_packages()
sys.path[0:0] = [
os.path.join(topsrcdir, pth.path)
for pth in requirements.pth_requirements
+ requirements.vendored_requirements
]
sys.path[0:0] = requirements.pths_as_absolute(topsrcdir)
def initialize(topsrcdir):