parameters: (self)
docstring: 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:
              1. relative path directory containing setup.py.
              2. argument(s) to setup.py. e.g. "develop". Each program argument
                 is delimited by a colon. Arguments with colons are not yet
                 supported.
  
          filename.pth -- Adds the path given as argument to filename.pth under
              the virtualenv site packages directory.
  
          optional -- This denotes the action as optional. The requested action
              is attempted. If it fails, we issue a warning and go on. The
              initial "optional" field is stripped then the remaining line is
              processed like normal. e.g.
              "optional:setup.py:python/foo:built_ext:-i"
  
          copy -- Copies the given file in the virtualenv site packages
              directory.
  
          packages.txt -- Denotes that the specified path is a child manifest. It
              will be read and processed as if its contents were concatenated
              into the manifest being read.
  
          objdir -- Denotes a relative path in the object directory to add to the
              search path. e.g. "objdir:build" will add $topobjdir/build to the
              search path.
  
          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.
docstring_summary: Populate the virtualenv.
docstring_tokens: Populate the virtualenv .
function: 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:
              1. relative path directory containing setup.py.
              2. argument(s) to setup.py. e.g. "develop". Each program argument
                 is delimited by a colon. Arguments with colons are not yet
                 supported.
  
          filename.pth -- Adds the path given as argument to filename.pth under
              the virtualenv site packages directory.
  
          optional -- This denotes the action as optional. The requested action
              is attempted. If it fails, we issue a warning and go on. The
              initial "optional" field is stripped then the remaining line is
              processed like normal. e.g.
              "optional:setup.py:python/foo:built_ext:-i"
  
          copy -- Copies the given file in the virtualenv site packages
              directory.
  
          packages.txt -- Denotes that the specified path is a child manifest. It
              will be read and processed as if its contents were concatenated
              into the manifest being read.
  
          objdir -- Denotes a relative path in the object directory to add to the
              search path. e.g. "objdir:build" will add $topobjdir/build to the
              search path.
  
          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()
  
          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:])
  
                  return True
  
              if package[0] == 'copy':
                  assert len(package) == 2
  
                  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.topobjdir,
                                                 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:
                      # This path is relative to the .pth file.  Using a
                      # relative path allows the srcdir/objdir combination
                      # to be moved around (as long as the paths relative to
                      # each other remain the same).
                      try:
                          f.write("%s\n" % os.path.relpath(path, python_lib))
                      except ValueError:
                          # When objdir is on a separate drive, relpath throws
                          f.write("%s\n" % os.path.join(python_lib, path))
  
                  return True
  
              if package[0] == 'optional':
                  try:
                      handle_package(package[1:])
                      return True
                  except:
                      print('Error processing command. Ignoring', \
                          'because optional. (%s)' % ':'.join(package),
                          file=self.log_handle)
                      return False
  
              if package[0] == 'objdir':
                  assert len(package) == 2
                  path = os.path.join(self.topobjdir, package[1])
  
                  with open(os.path.join(python_lib, 'objdir.pth'), 'a') as f:
                      f.write('%s\n' % path)
  
                  return True
  
              raise Exception('Unknown action: %s' % package[0])
  
          # We always target the OS X deployment target that Python itself was
          # built with, regardless of what's in the current environment. If we
          # don't do # this, we may run into a Python bug. See
          # http://bugs.python.org/issue9516 and bug 659881.
          #
          # Note that this assumes that nothing compiled in the virtualenv is
          # shipped as part of a distribution. If we do ship anything, the
          # deployment target here may be different from what's targeted by the
          # shipping binaries and # virtualenv-produced binaries may fail to
          # work.
          #
          # We also ignore environment variables that may have been altered by
          # configure or a mozconfig activated in the current shell. We trust
          # Python is smart enough to find a proper compiler and to use the
          # proper compiler flags. If it isn't your Python is likely broken.
          IGNORE_ENV_VARIABLES = ('CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS',
              'PYTHONDONTWRITEBYTECODE')
  
          try:
              old_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None)
              sysconfig_target = \
                  distutils.sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
  
              if sysconfig_target is not None:
                  os.environ['MACOSX_DEPLOYMENT_TARGET'] = sysconfig_target
  
              old_env_variables = {}
              for k in IGNORE_ENV_VARIABLES:
                  if k not in os.environ:
                      continue
  
                  old_env_variables[k] = os.environ[k]
                  del os.environ[k]
  
              # HACK ALERT.
              #
              # The following adjustment to the VSNNCOMNTOOLS environment
              # variables are wrong. This is done as a hack to facilitate the
              # building of binary Python packages - notably psutil - on Windows
              # machines that don't have the Visual Studio 2008 binaries
              # installed. This hack assumes the Python on that system was built
              # with Visual Studio 2008. The hack is wrong for the reasons
              # explained at
              # http://stackoverflow.com/questions/3047542/building-lxml-for-python-2-7-on-windows/5122521#5122521.
              if sys.platform in ('win32', 'cygwin') and \
                  'VS90COMNTOOLS' not in os.environ:
  
                  warnings.warn('Hacking environment to allow binary Python '
                      'extensions to build. You can make this warning go away '
                      'by installing Visual Studio 2008. You can download the '
                      'Express Edition installer from '
                      'http://go.microsoft.com/?linkid=7729279')
  
                  # We list in order from oldest to newest to prefer the closest
                  # to 2008 so differences are minimized.
                  for ver in ('100', '110', '120'):
                      var = 'VS%sCOMNTOOLS' % ver
                      if var in os.environ:
                          os.environ['VS90COMNTOOLS'] = os.environ[var]
                          break
  
              for package in packages:
                  handle_package(package)
          finally:
              os.environ.pop('MACOSX_DEPLOYMENT_TARGET', None)
  
              if old_target is not None:
                  os.environ['MACOSX_DEPLOYMENT_TARGET'] = old_target
  
              os.environ.update(old_env_variables)
function_tokens: def populate ( self ) : packages = self . packages ( ) 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 : ] ) return True if package [ 0 ] == 'copy' : assert len ( package ) == 2 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 . topobjdir , 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 : # This path is relative to the .pth file.  Using a # relative path allows the srcdir/objdir combination # to be moved around (as long as the paths relative to # each other remain the same). try : f . write ( "%s\n" % os . path . relpath ( path , python_lib ) ) except ValueError : # When objdir is on a separate drive, relpath throws f . write ( "%s\n" % os . path . join ( python_lib , path ) ) return True if package [ 0 ] == 'optional' : try : handle_package ( package [ 1 : ] ) return True except : print ( 'Error processing command. Ignoring' , 'because optional. (%s)' % ':' . join ( package ) , file = self . log_handle ) return False if package [ 0 ] == 'objdir' : assert len ( package ) == 2 path = os . path . join ( self . topobjdir , package [ 1 ] ) with open ( os . path . join ( python_lib , 'objdir.pth' ) , 'a' ) as f : f . write ( '%s\n' % path ) return True raise Exception ( 'Unknown action: %s' % package [ 0 ] ) # We always target the OS X deployment target that Python itself was # built with, regardless of what's in the current environment. If we # don't do # this, we may run into a Python bug. See # http://bugs.python.org/issue9516 and bug 659881. # # Note that this assumes that nothing compiled in the virtualenv is # shipped as part of a distribution. If we do ship anything, the # deployment target here may be different from what's targeted by the # shipping binaries and # virtualenv-produced binaries may fail to # work. # # We also ignore environment variables that may have been altered by # configure or a mozconfig activated in the current shell. We trust # Python is smart enough to find a proper compiler and to use the # proper compiler flags. If it isn't your Python is likely broken. IGNORE_ENV_VARIABLES = ( 'CC' , 'CXX' , 'CFLAGS' , 'CXXFLAGS' , 'LDFLAGS' , 'PYTHONDONTWRITEBYTECODE' ) try : old_target = os . environ . get ( 'MACOSX_DEPLOYMENT_TARGET' , None ) sysconfig_target = distutils . sysconfig . get_config_var ( 'MACOSX_DEPLOYMENT_TARGET' ) if sysconfig_target is not None : os . environ [ 'MACOSX_DEPLOYMENT_TARGET' ] = sysconfig_target old_env_variables = { } for k in IGNORE_ENV_VARIABLES : if k not in os . environ : continue old_env_variables [ k ] = os . environ [ k ] del os . environ [ k ] # HACK ALERT. # # The following adjustment to the VSNNCOMNTOOLS environment # variables are wrong. This is done as a hack to facilitate the # building of binary Python packages - notably psutil - on Windows # machines that don't have the Visual Studio 2008 binaries # installed. This hack assumes the Python on that system was built # with Visual Studio 2008. The hack is wrong for the reasons # explained at # http://stackoverflow.com/questions/3047542/building-lxml-for-python-2-7-on-windows/5122521#5122521. if sys . platform in ( 'win32' , 'cygwin' ) and 'VS90COMNTOOLS' not in os . environ : warnings . warn ( 'Hacking environment to allow binary Python ' 'extensions to build. You can make this warning go away ' 'by installing Visual Studio 2008. You can download the ' 'Express Edition installer from ' 'http://go.microsoft.com/?linkid=7729279' ) # We list in order from oldest to newest to prefer the closest # to 2008 so differences are minimized. for ver in ( '100' , '110' , '120' ) : var = 'VS%sCOMNTOOLS' % ver if var in os . environ : os . environ [ 'VS90COMNTOOLS' ] = os . environ [ var ] break for package in packages : handle_package ( package ) finally : os . environ . pop ( 'MACOSX_DEPLOYMENT_TARGET' , None ) if old_target is not None : os . environ [ 'MACOSX_DEPLOYMENT_TARGET' ] = old_target os . environ . update ( old_env_variables )