Bug 1724274: Simplify VirtualenvManager r=ahal

* Removes the unused `call_setup()` function
* Inlines functions that were internally called only once

Differential Revision: https://phabricator.services.mozilla.com/D124518
This commit is contained in:
Mitchell Hentges 2021-09-13 15:42:55 +00:00
Родитель 8b3f48d166
Коммит 6fc2ae861b
1 изменённых файлов: 3 добавлений и 41 удалений

Просмотреть файл

@ -146,13 +146,6 @@ class VirtualenvManager(VirtualenvHelper):
os.path.join(self.virtualenv_root, METADATA_FILENAME), os.path.join(self.virtualenv_root, METADATA_FILENAME),
) )
@property
def virtualenv_script_path(self):
"""Path to virtualenv's own populator script."""
return os.path.join(
self.topsrcdir, "third_party", "python", "virtualenv", "virtualenv.py"
)
def version_info(self): def version_info(self):
return eval( return eval(
subprocess.check_output( subprocess.check_output(
@ -292,7 +285,9 @@ class VirtualenvManager(VirtualenvHelper):
args = [ args = [
self._base_python, self._base_python,
self.virtualenv_script_path, os.path.join(
self.topsrcdir, "third_party", "python", "virtualenv", "virtualenv.py"
),
# Without this, virtualenv.py may attempt to contact the outside # Without this, virtualenv.py may attempt to contact the outside
# world and search for or download a newer version of pip, # world and search for or download a newer version of pip,
# setuptools, or wheel. This is bad for security, reproducibility, # setuptools, or wheel. This is bad for security, reproducibility,
@ -392,39 +387,6 @@ class VirtualenvManager(VirtualenvHelper):
finally: finally:
os.environ.update(old_env_variables) os.environ.update(old_env_variables)
def call_setup(self, directory, arguments):
"""Calls setup.py in a directory."""
setup = os.path.join(directory, "setup.py")
program = [self.python_path, setup]
program.extend(arguments)
# We probably could call the contents of this file inside the context
# of this interpreter using execfile() or similar. However, if global
# variables like sys.path are adjusted, this could cause all kinds of
# havoc. While this may work, invoking a new process is safer.
try:
env = os.environ.copy()
env.setdefault("ARCHFLAGS", get_archflags())
output = subprocess.check_output(
program,
cwd=directory,
env=env,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
print(output)
except subprocess.CalledProcessError as e:
if "Python.h: No such file or directory" in e.output:
print(
"WARNING: Python.h not found. Install Python development headers."
)
else:
print(e.output)
raise Exception("Error installing package: %s" % directory)
def build(self): def build(self):
"""Build a virtualenv per tree conventions. """Build a virtualenv per tree conventions.