[Distutils] small improvement of the script functionality under
Vivian De Smedt
vivian at vdesmedt.com
Tue Mar 29 12:02:20 CEST 2005
Dear disutils devloppers,
First I would like to thank you for the nice job you did. I like
distutils it is a very nice and powerfull way to install package.
I finally found a pretext to thank you.
Distutils have a script functionality that copy the corresponding file
into a common script folder (that could be on the path) and sligthly
modify the first line of the script to reflect the path of the python
It is very nice but for the window platform I think it could be improved.
First the extention of the script could be .cmd such that they will be
accessible as commands as soon as the script folder is in the path.
Second the first line adaptation could be slightly different and take
advantage of the -x option of the python executable
#!python foo bar
@C:\Python24\python.exe -x "%~f0" foo bar & exit /b
#!C:\Python24\python.exe -x "%~f0" foo bar & exit /b
Follows a proposition of modification of the copy_scripts function of
the build_scripts.py that reflect these changes
for script in self.scripts:
adjust = 0
script = convert_path(script)
outfile = os.path.join(self.build_dir, os.path.basename(script))
*if os.name == "nt":
outfile += ".cmd"*
if not self.force and not newer(script, outfile):
log.debug("not copying %s (up-to-date)", script)
# Always open the file, but ignore failures in dry-run mode --
# that way, we'll get accurate feedback if we can read the
f = open(script, "r")
if not self.dry_run:
f = None
first_line = f.readline()
if not first_line:
self.warn("%s is an empty file (skipping)" % script)
match = first_line_re.match(first_line)
adjust = 1
post_interp = match.group(1) or ''
log.info("copying and adjusting %s -> %s", script,
if not self.dry_run:
outf = open(outfile, "w")
* if not sysconfig.python_build:
python_path = os.path.normpath(sys.executable)
python_path = os.path.join(
"python" + sysconfig.get_config_var("EXE"))
if os.name == "nt":
outf.write('@%s -x "%%~f0" %s & exit /b\n' %
outf.write("#!%s%s\n" % (python_path, post_interp))*
Tell me what you think about this proposition and what I should do to
have a chance to integrate it into your module.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Distutils-SIG