From 9737b2375e94be0aaad346b2468c3f60743fdb7d Mon Sep 17 00:00:00 2001 From: Aidan Hobson Sayers Date: Mon, 14 Sep 2015 20:45:48 +0100 Subject: [PATCH 1/2] Create a marker file to avoid running pip when possible --- python/mach_bootstrap.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py index 19b1ad666e8..d32b6f8be45 100644 --- a/python/mach_bootstrap.py +++ b/python/mach_bootstrap.py @@ -96,12 +96,21 @@ def _activate_virtualenv(topdir): # chain each of the requirements files into the same `pip install` call # and it will check for conflicts. requirements_paths = [ - os.path.join(topdir, "python", "requirements.txt"), - os.path.join(topdir, "tests", "wpt", "harness", "requirements.txt"), - os.path.join(topdir, "tests", "wpt", "harness", "requirements_servo.txt"), + os.path.join("python", "requirements.txt"), + os.path.join("tests", "wpt", "harness", "requirements.txt"), + os.path.join("tests", "wpt", "harness", "requirements_servo.txt"), ] - for path in requirements_paths: - subprocess.check_call(["pip", "install", "-q", "-r", path]) + for req_rel_path in requirements_paths: + req_path = os.path.join(topdir, req_rel_path) + marker_file = req_rel_path.replace(os.path.sep, '-') + marker_path = os.path.join(virtualenv_path, marker_file) + try: + if os.path.getmtime(req_path) + 10 < os.path.getmtime(marker_path): + continue + except OSError: + open(marker_path, 'w').close() + subprocess.check_call(["pip", "install", "-q", "-r", req_path]) + os.utime(marker_path, None) def bootstrap(topdir): From 078d21b6e2575b622c3f3dd2c17e18f2d46629cc Mon Sep 17 00:00:00 2001 From: Aidan Hobson Sayers Date: Mon, 14 Sep 2015 20:46:11 +0100 Subject: [PATCH 2/2] Minor style tweak --- mach | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mach b/mach index e1a5c940a82..9d42641fa2a 100755 --- a/mach +++ b/mach @@ -16,7 +16,7 @@ import sys def main(args): topdir = os.path.dirname(sys.argv[0]) - sys.path[0:0] = [os.path.join(topdir, "python")] + sys.path.insert(0, os.path.join(topdir, "python")) import mach_bootstrap mach = mach_bootstrap.bootstrap(topdir) sys.exit(mach.run(sys.argv[1:]))