]> crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/setuptools/command/install_scripts.py
Archivo de configuraciĆ³n de la terminal
[config.git] / djavu-asus / elpy / rpc-venv / lib / python3.11 / site-packages / setuptools / command / install_scripts.py
1 from distutils import log
2 import distutils.command.install_scripts as orig
3 from distutils.errors import DistutilsModuleError
4 import os
5 import sys
6
7 from pkg_resources import Distribution, PathMetadata
8 from .._path import ensure_directory
9
10
11 class install_scripts(orig.install_scripts):
12 """Do normal script install, plus any egg_info wrapper scripts"""
13
14 def initialize_options(self):
15 orig.install_scripts.initialize_options(self)
16 self.no_ep = False
17
18 def run(self):
19 import setuptools.command.easy_install as ei
20
21 self.run_command("egg_info")
22 if self.distribution.scripts:
23 orig.install_scripts.run(self) # run first to set up self.outfiles
24 else:
25 self.outfiles = []
26 if self.no_ep:
27 # don't install entry point scripts into .egg file!
28 return
29
30 ei_cmd = self.get_finalized_command("egg_info")
31 dist = Distribution(
32 ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
33 ei_cmd.egg_name, ei_cmd.egg_version,
34 )
35 bs_cmd = self.get_finalized_command('build_scripts')
36 exec_param = getattr(bs_cmd, 'executable', None)
37 try:
38 bw_cmd = self.get_finalized_command("bdist_wininst")
39 is_wininst = getattr(bw_cmd, '_is_running', False)
40 except (ImportError, DistutilsModuleError):
41 is_wininst = False
42 writer = ei.ScriptWriter
43 if is_wininst:
44 exec_param = "python.exe"
45 writer = ei.WindowsScriptWriter
46 if exec_param == sys.executable:
47 # In case the path to the Python executable contains a space, wrap
48 # it so it's not split up.
49 exec_param = [exec_param]
50 # resolve the writer to the environment
51 writer = writer.best()
52 cmd = writer.command_spec_class.best().from_param(exec_param)
53 for args in writer.get_args(dist, cmd.as_header()):
54 self.write_script(*args)
55
56 def write_script(self, script_name, contents, mode="t", *ignored):
57 """Write an executable file to the scripts directory"""
58 from setuptools.command.easy_install import chmod, current_umask
59
60 log.info("Installing %s script to %s", script_name, self.install_dir)
61 target = os.path.join(self.install_dir, script_name)
62 self.outfiles.append(target)
63
64 mask = current_umask()
65 if not self.dry_run:
66 ensure_directory(target)
67 f = open(target, "w" + mode)
68 f.write(contents)
69 f.close()
70 chmod(target, 0o777 - mask)