From 78827b7e2c3b06f64cc4f5d3bc2a369b6f9b463e Mon Sep 17 00:00:00 2001 From: Mitchell Hentges Date: Fri, 3 Sep 2021 17:06:05 +0000 Subject: [PATCH] Bug 1723237: Use pip-compile directly from vendored location r=ahal We've been installing `piptools` so that we can use the `pip-compile` binary. However, we can just as easily do `python -m piptools compile ...` instead, which also allows us to skip a redundant install. Differential Revision: https://phabricator.services.mozilla.com/D123240 --- build/common_virtualenv_packages.txt | 1 + python/mozbuild/mozbuild/test/test_vendor.py | 5 +++-- python/mozbuild/mozbuild/vendor/vendor_python.py | 12 ++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build/common_virtualenv_packages.txt b/build/common_virtualenv_packages.txt index e60ee282f45f..6401d3311f07 100644 --- a/build/common_virtualenv_packages.txt +++ b/build/common_virtualenv_packages.txt @@ -86,6 +86,7 @@ pth:third_party/python/more_itertools pth:third_party/python/mozilla_version pth:third_party/python/pathspec pth:third_party/python/pep487/lib +pth:third_party/python/pip_tools pth:third_party/python/pluggy pth:third_party/python/ply pth:third_party/python/py diff --git a/python/mozbuild/mozbuild/test/test_vendor.py b/python/mozbuild/mozbuild/test/test_vendor.py index 58c87c07ebc0..33bc920fc928 100644 --- a/python/mozbuild/mozbuild/test/test_vendor.py +++ b/python/mozbuild/mozbuild/test/test_vendor.py @@ -28,8 +28,9 @@ def test_up_to_date_vendor(): # Since VendorPython thinks "work_dir" is the topsrcdir, # it will use its associated virtualenv and package configuration. # Since it uses "pip-tools" within, and "pip-tools" needs - # the "Click" library, we need to make it available. - file.write("pth:third_party/python/Click") + # the "Click" library, we need to make them available. + file.write("pth:third_party/python/Click\n") + file.write("pth:third_party/python/pip_tools\n") # Copy existing "third_party/python/" vendored files existing_vendored = os.path.join(topsrcdir, "third_party", "python") diff --git a/python/mozbuild/mozbuild/vendor/vendor_python.py b/python/mozbuild/mozbuild/vendor/vendor_python.py index a661fb11c992..f730baf34948 100644 --- a/python/mozbuild/mozbuild/vendor/vendor_python.py +++ b/python/mozbuild/mozbuild/vendor/vendor_python.py @@ -21,14 +21,7 @@ class VendorPython(MozbuildObject): self.log_manager.enable_unstructured() vendor_dir = mozpath.join(self.topsrcdir, os.path.join("third_party", "python")) - self.activate_virtualenv() - pip_compile = os.path.join(self.virtualenv_manager.bin_path, "pip-compile") - if not os.path.exists(pip_compile): - path = os.path.normpath( - os.path.join(self.topsrcdir, "third_party", "python", "pip_tools") - ) - self.virtualenv_manager.install_pip_package(path, vendored=True) spec = os.path.join(vendor_dir, "requirements.in") requirements = os.path.join(vendor_dir, "requirements.txt") @@ -41,7 +34,10 @@ class VendorPython(MozbuildObject): # resolve the dependencies and update requirements.txt subprocess.check_output( [ - pip_compile, + self.virtualenv_manager.python_path, + "-m", + "piptools", + "compile", tmpspec, "--no-header", "--no-index",