from setuptools import Command from setuptools.archive_util import unpack_archive from distutils import log, dir_util import os, shutil, pkg_resources class install_egg_info(Command): """Install an .egg-info directory for the package""" description = "Install an .egg-info directory for the package" user_options = [ ('install-dir=', 'd', "directory to install to"), ] def initialize_options(self): self.install_dir = None def finalize_options(self): self.set_undefined_options('install_lib',('install_dir','install_dir')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version ).egg_name()+'.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) self.outputs = [self.target] def run(self): self.run_command('egg_info') target = self.target if os.path.isdir(self.target) and not os.path.islink(self.target): dir_util.remove_tree(self.target, dry_run=self.dry_run) elif os.path.exists(self.target): self.execute(os.unlink,(self.target,),"Removing "+self.target) if not self.dry_run: pkg_resources.ensure_directory(self.target) self.execute(self.copytree, (), "Copying %s to %s" % (self.source, self.target) ) self.install_namespaces() def get_outputs(self): return self.outputs def copytree(self): # Copy the .egg-info tree to site-packages def skimmer(src,dst): # filter out source-control directories; note that 'src' is always # a '/'-separated path, regardless of platform. 'dst' is a # platform-specific path. for skip in '.svn/','CVS/': if src.startswith(skip) or '/'+skip in src: return None self.outputs.append(dst) log.debug("Copying %s to %s", src, dst) return dst unpack_archive(self.source, self.target, skimmer) def install_namespaces(self): nsp = self._get_all_ns_packages() if not nsp: return filename,ext = os.path.splitext(self.target) filename += '-nspkg.pth'; self.outputs.append(filename) log.info("Installing %s",filename) if not self.dry_run: f = open(filename,'wt') for pkg in nsp: # ensure pkg is not a unicode string under Python 2.7 pkg = str(pkg) pth = tuple(pkg.split('.')) trailer = '\n' if '.' in pkg: trailer = ( "; m and setattr(sys.modules[%r], %r, m)\n" % ('.'.join(pth[:-1]), pth[-1]) ) f.write( "import sys,types,os; " "p = os.path.join(sys._getframe(1).f_locals['sitedir'], " "*%(pth)r); " "ie = os.path.exists(os.path.join(p,'__init__.py')); " "m = not ie and " "sys.modules.setdefault(%(pkg)r,types.ModuleType(%(pkg)r)); " "mp = (m or []) and m.__dict__.setdefault('__path__',[]); " "(p not in mp) and mp.append(p)%(trailer)s" % locals() ) f.close() def _get_all_ns_packages(self): nsp = {} for pkg in self.distribution.namespace_packages or []: pkg = pkg.split('.') while pkg: nsp['.'.join(pkg)] = 1 pkg.pop() nsp=list(nsp) nsp.sort() # set up shorter names first return nsp
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
.__init__.pyo.40009 | File | 911 B | 0644 |
|
.alias.pyo.40009 | File | 3.16 KB | 0644 |
|
.bdist_egg.pyo.40009 | File | 18.18 KB | 0644 |
|
.bdist_rpm.pyo.40009 | File | 2.24 KB | 0644 |
|
.bdist_wininst.pyo.40009 | File | 2.33 KB | 0644 |
|
.build_py.pyo.40009 | File | 11.38 KB | 0644 |
|
.develop.pyo.40009 | File | 5.68 KB | 0644 |
|
.easy_install.pyo.40009 | File | 65.69 KB | 0644 |
|
.egg_info.pyo.40009 | File | 17.27 KB | 0644 |
|
.install.pyo.40009 | File | 3.67 KB | 0644 |
|
.install_egg_info.pyo.40009 | File | 4.56 KB | 0644 |
|
.install_scripts.pyo.40009 | File | 2.54 KB | 0644 |
|
.register.pyo.40009 | File | 692 B | 0644 |
|
.rotate.pyo.40009 | File | 2.88 KB | 0644 |
|
.saveopts.pyo.40009 | File | 1.2 KB | 0644 |
|
.sdist.pyo.40009 | File | 9.92 KB | 0644 |
|
.setopt.pyo.40009 | File | 5.91 KB | 0644 |
|
.test.pyo.40009 | File | 5.76 KB | 0644 |
|
__init__.py | File | 689 B | 0644 |
|
__init__.pyc | File | 911 B | 0644 |
|
__init__.pyo | File | 911 B | 0644 |
|
alias.py | File | 2.43 KB | 0644 |
|
alias.pyc | File | 3.16 KB | 0644 |
|
alias.pyo | File | 3.16 KB | 0644 |
|
bdist_egg.py | File | 18.28 KB | 0644 |
|
bdist_egg.pyc | File | 18.18 KB | 0644 |
|
bdist_egg.pyo | File | 18.18 KB | 0644 |
|
bdist_rpm.py | File | 1.98 KB | 0644 |
|
bdist_rpm.pyc | File | 2.24 KB | 0644 |
|
bdist_rpm.pyo | File | 2.24 KB | 0644 |
|
bdist_wininst.py | File | 2.23 KB | 0644 |
|
bdist_wininst.pyc | File | 2.33 KB | 0644 |
|
bdist_wininst.pyo | File | 2.33 KB | 0644 |
|
build_ext.py | File | 11.58 KB | 0644 |
|
build_ext.pyc | File | 10.08 KB | 0644 |
|
build_ext.pyo | File | 10.04 KB | 0644 |
|
build_py.py | File | 10.29 KB | 0644 |
|
build_py.pyc | File | 11.38 KB | 0644 |
|
build_py.pyo | File | 11.38 KB | 0644 |
|
develop.py | File | 6.3 KB | 0644 |
|
develop.pyc | File | 5.68 KB | 0644 |
|
develop.pyo | File | 5.68 KB | 0644 |
|
easy_install.py | File | 73.07 KB | 0755 |
|
easy_install.pyc | File | 65.69 KB | 0644 |
|
easy_install.pyo | File | 65.69 KB | 0644 |
|
egg_info.py | File | 15.42 KB | 0644 |
|
egg_info.pyc | File | 17.27 KB | 0644 |
|
egg_info.pyo | File | 17.27 KB | 0644 |
|
install.py | File | 3.97 KB | 0644 |
|
install.pyc | File | 3.67 KB | 0644 |
|
install.pyo | File | 3.67 KB | 0644 |
|
install_egg_info.py | File | 3.74 KB | 0644 |
|
install_egg_info.pyc | File | 4.56 KB | 0644 |
|
install_egg_info.pyo | File | 4.56 KB | 0644 |
|
install_lib.py | File | 2.43 KB | 0644 |
|
install_lib.pyc | File | 3.14 KB | 0644 |
|
install_lib.pyo | File | 3.1 KB | 0644 |
|
install_scripts.py | File | 2.02 KB | 0644 |
|
install_scripts.pyc | File | 2.54 KB | 0644 |
|
install_scripts.pyo | File | 2.54 KB | 0644 |
|
register.py | File | 277 B | 0644 |
|
register.pyc | File | 692 B | 0644 |
|
register.pyo | File | 692 B | 0644 |
|
rotate.py | File | 2.01 KB | 0644 |
|
rotate.pyc | File | 2.88 KB | 0644 |
|
rotate.pyo | File | 2.88 KB | 0644 |
|
saveopts.py | File | 705 B | 0644 |
|
saveopts.pyc | File | 1.2 KB | 0644 |
|
saveopts.pyo | File | 1.2 KB | 0644 |
|
sdist.py | File | 9.6 KB | 0644 |
|
sdist.pyc | File | 9.92 KB | 0644 |
|
sdist.pyo | File | 9.92 KB | 0644 |
|
setopt.py | File | 4.95 KB | 0644 |
|
setopt.pyc | File | 5.91 KB | 0644 |
|
setopt.pyo | File | 5.91 KB | 0644 |
|
test.py | File | 5.79 KB | 0644 |
|
test.pyc | File | 5.76 KB | 0644 |
|
test.pyo | File | 5.76 KB | 0644 |
|
upload.py | File | 6.57 KB | 0644 |
|
upload.pyc | File | 6.28 KB | 0644 |
|
upload.pyo | File | 6.26 KB | 0644 |
|
upload_docs.py | File | 6.81 KB | 0644 |
|
upload_docs.pyc | File | 7.01 KB | 0644 |
|
upload_docs.pyo | File | 6.98 KB | 0644 |
|