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 executable.
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

could become:

@C:\Python24\python.exe -x "%~f0" foo bar  & exit /b

instead of:

#!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"

            outfiles.append(outfile)

            if not self.force and not newer(script, outfile):
                log.debug("not copying %s (up-to-date)", script)
                continue

            # Always open the file, but ignore failures in dry-run mode --
            # that way, we'll get accurate feedback if we can read the
            # script.
            try:
                f = open(script, "r")
            except IOError:
                if not self.dry_run:
                    raise
                f = None
            else:
                first_line = f.readline()
                if not first_line:
                    self.warn("%s is an empty file (skipping)" % script)
                    continue

                match = first_line_re.match(first_line)
                if match:
                    adjust = 1
                    post_interp = match.group(1) or ''

            if adjust:
                log.info("copying and adjusting %s -> %s", script,
                         self.build_dir)
                if not self.dry_run:
                    outf = open(outfile, "w")
                    if not sysconfig.python_build:
                        python_path = os.path.normpath(sys.executable)
                    else:
                        python_path = os.path.join(
                            sysconfig.get_config_var("BINDIR"),
                            "python" + sysconfig.get_config_var("EXE"))
                    if os.name == "nt":
                        outf.write('@%s -x "%%~f0" %s & exit /b\n' % (python_path, post_interp))
                    else:
                        outf.write("#!%s%s\n" % (python_path, post_interp))


                    outf.writelines(f.readlines())
                    outf.close()
                if f:
                    f.close()
            else:
                f.close()
                self.copy_file(script, outfile)

Tell me what you think about this proposition and what I should do to have a chance to integrate it into your module.

Vivian.