Statistics
| Branch: | Revision:

root / env / lib / python2.7 / site-packages / distribute-0.6.19-py2.7.egg / setuptools / command / install_scripts.py @ 1a305335

History | View | Annotate | Download (1.96 KB)

1
from distutils.command.install_scripts import install_scripts \
2
     as _install_scripts
3
from pkg_resources import Distribution, PathMetadata, ensure_directory
4
import os
5
from distutils import log
6

    
7
class install_scripts(_install_scripts):
8
    """Do normal script install, plus any egg_info wrapper scripts"""
9

    
10
    def initialize_options(self):
11
        _install_scripts.initialize_options(self)
12
        self.no_ep = False
13

    
14
    def run(self):
15
        from setuptools.command.easy_install import get_script_args
16
        from setuptools.command.easy_install import sys_executable
17

    
18
        self.run_command("egg_info")
19
        if self.distribution.scripts:
20
            _install_scripts.run(self)  # run first to set up self.outfiles
21
        else:
22
            self.outfiles = []
23
        if self.no_ep:
24
            # don't install entry point scripts into .egg file!
25
            return
26

    
27
        ei_cmd = self.get_finalized_command("egg_info")
28
        dist = Distribution(
29
            ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
30
            ei_cmd.egg_name, ei_cmd.egg_version,
31
        )
32
        bs_cmd = self.get_finalized_command('build_scripts')
33
        executable = getattr(bs_cmd,'executable',sys_executable)
34
        is_wininst = getattr(
35
            self.get_finalized_command("bdist_wininst"), '_is_running', False
36
        )
37
        for args in get_script_args(dist, executable, is_wininst):
38
            self.write_script(*args)
39

    
40
    def write_script(self, script_name, contents, mode="t", *ignored):
41
        """Write an executable file to the scripts directory"""
42
        from setuptools.command.easy_install import chmod
43
        log.info("Installing %s script to %s", script_name, self.install_dir)
44
        target = os.path.join(self.install_dir, script_name)
45
        self.outfiles.append(target)
46

    
47
        if not self.dry_run:
48
            ensure_directory(target)
49
            f = open(target,"w"+mode)
50
            f.write(contents)
51
            f.close()
52
            chmod(target,0755)
53