Beispiel #1
0
  def _dump_built_library(self, library, builder):
    absolute_sources = library.expand_files()
    absolute_sources.sort()
    cache_key = self._cache.key_for(library._create_id(), absolute_sources)
    if not self._cache.needs_update(cache_key):
      print '  Generating (cached) %s...' % library
      self._cache.use_cached_files(cache_key, self.env.add_dependency_file)
    else:
      print '  Generating %s...' % library
      egg_file = builder.build_egg()

      if egg_file:
        src_egg_file = egg_file
        dst_egg_file = os.path.join(os.path.dirname(egg_file),
            cache_key.hash + '_' + os.path.basename(egg_file))
        os.rename(src_egg_file, dst_egg_file)
        self._cache.update(cache_key, [dst_egg_file])
        egg_dep = PythonDependency.from_eggs(dst_egg_file)

        for pkg in builder.packages():
          print '    found namespace: %s' % pkg
        print '    copying...',
        self.env.add_dependency(egg_dep)
        print 'done.'
      else:
        print '   Failed!'
        raise PythonChroot.BuildFailureException("Failed to build %s!" % library)
Beispiel #2
0
 def _dump_setuptools(self):
   SETUPTOOLS = 'distribute-0.6.21-py2.6.egg'
   print '  Dumping setuptools: %s' % SETUPTOOLS
   data = pkgutil.get_data(__name__, os.path.join('bootstrap', SETUPTOOLS))
   with temporary_dir() as tempdir:
     egg_path = os.path.join(tempdir, SETUPTOOLS)
     with open(egg_path, 'w') as fp:
       fp.write(data)
     egg_dep = PythonDependency.from_eggs(egg_path)
     self.env.add_dependency(egg_dep)
Beispiel #3
0
 def _dump_egg(self, egg):
   target_name = os.path.pathsep.join(sorted(os.path.basename(e) for e in egg.eggs))
   cache_key = self._cache.key_for(target_name, egg.eggs)
   if self._cache.needs_update(cache_key):
     print '  Dumping egg: %s' % egg
     prefixes, all_added_files = set(), set()
     for egg_path in egg.eggs:
       egg_dep = PythonDependency.from_eggs(egg_path)
       prefix, added_files = self.env.add_dependency(egg_dep)
       all_added_files.update(added_files)
       prefixes.add(prefix)
     assert len(prefixes) == 1, 'Ambiguous egg environment!'
     self._cache.update(cache_key, all_added_files, artifact_root=prefixes.pop())
   else:
     print '  Dumping (cached) egg: %s' % egg
     self._cache.use_cached_files(cache_key, self.env.add_dependency_file)
Beispiel #4
0
 def _dump_egg(self, egg):
     if isinstance(egg, PythonEgg):
         target_name = os.path.pathsep.join(sorted(os.path.basename(e) for e in egg.eggs))
         cache_key = self._cache.key_for(target_name, egg.eggs)
         if self._cache.needs_update(cache_key):
             self.debug("  Dumping egg: %s" % egg)
             prefixes, all_added_files = set(), set()
             for egg_path in egg.eggs:
                 egg_dep = PythonDependency.from_eggs(egg_path)
                 prefix, added_files = self.env.add_dependency(egg_dep)
                 all_added_files.update(added_files)
                 prefixes.add(prefix)
             assert len(prefixes) == 1, "Ambiguous egg environment!"
             self._cache.update(cache_key, all_added_files, artifact_root=prefixes.pop())
         else:
             self.debug("  Dumping (cached) egg: %s" % egg)
             self._cache.use_cached_files(cache_key, self.env.add_dependency_file)
     elif isinstance(egg, PythonDependency):
         self.debug("  Dumping PythonDependency: %s" % egg)
         self.env.add_dependency(egg)
     else:
         raise PythonChroot.InvalidDependencyException("Unknown egg dependency %s" % egg)
Beispiel #5
0
 def _dump_req(self, req):
     self.debug("    - Fetching requirement: %s" % req)
     fetched_egg = self._fetcher.fetch(req)
     if fetched_egg is None:
         print("ERROR: Could not find %s!" % req, file=sys.stderr)
     else:
         if fetched_egg.endswith(".egg"):
             self._dump_egg(PythonDependency.from_eggs(fetched_egg))
             self.cache_egg_if_necessary(fetched_egg)
         else:
             if self._index is None:
                 self.debug("ERROR: Could not contact any indices!  Your application may not " "work properly.")
                 return
             self.debug("      => Building %s" % fetched_egg)
             distributions = ReqBuilder.install_requirement(fetched_egg, index=self._index, repositories=self._repos)
             if not distributions:
                 print("WARNING: Unable to build a working distribution from %s!" % fetched_egg, file=sys.stderr)
                 print("Your application may not work properly.", file=sys.stderr)
             else:
                 for distribution in distributions:
                     if distribution.location.endswith(".egg"):
                         self.cache_egg_if_necessary(distribution.location)
                     self._dump_distribution(distribution)
Beispiel #6
0
 def _dump_distribution(self, dist):
     self.debug("  Dumping distribution: .../%s" % os.path.basename(dist.location))
     egg_dep = PythonDependency.from_distributions(dist)
     self.env.add_dependency(egg_dep)