[Distutils] patch for interpreter destination location
Tim Magill
magill@gate.net
Mon May 12 03:10:01 2003
--BI5RvnYi6R4T2M87
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
I'm interested in building distribution files in multiple spooling
directories for delivery on multiple platforms. In doing so there was
no way for me to set the location for the interpreter in the final
destination rather than the spooling destination.
Enclosed is a patch that allows me to specify the string to be
substituted in the "#!" line at the beginning of scripts and a
documentation fragment for the new option.
Comments?
thanks
tim
--BI5RvnYi6R4T2M87
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch.diff"
Index: Lib/distutils/command/build.py
===================================================================
RCS file: /src/python/Lib/distutils/command/build.py,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 build.py
--- Lib/distutils/command/build.py 25 Jan 2003 00:10:42 -0000 1.1.1.1
+++ Lib/distutils/command/build.py 10 May 2003 21:50:11 -0000
@@ -40,6 +40,8 @@
"compile extensions and libraries with debugging information"),
('force', 'f',
"forcibly build everything (ignore file timestamps)"),
+ ('executable=', 'e',
+ "specify final destination interpreter path (build.py)"),
]
boolean_options = ['debug', 'force']
@@ -61,6 +63,7 @@
self.compiler = None
self.debug = None
self.force = 0
+ self.executable = None
def finalize_options (self):
@@ -93,6 +96,8 @@
self.build_scripts = os.path.join(self.build_base,
'scripts-' + sys.version[0:3])
+ if self.executable is None:
+ self.executable = os.path.normpath(sys.executable)
# finalize_options ()
Index: Lib/distutils/command/build_scripts.py
===================================================================
RCS file: /src/python/Lib/distutils/command/build_scripts.py,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 build_scripts.py
--- Lib/distutils/command/build_scripts.py 25 Jan 2003 00:10:42 -0000 1.1.1.1
+++ Lib/distutils/command/build_scripts.py 10 May 2003 21:50:11 -0000
@@ -22,6 +22,7 @@
user_options = [
('build-dir=', 'd', "directory to \"build\" (copy) to"),
('force', 'f', "forcibly build everything (ignore file timestamps"),
+ ('executable=', 'e', "specify final destination interpreter path"),
]
boolean_options = ['force']
@@ -31,12 +32,14 @@
self.build_dir = None
self.scripts = None
self.force = None
+ self.executable = None
self.outfiles = None
def finalize_options (self):
self.set_undefined_options('build',
('build_scripts', 'build_dir'),
- ('force', 'force'))
+ ('force', 'force'),
+ ('executable', 'executable'))
self.scripts = self.distribution.scripts
@@ -89,7 +92,7 @@
outf = open(outfile, "w")
if not sysconfig.python_build:
outf.write("#!%s%s\n" %
- (os.path.normpath(sys.executable),
+ (self.executable,
post_interp))
else:
outf.write("#!%s%s" %
--BI5RvnYi6R4T2M87
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="doc.txt"
3.4 Listing scripts
So far we have been dealing with pure and non-pure Python modules,
which are usually not run by themselves but imported by scripts.
Scripts are files containing Python source code, indended to be
started from the command line. Distutils provides two features for
scripts. If the first line of the script starts with #! and contains
the word ``python'' Distutils adjusts the interpreter location. By
default, it is replaced with the current interpreter location. The
'--executable=/-e' switch will allow the interpreter path to be
explicitly overridden.
The scripts option simply is a list of files to be handled in this
way.
--BI5RvnYi6R4T2M87--