Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f5c0c4

Browse files
committed
Patch #736857, #736859: Add -e option to build_scripts.
1 parent be83737 commit 9f5c0c4

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

Doc/dist/dist.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,9 @@ \section{Installing Scripts}
640640
anything very complicated. The only clever feature is that if the
641641
first line of the script starts with \code{\#!} and contains the word
642642
``python'', the Distutils will adjust the first line to refer to the
643-
current interpreter location.
643+
current interpreter location. By default, it is replaced with the
644+
current interpreter location. The '--executable=/-e' switch will
645+
allow the interpreter path to be explicitly overridden.
644646

645647
The \option{scripts} option simply is a list of files to be handled
646648
in this way. From the PyXML setup script:

Lib/distutils/command/build.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class build (Command):
4040
"compile extensions and libraries with debugging information"),
4141
('force', 'f',
4242
"forcibly build everything (ignore file timestamps)"),
43+
('executable=', 'e',
44+
"specify final destination interpreter path (build.py)"),
4345
]
4446

4547
boolean_options = ['debug', 'force']
@@ -61,6 +63,7 @@ def initialize_options (self):
6163
self.compiler = None
6264
self.debug = None
6365
self.force = 0
66+
self.executable = None
6467

6568
def finalize_options (self):
6669

@@ -93,6 +96,8 @@ def finalize_options (self):
9396
self.build_scripts = os.path.join(self.build_base,
9497
'scripts-' + sys.version[0:3])
9598

99+
if self.executable is None:
100+
self.executable = os.path.normpath(sys.executable)
96101
# finalize_options ()
97102

98103

Lib/distutils/command/build_scripts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class build_scripts (Command):
2424
user_options = [
2525
('build-dir=', 'd', "directory to \"build\" (copy) to"),
2626
('force', 'f', "forcibly build everything (ignore file timestamps"),
27+
('executable=', 'e', "specify final destination interpreter path"),
2728
]
2829

2930
boolean_options = ['force']
@@ -33,12 +34,14 @@ def initialize_options (self):
3334
self.build_dir = None
3435
self.scripts = None
3536
self.force = None
37+
self.executable = None
3638
self.outfiles = None
3739

3840
def finalize_options (self):
3941
self.set_undefined_options('build',
4042
('build_scripts', 'build_dir'),
41-
('force', 'force'))
43+
('force', 'force'),
44+
('executable', 'executable'))
4245
self.scripts = self.distribution.scripts
4346

4447
def get_source_files(self):
@@ -95,7 +98,7 @@ def copy_scripts (self):
9598
outf = open(outfile, "w")
9699
if not sysconfig.python_build:
97100
outf.write("#!%s%s\n" %
98-
(os.path.normpath(sys.executable),
101+
(self.executable,
99102
post_interp))
100103
else:
101104
outf.write("#!%s%s\n" %

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Extension modules
5757
Library
5858
-------
5959

60+
- distutils build/build_scripts now has an -e option to specify the
61+
path to the Python interpreter for installed scripts.
62+
6063
- PEP 292 classes Template and SafeTemplate are added to the string module.
6164

6265
- tarfile now generates GNU tar files by default.

0 commit comments

Comments
 (0)