OLD | NEW |
(Empty) | |
| 1 from distutils import log |
| 2 import distutils.command.install_scripts as orig |
| 3 import os |
| 4 |
| 5 from pkg_resources import Distribution, PathMetadata, ensure_directory |
| 6 |
| 7 |
| 8 class install_scripts(orig.install_scripts): |
| 9 """Do normal script install, plus any egg_info wrapper scripts""" |
| 10 |
| 11 def initialize_options(self): |
| 12 orig.install_scripts.initialize_options(self) |
| 13 self.no_ep = False |
| 14 |
| 15 def run(self): |
| 16 from setuptools.command.easy_install import get_script_args |
| 17 from setuptools.command.easy_install import sys_executable |
| 18 |
| 19 self.run_command("egg_info") |
| 20 if self.distribution.scripts: |
| 21 orig.install_scripts.run(self) # run first to set up self.outfiles |
| 22 else: |
| 23 self.outfiles = [] |
| 24 if self.no_ep: |
| 25 # don't install entry point scripts into .egg file! |
| 26 return |
| 27 |
| 28 ei_cmd = self.get_finalized_command("egg_info") |
| 29 dist = Distribution( |
| 30 ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), |
| 31 ei_cmd.egg_name, ei_cmd.egg_version, |
| 32 ) |
| 33 bs_cmd = self.get_finalized_command('build_scripts') |
| 34 executable = getattr(bs_cmd, 'executable', sys_executable) |
| 35 is_wininst = getattr( |
| 36 self.get_finalized_command("bdist_wininst"), '_is_running', False |
| 37 ) |
| 38 for args in get_script_args(dist, executable, is_wininst): |
| 39 self.write_script(*args) |
| 40 |
| 41 def write_script(self, script_name, contents, mode="t", *ignored): |
| 42 """Write an executable file to the scripts directory""" |
| 43 from setuptools.command.easy_install import chmod, current_umask |
| 44 |
| 45 log.info("Installing %s script to %s", script_name, self.install_dir) |
| 46 target = os.path.join(self.install_dir, script_name) |
| 47 self.outfiles.append(target) |
| 48 |
| 49 mask = current_umask() |
| 50 if not self.dry_run: |
| 51 ensure_directory(target) |
| 52 f = open(target, "w" + mode) |
| 53 f.write(contents) |
| 54 f.close() |
| 55 chmod(target, 0o777 - mask) |
OLD | NEW |