author | Gregory Szorc <gps@mozilla.com> |
Thu, 24 Jan 2013 19:13:30 -0800 | |
changeset 119809 | a207f33adc1a12ef7e83183d557a34dcac7a8f01 |
parent 119808 | 30fcaabe235aaa83b4e4426acef1ff467ed4b9b4 |
child 119810 | 52c92a6c6e24bbf1007955092121d2606797f551 |
child 119848 | 0b4168438bd72b05a93438585a397130b6d94a37 |
child 127198 | 1cc0768e68c499567bcda62144a04c18f41f2d53 |
push id | 24227 |
push user | gszorc@mozilla.com |
push date | Fri, 25 Jan 2013 03:14:41 +0000 |
treeherder | mozilla-central@a207f33adc1a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 830996 |
milestone | 21.0a1 |
backs out | c779b2ab7695655a1c8db3a17e8712d584a001b5 |
first release with | nightly linux32
a207f33adc1a
/
21.0a1
/
20130125031018
/
files
nightly linux64
a207f33adc1a
/
21.0a1
/
20130125031018
/
files
nightly mac
a207f33adc1a
/
21.0a1
/
20130125031018
/
files
nightly win32
a207f33adc1a
/
21.0a1
/
20130125031018
/
files
nightly win64
a207f33adc1a
/
21.0a1
/
20130125031018
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
21.0a1
/
20130125031018
/
pushlog to previous
nightly linux64
21.0a1
/
20130125031018
/
pushlog to previous
nightly mac
21.0a1
/
20130125031018
/
pushlog to previous
nightly win32
21.0a1
/
20130125031018
/
pushlog to previous
nightly win64
21.0a1
/
20130125031018
/
pushlog to previous
|
build/virtualenv/packages.txt | file | annotate | diff | comparison | revisions | |
build/virtualenv/populate_virtualenv.py | file | annotate | diff | comparison | revisions |
--- a/build/virtualenv/packages.txt +++ b/build/virtualenv/packages.txt @@ -1,15 +1,25 @@ simplejson.pth:python/simplejson-2.1.1 +manifestdestiny.pth:testing/mozbase/manifestdestiny +mozcrash.pth:testing/mozbase/mozcrash +mozdevice.pth:testing/mozbase/mozdevice +mozfile.pth:testing/mozbase/mozfile +mozhttpd.pth:testing/mozbase/mozhttpd +mozinfo.pth:testing/mozbase/mozinfo +mozinstall.pth:testing/mozbase/mozinstall +mozlog.pth:testing/mozbase/mozlog +mozprocess.pth:testing/mozbase/mozprocess +mozprofile.pth:testing/mozbase/mozprofile +mozrunner.pth:testing/mozbase/mozrunner marionette.pth:testing/marionette/client blessings.pth:python/blessings mach.pth:python/mach mozbuild.pth:python/mozbuild pymake.pth:build/pymake optional:setup.py:python/psutil:build_ext:--inplace optional:psutil.pth:python/psutil which.pth:python/which mock.pth:python/mock-1.0.0 mozilla.pth:build mozilla.pth:config mozilla.pth:xpcom/typelib/xpt/tools copy:build/buildconfig.py -packages.txt:testing/mozbase/packages.txt
--- a/build/virtualenv/populate_virtualenv.py +++ b/build/virtualenv/populate_virtualenv.py @@ -17,118 +17,100 @@ import sys # Minimum version of Python required to build. MINIMUM_PYTHON_MAJOR = 2 MINIMUM_PYTHON_MINOR = 7 class VirtualenvManager(object): """Contains logic for managing virtualenvs for building the tree.""" - def __init__(self, topsrcdir, virtualenv_path, log_handle, manifest_path): + def __init__(self, topsrcdir, virtualenv_path, log_handle): """Create a new manager. Each manager is associated with a source directory, a path where you want the virtualenv to be created, and a handle to write output to. """ self.topsrcdir = topsrcdir self.virtualenv_root = virtualenv_path self.log_handle = log_handle - self.manifest_path = manifest_path @property def virtualenv_script_path(self): """Path to virtualenv's own populator script.""" return os.path.join(self.topsrcdir, 'python', 'virtualenv', 'virtualenv.py') @property + def manifest_path(self): + return os.path.join(self.topsrcdir, 'build', 'virtualenv', + 'packages.txt') + + @property def python_path(self): if sys.platform in ('win32', 'cygwin'): return os.path.join(self.virtualenv_root, 'Scripts', 'python.exe') return os.path.join(self.virtualenv_root, 'bin', 'python') @property def activate_path(self): if sys.platform in ('win32', 'cygwin'): return os.path.join(self.virtualenv_root, 'Scripts', 'activate_this.py') return os.path.join(self.virtualenv_root, 'bin', 'activate_this.py') - def up_to_date(self): - """Returns whether the virtualenv is present and up to date.""" - - deps = [self.manifest_path, __file__] - - # check if virtualenv exists - if not os.path.exists(self.virtualenv_root) or \ - not os.path.exists(self.activate_path): - - return False - - # check modification times - activate_mtime = os.path.getmtime(self.activate_path) - dep_mtime = max(os.path.getmtime(p) for p in deps) - if dep_mtime > activate_mtime: - return False - - # recursively check sub packages.txt files - submanifests = [i for i in self.packages() - if i[0] == 'packages.txt'] - for submanifest in submanifests: - submanager = VirtualenvManager(self.topsrcdir, - self.virtualenv_root, - self.log_handle, - src) - if not submanager.up_to_date(): - return False - - return True - def ensure(self): """Ensure the virtualenv is present and up to date. If the virtualenv is up to date, this does nothing. Otherwise, it creates and populates the virtualenv as necessary. This should be the main API used from this class as it is the highest-level. """ - if self.up_to_date(): - return self.virtualenv_root - return self.build() + deps = [self.manifest_path, __file__] + + if not os.path.exists(self.virtualenv_root) or \ + not os.path.exists(self.activate_path): + + return self.build() + + activate_mtime = os.path.getmtime(self.activate_path) + dep_mtime = max(os.path.getmtime(p) for p in deps) + + if dep_mtime > activate_mtime: + return self.build() + + return self.virtualenv_root def create(self): """Create a new, empty virtualenv. Receives the path to virtualenv's virtualenv.py script (which will be called out to), the path to create the virtualenv in, and a handle to write output to. """ env = dict(os.environ) - env.pop('PYTHONDONTWRITEBYTECODE', None) + try: + del env['PYTHONDONTWRITEBYTECODE'] + except KeyError: + pass args = [sys.executable, self.virtualenv_script_path, '--system-site-packages', self.virtualenv_root] result = subprocess.call(args, stdout=self.log_handle, stderr=subprocess.STDOUT, env=env) - if result: + if result != 0: raise Exception('Error creating virtualenv.') return self.virtualenv_root - def packages(self): - with file(self.manifest_path, 'rU') as fh: - packages = [line.rstrip().split(':') - for line in fh] - return packages - def populate(self): """Populate the virtualenv. The manifest file consists of colon-delimited fields. The first field specifies the action. The remaining fields are arguments to that action. The following actions are supported: setup.py -- Invoke setup.py for a package. Expects the arguments: @@ -149,18 +131,21 @@ class VirtualenvManager(object): copy -- Copies the given file in the virtualenv site packages directory. Note that the Python interpreter running this function should be the one from the virtualenv. If it is the system Python or if the environment is not configured properly, packages could be installed into the wrong place. This is how virtualenv's work. """ - - packages = self.packages() + packages = [] + fh = open(self.manifest_path, 'rU') + for line in fh: + packages.append(line.rstrip().split(':')) + fh.close() def handle_package(package): python_lib = distutils.sysconfig.get_python_lib() if package[0] == 'setup.py': assert len(package) >= 2 self.call_setup(os.path.join(self.topsrcdir, package[1]), package[2:]) @@ -172,29 +157,16 @@ class VirtualenvManager(object): src = os.path.join(self.topsrcdir, package[1]) dst = os.path.join(python_lib, os.path.basename(package[1])) shutil.copy(src, dst) return True - if package[0] == 'packages.txt': - assert len(package) == 2 - - src = os.path.join(self.topsrcdir, package[1]) - assert os.path.isfile(src), "'%s' does not exist" % src - submanager = VirtualenvManager(self.topsrcdir, - self.virtualenv_root, - self.log_handle, - src) - submanager.populate() - - return True - if package[0].endswith('.pth'): assert len(package) == 2 path = os.path.join(self.topsrcdir, package[1]) with open(os.path.join(python_lib, package[0]), 'a') as f: f.write("%s\n" % path) @@ -244,22 +216,27 @@ class VirtualenvManager(object): continue old_env_variables[k] = os.environ[k] del os.environ[k] for package in packages: handle_package(package) finally: - os.environ.pop('MACOSX_DEPLOYMENT_TARGET', None) + try: + del os.environ['MACOSX_DEPLOYMENT_TARGET'] + except KeyError: + pass if old_target is not None: os.environ['MACOSX_DEPLOYMENT_TARGET'] = old_target - os.environ.update(old_env_variables) + for k in old_env_variables: + os.environ[k] = old_env_variables[k] + def call_setup(self, directory, arguments): """Calls setup.py in a directory.""" setup = os.path.join(directory, 'setup.py') program = [sys.executable, setup] program.extend(arguments) @@ -338,18 +315,15 @@ if __name__ == '__main__': populate = False # This should only be called internally. if sys.argv[1] == 'populate': populate = True topsrcdir = sys.argv[2] virtualenv_path = sys.argv[3] - # path to default packages.txt - manifest_path = os.path.join(topsrcdir, 'build', 'virtualenv', 'packages.txt') - - manager = VirtualenvManager(topsrcdir, virtualenv_path, sys.stdout, manifest_path) + manager = VirtualenvManager(topsrcdir, virtualenv_path, sys.stdout) if populate: manager.populate() else: manager.ensure()