from setuptools.command.easy_install import easy_install from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError import os, sys, setuptools, glob class develop(easy_install): """Set up package for development""" description = "install package in 'development mode'" user_options = easy_install.user_options + [ ("uninstall", "u", "Uninstall this source package"), ("egg-path=", None, "Set the path to be used in the .egg-link file"), ] boolean_options = easy_install.boolean_options + ['uninstall'] command_consumes_arguments = False # override base def run(self): if self.uninstall: self.multi_version = True self.uninstall_link() else: self.install_for_development() self.warn_deprecated_options() def initialize_options(self): self.uninstall = None self.egg_path = None easy_install.initialize_options(self) self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: raise DistutilsError( "Please rename %r to %r before using 'develop'" % (ei.egg_info, ei.broken_egg_info) ) self.args = [ei.egg_name] easy_install.finalize_options(self) self.expand_basedirs() self.expand_dirs() # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) target = normalize_path(self.egg_base) if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" " directory to "+target ) # Make a distribution for the package's source self.dist = Distribution( target, PathMetadata(target, os.path.abspath(ei.egg_info)), project_name = ei.egg_name ) p = self.egg_base.replace(os.sep,'/') if p!= os.curdir: p = '../' * (p.count('/')+1) self.setup_path = p p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) if p != normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date self.reinitialize_command('build_py', inplace=0) self.run_command('build_py') bpy_cmd = self.get_finalized_command("build_py") build_path = normalize_path(bpy_cmd.build_lib) # Build extensions self.reinitialize_command('egg_info', egg_base=build_path) self.run_command('egg_info') self.reinitialize_command('build_ext', inplace=0) self.run_command('build_ext') # Fixup egg-link and easy-install.pth ei_cmd = self.get_finalized_command("egg_info") self.egg_path = build_path self.dist.location = build_path self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) # XXX else: # Without 2to3 inplace works fine: self.run_command('egg_info') # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) setuptools.bootstrap_install_from = None # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: f = open(self.egg_link,"w") f.write(self.egg_path + "\n" + self.setup_path) f.close() # postprocess the installed distro, fixing up .pth, installing scripts, # and handling requirements self.process_distribution(None, self.dist, not self.no_deps) def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) egg_link_file = open(self.egg_link) contents = [line.rstrip() for line in egg_link_file] egg_link_file.close() if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return if not self.dry_run: os.unlink(self.egg_link) if not self.dry_run: self.update_pth(self.dist) # remove any .pth link to us if self.distribution.scripts: # XXX should also check for entry point scripts! log.warn("Note: you must uninstall or replace scripts manually!") def install_egg_scripts(self, dist): if dist is not self.dist: # Installing a dependency, so fall back to normal behavior return easy_install.install_egg_scripts(self,dist) # create wrapper scripts in the script dir, pointing to dist.scripts # new-style... self.install_wrapper_scripts(dist) # ...and old-style for script_name in self.distribution.scripts or []: script_path = os.path.abspath(convert_path(script_name)) script_name = os.path.basename(script_path) f = open(script_path,'rU') script_text = f.read() f.close() self.install_script(dist, script_name, script_text, script_path)
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 |
|