From 1b77dd8e7845b5ac38fc7367796290dd65b8c531 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 14 Dec 2005 23:47:22 +0000 Subject: Support full roundtrip translation of eggs to and from ``bdist_wininst`` format. Running ``bdist_wininst`` on a setuptools-based package wraps the egg in an .exe that will safely install it as an egg (i.e., with metadata and entry-point wrapper scripts), and ``easy_install`` can turn the .exe back into an ``.egg`` file or directory and install it as such. At this point, it should also be possible to "system package" any egg, complete with wrapper scripts, and at least bdist_wininst works now. More testing is needed for at least bdist_dumb and bdist_rpm. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041692 --- setuptools/command/install_scripts.py | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 setuptools/command/install_scripts.py (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py new file mode 100755 index 00000000..470d4be4 --- /dev/null +++ b/setuptools/command/install_scripts.py @@ -0,0 +1,40 @@ +from distutils.command.install_scripts import install_scripts \ + as _install_scripts +from easy_install import get_script_args +from pkg_resources import Distribution, PathMetadata, ensure_directory +import os +from distutils import log + + +class install_scripts(_install_scripts): + """Do normal script install, plus any egg_info wrapper scripts""" + + def run(self): + self.run_command("egg_info") + _install_scripts.run(self) # run first to set up self.outfiles + + ei_cmd = self.get_finalized_command("egg_info") + dist = Distribution( + ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), + ei_cmd.egg_name, ei_cmd.egg_version, + ) + for args in get_script_args(dist): + self.write_script(*args) + + def write_script(self, script_name, contents, mode="t", *ignored): + """Write an executable file to the scripts directory""" + + log.info("Installing %s script to %s", script_name, self.install_dir) + target = os.path.join(self.install_dir, script_name) + self.outfiles.append(target) + + if not self.dry_run: + ensure_directory(target) + f = open(target,"w"+mode) + f.write(contents) + f.close() + try: + os.chmod(target,0755) + except (AttributeError, os.error): + pass + -- cgit v1.2.1 From d88c2b8c99c57a434209741a65bdb2751415ec3f Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 20 Dec 2005 16:31:29 +0000 Subject: Fix "legacy mode" trying to install scripts when there are none. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041777 --- setuptools/command/install_scripts.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 470d4be4..601b66f3 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -5,14 +5,15 @@ from pkg_resources import Distribution, PathMetadata, ensure_directory import os from distutils import log - class install_scripts(_install_scripts): """Do normal script install, plus any egg_info wrapper scripts""" def run(self): self.run_command("egg_info") - _install_scripts.run(self) # run first to set up self.outfiles - + if self.distribution.scripts: + _install_scripts.run(self) # run first to set up self.outfiles + else: + self.outfiles = [] ei_cmd = self.get_finalized_command("egg_info") dist = Distribution( ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), -- cgit v1.2.1 From 199f4f67ed81ef2f4fa3130bc6be0654e0d6dfd8 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Mon, 26 Dec 2005 19:21:41 +0000 Subject: Make the install_scripts command respect the "build_scripts -e" option when installing generated scripts using the --single-version-externally-managed option. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041815 --- setuptools/command/install_scripts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 601b66f3..66c08838 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,6 +1,6 @@ from distutils.command.install_scripts import install_scripts \ as _install_scripts -from easy_install import get_script_args +from easy_install import get_script_args, sys_executable from pkg_resources import Distribution, PathMetadata, ensure_directory import os from distutils import log @@ -19,12 +19,12 @@ class install_scripts(_install_scripts): ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), ei_cmd.egg_name, ei_cmd.egg_version, ) - for args in get_script_args(dist): - self.write_script(*args) + bs_cmd = self.get_finalized_command('build_scripts') + executable = getattr(bs_cmd,'executable',sys_executable) + for args in get_script_args(dist, executable): self.write_script(*args) def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" - log.info("Installing %s script to %s", script_name, self.install_dir) target = os.path.join(self.install_dir, script_name) self.outfiles.append(target) -- cgit v1.2.1 From 49c03612e7eb1a75ec836c574f6d1711fb6ecebf Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Mon, 13 Feb 2006 17:32:42 +0000 Subject: Fixed duplication of scripts inside .egg files --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042345 --- setuptools/command/install_scripts.py | 43 ++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 66c08838..fc156dce 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -8,12 +8,20 @@ from distutils import log class install_scripts(_install_scripts): """Do normal script install, plus any egg_info wrapper scripts""" + def initialize_options(self): + _install_scripts.initialize_options(self) + self.no_ep = False + def run(self): self.run_command("egg_info") if self.distribution.scripts: _install_scripts.run(self) # run first to set up self.outfiles else: self.outfiles = [] + if self.no_ep: + # don't install entry point scripts into .egg file! + return + ei_cmd = self.get_finalized_command("egg_info") dist = Distribution( ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), @@ -21,7 +29,15 @@ class install_scripts(_install_scripts): ) bs_cmd = self.get_finalized_command('build_scripts') executable = getattr(bs_cmd,'executable',sys_executable) - for args in get_script_args(dist, executable): self.write_script(*args) + + for args in get_script_args(dist, executable): + self.write_script(*args) + + + + + + def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" @@ -39,3 +55,28 @@ class install_scripts(_install_scripts): except (AttributeError, os.error): pass + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1 From 47f061eef1d9c4832b9a4394e84642811356ad10 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 29 Dec 2006 01:32:46 +0000 Subject: Partial support for cross-platform generation of bdist_wininst .exe's. Unfortunately, bdist_wininst doesn't fix up #! lines, so python.exe or pythonw.exe have to be on PATH for generated scripts to work. This could probably be fixed up with a post-install script, but that's a job for another day. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4053186 --- setuptools/command/install_scripts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index fc156dce..904704df 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -29,16 +29,16 @@ class install_scripts(_install_scripts): ) bs_cmd = self.get_finalized_command('build_scripts') executable = getattr(bs_cmd,'executable',sys_executable) - - for args in get_script_args(dist, executable): + is_wininst = getattr( + self.get_finalized_command("bdist_wininst"), '_is_running', False + ) + for args in get_script_args(dist, executable, is_wininst): self.write_script(*args) - - def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" log.info("Installing %s script to %s", script_name, self.install_dir) -- cgit v1.2.1 From 7c4938d53774c51b441970e177ce72cc3bdf68ce Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 18 Jan 2008 21:51:23 +0000 Subject: chmod/test cleanups and Jython compatibility (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4060062 --- setuptools/command/install_scripts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 904704df..c2dc2d59 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,6 +1,6 @@ from distutils.command.install_scripts import install_scripts \ as _install_scripts -from easy_install import get_script_args, sys_executable +from easy_install import get_script_args, sys_executable, chmod from pkg_resources import Distribution, PathMetadata, ensure_directory import os from distutils import log @@ -50,10 +50,10 @@ class install_scripts(_install_scripts): f = open(target,"w"+mode) f.write(contents) f.close() - try: - os.chmod(target,0755) - except (AttributeError, os.error): - pass + chmod(target,0755) + + + -- cgit v1.2.1 From 9d29ae853126d08c8779e7e158905ae263d6f52a Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 27 Oct 2009 09:30:16 +0100 Subject: removed PJE-style white lines --HG-- branch : distribute extra : rebase_source : b6f2b1983aa0e5994df5a29688348929fcd20628 --- setuptools/command/install_scripts.py | 38 +++-------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index c2dc2d59..b1186dba 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -11,7 +11,7 @@ class install_scripts(_install_scripts): def initialize_options(self): _install_scripts.initialize_options(self) self.no_ep = False - + def run(self): self.run_command("egg_info") if self.distribution.scripts: @@ -20,9 +20,9 @@ class install_scripts(_install_scripts): self.outfiles = [] if self.no_ep: # don't install entry point scripts into .egg file! - return + return - ei_cmd = self.get_finalized_command("egg_info") + ei_cmd = self.get_finalized_command("egg_info") dist = Distribution( ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), ei_cmd.egg_name, ei_cmd.egg_version, @@ -35,10 +35,6 @@ class install_scripts(_install_scripts): for args in get_script_args(dist, executable, is_wininst): self.write_script(*args) - - - - def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" log.info("Installing %s script to %s", script_name, self.install_dir) @@ -52,31 +48,3 @@ class install_scripts(_install_scripts): f.close() chmod(target,0755) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.1 From 9fc8282b30e40eb2c02c3e7bd28be5156e109a5c Mon Sep 17 00:00:00 2001 From: tarek Date: Sun, 15 Nov 2009 00:16:38 +0100 Subject: Fixed #80: test_develop fails with Python 3.1. I don't understand why the module is shadowed at this stage, but importing it fixes the problem. --HG-- branch : distribute extra : rebase_source : 9cbb38022787d08f0c8399e25829b10286fb655d --- setuptools/command/install_scripts.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index b1186dba..ac797883 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,6 +1,5 @@ from distutils.command.install_scripts import install_scripts \ as _install_scripts -from easy_install import get_script_args, sys_executable, chmod from pkg_resources import Distribution, PathMetadata, ensure_directory import os from distutils import log @@ -13,6 +12,9 @@ class install_scripts(_install_scripts): self.no_ep = False def run(self): + from setuptools.command.easy_install import (get_script_args, + sys_executable) + self.run_command("egg_info") if self.distribution.scripts: _install_scripts.run(self) # run first to set up self.outfiles @@ -37,6 +39,7 @@ class install_scripts(_install_scripts): def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" + from setuptools.command.easy_install import chmod log.info("Installing %s script to %s", script_name, self.install_dir) target = os.path.join(self.install_dir, script_name) self.outfiles.append(target) -- cgit v1.2.1 From 6a6a261fa50522d77fba6d6345fb71ba9f00c311 Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Thu, 6 May 2010 18:10:32 +0200 Subject: make sure all tests passes on all python versions fixes #149 --HG-- branch : distribute extra : rebase_source : 6288f4fcf65083b9d4ffb0ea8b35af44e699b4d5 --- setuptools/command/install_scripts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index ac797883..6ce1b993 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -12,8 +12,8 @@ class install_scripts(_install_scripts): self.no_ep = False def run(self): - from setuptools.command.easy_install import (get_script_args, - sys_executable) + from setuptools.command.easy_install import get_script_args + from setuptools.command.easy_install import sys_executable self.run_command("egg_info") if self.distribution.scripts: -- cgit v1.2.1 From 58a658b26d1c95b31d02050dcccd648d2e4ce27b Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 20 Jun 2011 22:55:16 +0100 Subject: Changes to support 2.x and 3.x in the same codebase. --HG-- branch : distribute extra : rebase_source : 7d3608edee54a43789f0574d702fb839628b5071 --- setuptools/command/install_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 6ce1b993..251190ba 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -49,5 +49,5 @@ class install_scripts(_install_scripts): f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target,0755) + chmod(target,0x1ED) # 0755 -- cgit v1.2.1 From 8dde28ee529c74d578e8142dfbb0a537a8bf0414 Mon Sep 17 00:00:00 2001 From: Justin Azoff Date: Sat, 12 May 2012 19:01:44 -0400 Subject: When writing out scripts, respect the users umask --HG-- branch : distribute extra : rebase_source : d4fc14bcdcd3e1a45da8bdcdef490537863ece35 --- setuptools/command/install_scripts.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 6ce1b993..82456035 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -39,15 +39,16 @@ class install_scripts(_install_scripts): def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" - from setuptools.command.easy_install import chmod + from setuptools.command.easy_install import chmod, current_umask log.info("Installing %s script to %s", script_name, self.install_dir) target = os.path.join(self.install_dir, script_name) self.outfiles.append(target) + mask = current_umask() if not self.dry_run: ensure_directory(target) f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target,0755) + chmod(target, 0777-mask) -- cgit v1.2.1 From 3ca95bfdfe8b4e68338f43de462e6b57e3fdf1a0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 1 Mar 2014 19:45:51 -0500 Subject: Remove excess whitespace --- setuptools/command/install_scripts.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 105dabca..1c6cc51d 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -51,4 +51,3 @@ class install_scripts(_install_scripts): f.write(contents) f.close() chmod(target, 0x1FF-mask) # 0777 - -- cgit v1.2.1 From 573c2c86d4d4f506a87a1fc16060f32c1386ad38 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 30 Apr 2014 17:38:29 -0400 Subject: Correct indentation and clarify meaning by using namespacing --HG-- extra : amend_source : 20ab7547c8478eb084767fe701e627bdd462ba16 --- setuptools/command/install_scripts.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 1c6cc51d..c19536bf 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,14 +1,13 @@ -from distutils.command.install_scripts import install_scripts \ - as _install_scripts +import distutils.command.install_scripts as orig from pkg_resources import Distribution, PathMetadata, ensure_directory import os from distutils import log -class install_scripts(_install_scripts): +class install_scripts(orig.install_scripts): """Do normal script install, plus any egg_info wrapper scripts""" def initialize_options(self): - _install_scripts.initialize_options(self) + orig.install_scripts.initialize_options(self) self.no_ep = False def run(self): @@ -17,7 +16,7 @@ class install_scripts(_install_scripts): self.run_command("egg_info") if self.distribution.scripts: - _install_scripts.run(self) # run first to set up self.outfiles + orig.install_scripts.run(self) # run first to set up self.outfiles else: self.outfiles = [] if self.no_ep: -- cgit v1.2.1 From 3fdbb8f7fa5c84dca9a7ff309d71ae3aeff60009 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 5 May 2014 03:50:59 -0400 Subject: Use modern syntax for octal values --- setuptools/command/install_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index c19536bf..ac373193 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -49,4 +49,4 @@ class install_scripts(orig.install_scripts): f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target, 0x1FF-mask) # 0777 + chmod(target, 0o777-mask) -- cgit v1.2.1 From 8e3f9d3253d1d0fb820dad4249d5110d017595c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Wed, 18 Jun 2014 20:31:05 +0300 Subject: Fixed PEP 8 compliancy of the setuptools.command package --- setuptools/command/install_scripts.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index ac373193..eb79fa3c 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,7 +1,9 @@ +from distutils import log import distutils.command.install_scripts as orig -from pkg_resources import Distribution, PathMetadata, ensure_directory import os -from distutils import log + +from pkg_resources import Distribution, PathMetadata, ensure_directory + class install_scripts(orig.install_scripts): """Do normal script install, plus any egg_info wrapper scripts""" @@ -29,7 +31,7 @@ class install_scripts(orig.install_scripts): ei_cmd.egg_name, ei_cmd.egg_version, ) bs_cmd = self.get_finalized_command('build_scripts') - executable = getattr(bs_cmd,'executable',sys_executable) + executable = getattr(bs_cmd, 'executable', sys_executable) is_wininst = getattr( self.get_finalized_command("bdist_wininst"), '_is_running', False ) @@ -39,6 +41,7 @@ class install_scripts(orig.install_scripts): def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" from setuptools.command.easy_install import chmod, current_umask + log.info("Installing %s script to %s", script_name, self.install_dir) target = os.path.join(self.install_dir, script_name) self.outfiles.append(target) @@ -46,7 +49,7 @@ class install_scripts(orig.install_scripts): mask = current_umask() if not self.dry_run: ensure_directory(target) - f = open(target,"w"+mode) + f = open(target, "w" + mode) f.write(contents) f.close() - chmod(target, 0o777-mask) + chmod(target, 0o777 - mask) -- cgit v1.2.1 From 2170df350911390a4a9a205763475dc7a7a2fb54 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jan 2015 16:21:11 -0500 Subject: Move decision logic about windows/header generation closer to install_scripts, as it doesn't appear to be used elsewhere. --- setuptools/command/install_scripts.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index eb79fa3c..eb5ed0f2 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -13,9 +13,9 @@ class install_scripts(orig.install_scripts): self.no_ep = False def run(self): - from setuptools.command.easy_install import get_script_args - from setuptools.command.easy_install import sys_executable - + from setuptools.command.easy_install import ( + ScriptWriter, sys_executable, get_script_header, + ) self.run_command("egg_info") if self.distribution.scripts: orig.install_scripts.run(self) # run first to set up self.outfiles @@ -35,7 +35,9 @@ class install_scripts(orig.install_scripts): is_wininst = getattr( self.get_finalized_command("bdist_wininst"), '_is_running', False ) - for args in get_script_args(dist, executable, is_wininst): + writer = ScriptWriter.get_writer(force_windows=is_wininst) + header = get_script_header("", executable, wininst=is_wininst) + for args in writer._gen_args(dist, header): self.write_script(*args) def write_script(self, script_name, contents, mode="t", *ignored): -- cgit v1.2.1 From ef9c3db451e2f24fc8821287e79a1ef48e0c5cf5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jan 2015 16:43:55 -0500 Subject: Move get_script_header into ScriptWriter --- setuptools/command/install_scripts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index eb5ed0f2..de74145f 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -35,8 +35,10 @@ class install_scripts(orig.install_scripts): is_wininst = getattr( self.get_finalized_command("bdist_wininst"), '_is_running', False ) + if is_wininst: + executable = "python.exe" writer = ScriptWriter.get_writer(force_windows=is_wininst) - header = get_script_header("", executable, wininst=is_wininst) + header = get_script_header("", executable) for args in writer._gen_args(dist, header): self.write_script(*args) -- cgit v1.2.1 From c3beddd034239005c98f7285a2936c513c5a81be Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jan 2015 17:12:37 -0500 Subject: Deprecate and remove usage of easy_install.get_script_header. --- setuptools/command/install_scripts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index de74145f..138e4ea2 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -14,7 +14,7 @@ class install_scripts(orig.install_scripts): def run(self): from setuptools.command.easy_install import ( - ScriptWriter, sys_executable, get_script_header, + ScriptWriter, sys_executable, nt_quote_arg, ) self.run_command("egg_info") if self.distribution.scripts: @@ -38,7 +38,7 @@ class install_scripts(orig.install_scripts): if is_wininst: executable = "python.exe" writer = ScriptWriter.get_writer(force_windows=is_wininst) - header = get_script_header("", executable) + header = ScriptWriter.get_header("", nt_quote_arg(executable)) for args in writer._gen_args(dist, header): self.write_script(*args) -- cgit v1.2.1 From 261d57232c74954468688a76aab2caea80ed42fc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jan 2015 17:14:11 -0500 Subject: Rename _gen_args to get_args (for consistency). --- setuptools/command/install_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 138e4ea2..1717e1cf 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -39,7 +39,7 @@ class install_scripts(orig.install_scripts): executable = "python.exe" writer = ScriptWriter.get_writer(force_windows=is_wininst) header = ScriptWriter.get_header("", nt_quote_arg(executable)) - for args in writer._gen_args(dist, header): + for args in writer.get_args(dist, header): self.write_script(*args) def write_script(self, script_name, contents, mode="t", *ignored): -- cgit v1.2.1 From 3ababa264dc404e9f8eae01045a4531b0b5bd692 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jan 2015 21:31:05 -0500 Subject: Update install_scripts to use CommandSpec for generating script headers. --- setuptools/command/install_scripts.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 1717e1cf..722b0566 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -13,9 +13,8 @@ class install_scripts(orig.install_scripts): self.no_ep = False def run(self): - from setuptools.command.easy_install import ( - ScriptWriter, sys_executable, nt_quote_arg, - ) + from setuptools.command.easy_install import ScriptWriter, CommandSpec + self.run_command("egg_info") if self.distribution.scripts: orig.install_scripts.run(self) # run first to set up self.outfiles @@ -31,15 +30,14 @@ class install_scripts(orig.install_scripts): ei_cmd.egg_name, ei_cmd.egg_version, ) bs_cmd = self.get_finalized_command('build_scripts') - executable = getattr(bs_cmd, 'executable', sys_executable) + cmd = CommandSpec.from_param(getattr(bs_cmd, 'executable', None)) is_wininst = getattr( self.get_finalized_command("bdist_wininst"), '_is_running', False ) if is_wininst: - executable = "python.exe" + cmd = CommandSpec.from_string("python.exe") writer = ScriptWriter.get_writer(force_windows=is_wininst) - header = ScriptWriter.get_header("", nt_quote_arg(executable)) - for args in writer.get_args(dist, header): + for args in writer.get_args(dist, cmd.as_header()): self.write_script(*args) def write_script(self, script_name, contents, mode="t", *ignored): -- cgit v1.2.1 From 921fc3e28378598912d69d3f2a6ebdd090ed3e4e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 Jan 2015 15:33:09 -0500 Subject: Renamed .get_writer to .best and removed boolean argument. --- setuptools/command/install_scripts.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 722b0566..ad89c5fd 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -13,7 +13,7 @@ class install_scripts(orig.install_scripts): self.no_ep = False def run(self): - from setuptools.command.easy_install import ScriptWriter, CommandSpec + import setuptools.command.easy_install as ei self.run_command("egg_info") if self.distribution.scripts: @@ -30,14 +30,15 @@ class install_scripts(orig.install_scripts): ei_cmd.egg_name, ei_cmd.egg_version, ) bs_cmd = self.get_finalized_command('build_scripts') - cmd = CommandSpec.from_param(getattr(bs_cmd, 'executable', None)) + cmd = ei.CommandSpec.from_param(getattr(bs_cmd, 'executable', None)) is_wininst = getattr( self.get_finalized_command("bdist_wininst"), '_is_running', False ) + writer = ei.ScriptWriter if is_wininst: - cmd = CommandSpec.from_string("python.exe") - writer = ScriptWriter.get_writer(force_windows=is_wininst) - for args in writer.get_args(dist, cmd.as_header()): + cmd = ei.CommandSpec.from_string("python.exe") + writer = ei.WindowsScriptWriter + for args in writer.best().get_args(dist, cmd.as_header()): self.write_script(*args) def write_script(self, script_name, contents, mode="t", *ignored): -- cgit v1.2.1 From 7cf2343ad9f5b77992422598d27d1f70e9473db0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 18 Jan 2015 19:45:22 -0500 Subject: Extract variable for bdist_wininst command --- setuptools/command/install_scripts.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index ad89c5fd..cad524ec 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -31,9 +31,8 @@ class install_scripts(orig.install_scripts): ) bs_cmd = self.get_finalized_command('build_scripts') cmd = ei.CommandSpec.from_param(getattr(bs_cmd, 'executable', None)) - is_wininst = getattr( - self.get_finalized_command("bdist_wininst"), '_is_running', False - ) + bw_cmd = self.get_finalized_command("bdist_wininst") + is_wininst = getattr(bw_cmd, '_is_running', False) writer = ei.ScriptWriter if is_wininst: cmd = ei.CommandSpec.from_string("python.exe") -- cgit v1.2.1 From 0d32bf350dce5cf21c821b9216799fa53550c5c1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 18 Jan 2015 19:46:46 -0500 Subject: Extract variable for exec_param --- setuptools/command/install_scripts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index cad524ec..f85f4520 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -30,7 +30,8 @@ class install_scripts(orig.install_scripts): ei_cmd.egg_name, ei_cmd.egg_version, ) bs_cmd = self.get_finalized_command('build_scripts') - cmd = ei.CommandSpec.from_param(getattr(bs_cmd, 'executable', None)) + exec_param = getattr(bs_cmd, 'executable', None) + cmd = ei.CommandSpec.from_param(exec_param) bw_cmd = self.get_finalized_command("bdist_wininst") is_wininst = getattr(bw_cmd, '_is_running', False) writer = ei.ScriptWriter -- cgit v1.2.1 From 0a0f7d5816fa7e42fd787d4923265adc965e1360 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 18 Jan 2015 19:54:01 -0500 Subject: Defer resolution of the CommandSpec and do it exactly once. --- setuptools/command/install_scripts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index f85f4520..af079fbb 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -31,13 +31,13 @@ class install_scripts(orig.install_scripts): ) bs_cmd = self.get_finalized_command('build_scripts') exec_param = getattr(bs_cmd, 'executable', None) - cmd = ei.CommandSpec.from_param(exec_param) bw_cmd = self.get_finalized_command("bdist_wininst") is_wininst = getattr(bw_cmd, '_is_running', False) writer = ei.ScriptWriter if is_wininst: - cmd = ei.CommandSpec.from_string("python.exe") + exec_param = "python.exe" writer = ei.WindowsScriptWriter + cmd = ei.CommandSpec.from_param(exec_param) for args in writer.best().get_args(dist, cmd.as_header()): self.write_script(*args) -- cgit v1.2.1 From 97f96e8cd4d1938095101f26a28f17d6a3f97435 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 18 Jan 2015 19:55:09 -0500 Subject: Extract writer resolution as a variable --- setuptools/command/install_scripts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index af079fbb..8d251ee7 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -37,8 +37,10 @@ class install_scripts(orig.install_scripts): if is_wininst: exec_param = "python.exe" writer = ei.WindowsScriptWriter + # resolve the writer to the environment + writer = writer.best() cmd = ei.CommandSpec.from_param(exec_param) - for args in writer.best().get_args(dist, cmd.as_header()): + for args in writer.get_args(dist, cmd.as_header()): self.write_script(*args) def write_script(self, script_name, contents, mode="t", *ignored): -- cgit v1.2.1 From 43ffa78752de38190b2480b68d9ad908cf1b7fa5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 18 Jan 2015 19:57:02 -0500 Subject: Allow the CommandSpec class to be resolved by the writer. --- setuptools/command/install_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 8d251ee7..9d4ac420 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -39,7 +39,7 @@ class install_scripts(orig.install_scripts): writer = ei.WindowsScriptWriter # resolve the writer to the environment writer = writer.best() - cmd = ei.CommandSpec.from_param(exec_param) + cmd = writer.command_spec_cls.from_param(exec_param) for args in writer.get_args(dist, cmd.as_header()): self.write_script(*args) -- cgit v1.2.1 From e584d52bc8080aa0e1dfec9514068bfef175b7fd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 18 Jan 2015 20:46:32 -0500 Subject: Correct command reference. --- setuptools/command/install_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 9d4ac420..20c2cce9 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -39,7 +39,7 @@ class install_scripts(orig.install_scripts): writer = ei.WindowsScriptWriter # resolve the writer to the environment writer = writer.best() - cmd = writer.command_spec_cls.from_param(exec_param) + cmd = writer.command_spec_class.from_param(exec_param) for args in writer.get_args(dist, cmd.as_header()): self.write_script(*args) -- cgit v1.2.1 From ad794c2809cc2ad0a48a14129dca82996f14af28 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 20 Jan 2015 20:33:29 -0500 Subject: Use a .best classmethod to resolve JythonCommandSpec when relevant. --- setuptools/command/install_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 20c2cce9..be66cb22 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -39,7 +39,7 @@ class install_scripts(orig.install_scripts): writer = ei.WindowsScriptWriter # resolve the writer to the environment writer = writer.best() - cmd = writer.command_spec_class.from_param(exec_param) + cmd = writer.command_spec_class.best().from_param(exec_param) for args in writer.get_args(dist, cmd.as_header()): self.write_script(*args) -- cgit v1.2.1 From 3132833570c90d52f6c2a422506732e82d772cdd Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Sun, 26 Jun 2016 01:48:30 +0200 Subject: Ensure shebang lines are correctly quoted if sys.executable contains spaces. Fixes issue #398. This only special-cases sys.executable; if the --executable parameter is used, paths with spaces have to be quoted there explicitly. While this change also applies to Unix platforms, if sys.executable contains spaces on Unix, any shebang lines created with it aren't going to work either way, whether they are quoted or not. --- setuptools/command/install_scripts.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index be66cb22..16234273 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,6 +1,7 @@ from distutils import log import distutils.command.install_scripts as orig import os +import sys from pkg_resources import Distribution, PathMetadata, ensure_directory @@ -37,6 +38,10 @@ class install_scripts(orig.install_scripts): if is_wininst: exec_param = "python.exe" writer = ei.WindowsScriptWriter + if exec_param == sys.executable: + # In case the path to the Python executable contains a space, wrap + # it so it's not split up. + exec_param = [exec_param] # resolve the writer to the environment writer = writer.best() cmd = writer.command_spec_class.best().from_param(exec_param) -- cgit v1.2.1 From 760e2e1df9c9c9d1fc072e7b6ad9df4c32bfc835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 27 Jul 2018 14:36:34 +0200 Subject: Remove spurious executable permissions --- setuptools/command/install_scripts.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 setuptools/command/install_scripts.py (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py old mode 100755 new mode 100644 -- cgit v1.2.1 From 60da370778026872e44d44c3a0429bfc2b242504 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 3 Feb 2020 15:05:14 +0100 Subject: Fix install_scripts() if bdist_wininst is missing Closes #1985 --- setuptools/command/install_scripts.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 16234273..8c9a15e2 100644 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -32,8 +32,11 @@ class install_scripts(orig.install_scripts): ) bs_cmd = self.get_finalized_command('build_scripts') exec_param = getattr(bs_cmd, 'executable', None) - bw_cmd = self.get_finalized_command("bdist_wininst") - is_wininst = getattr(bw_cmd, '_is_running', False) + try: + bw_cmd = self.get_finalized_command("bdist_wininst") + is_wininst = getattr(bw_cmd, '_is_running', False) + except ImportError: + is_wininst = False writer = ei.ScriptWriter if is_wininst: exec_param = "python.exe" -- cgit v1.2.1 From e6fdc967a538c7c08768a4898317572a76de2f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 12 Feb 2021 09:55:57 +0100 Subject: Remove bdist_wininst Fixes https://github.com/pypa/setuptools/issues/2558 --- setuptools/command/install_scripts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/install_scripts.py') diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 8c9a15e2..9cd8eb06 100644 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,5 +1,6 @@ from distutils import log import distutils.command.install_scripts as orig +from distutils.errors import DistutilsModuleError import os import sys @@ -35,7 +36,7 @@ class install_scripts(orig.install_scripts): try: bw_cmd = self.get_finalized_command("bdist_wininst") is_wininst = getattr(bw_cmd, '_is_running', False) - except ImportError: + except (ImportError, DistutilsModuleError): is_wininst = False writer = ei.ScriptWriter if is_wininst: -- cgit v1.2.1