diff options
author | PJ Eby <distutils-sig@python.org> | 2005-10-16 20:45:30 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-10-16 20:45:30 +0000 |
commit | c23b0fb2bfbd8df35ebee9551458ed00e0f2095c (patch) | |
tree | 7b535fe7eab66d13a987f9125d5e177c634ab40b | |
parent | 7a635d5195358704e12cc92d83a0b7b802e662da (diff) | |
download | external_python_setuptools-c23b0fb2bfbd8df35ebee9551458ed00e0f2095c.tar.gz external_python_setuptools-c23b0fb2bfbd8df35ebee9551458ed00e0f2095c.tar.bz2 external_python_setuptools-c23b0fb2bfbd8df35ebee9551458ed00e0f2095c.zip |
Fix problem with Windows console scripts conflicting with module names,
thereby confusing the import process. Scripts are now generated with a
suffix of the form '-script.py' to avoid conflicts. (The .exe's are still
generated without the '-script' part, so you don't have to type it.)
Thanks to Matthew R. Scott for reporting the problem.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041261
-rwxr-xr-x | EasyInstall.txt | 3 | ||||
-rwxr-xr-x | launcher.c | 8 | ||||
-rwxr-xr-x | setuptools/cli.exe | bin | 5632 -> 5632 bytes | |||
-rwxr-xr-x | setuptools/command/easy_install.py | 28 | ||||
-rwxr-xr-x | setuptools/gui.exe | bin | 5632 -> 5632 bytes |
5 files changed, 21 insertions, 18 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt index 236210c6..7866ed2d 100755 --- a/EasyInstall.txt +++ b/EasyInstall.txt @@ -780,6 +780,9 @@ Known Issues 0.6a6 * Added ``--no-deps`` option. + * Improved Windows ``.exe`` script wrappers so that the script can have the + same name as a module without confusing Python. + 0.6a3 * Improved error message when trying to use old ways of running ``easy_install``. Removed the ability to run via ``python -m`` or by @@ -12,8 +12,8 @@ To build/rebuild with mingw32, do this in the setuptools project directory: - gcc -DGUI=0 -mno-cygwin -O -s -o setuptools/cli.exe launcher.c - gcc -DGUI=1 -mwindows -mno-cygwin -O -s -o setuptools/gui.exe launcher.c + gcc -DGUI=0 -mno-cygwin -O -s -o setuptools/cli.exe launcher.c + gcc -DGUI=1 -mwindows -mno-cygwin -O -s -o setuptools/gui.exe launcher.c It links to msvcrt.dll, but this shouldn't be a problem since it doesn't actually run Python in the same process. Note that using 'exec' instead @@ -55,7 +55,8 @@ int run(int argc, char **argv, int is_gui) { end = script + strlen(script); while( end>script && *end != '.') *end-- = '\0'; - strcat(script, (GUI ? "pyw" : "py")); + *end-- = '\0'; + strcat(script, (GUI ? "-script.pyw" : "-script.py")); /* figure out the target python executable */ @@ -74,7 +75,6 @@ int run(int argc, char **argv, int is_gui) { *ptr = '\0'; while (ptr>python && isspace(*ptr)) *ptr-- = '\0'; /* strip trailing sp */ - if (strncmp(python, "#!", 2)) { /* default to python.exe if no #! header */ strcpy(python, "#!python.exe"); diff --git a/setuptools/cli.exe b/setuptools/cli.exe Binary files differindex d4afdaec..4da0b584 100755 --- a/setuptools/cli.exe +++ b/setuptools/cli.exe diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index b32be711..d85858a7 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -102,13 +102,13 @@ class easy_install(Command): def delete_blockers(self, blockers): for filename in blockers: - log.info("Deleting %s", filename) - if not self.dry_run: - if os.path.isdir(filename) and not os.path.islink(filename): - shutil.rmtree(filename) - else: - os.unlink(filename) - + if os.path.exists(filename) or os.path.islink(filename): + log.info("Deleting %s", filename) + if not self.dry_run: + if os.path.isdir(filename) and not os.path.islink(filename): + shutil.rmtree(filename) + else: + os.unlink(filename) @@ -464,18 +464,21 @@ class easy_install(Command): " load_entry_point(%(spec)r, %(group)r, %(name)r)()\n" ")\n" ) % locals() - if sys.platform=='win32': # On Windows, add a .py extension and an .exe launcher if group=='gui_scripts': - ext, launcher = '.pyw', 'gui.exe' + ext, launcher = '-script.pyw', 'gui.exe' + old = ['.pyw'] new_header = re.sub('(?i)python.exe','pythonw.exe',header) else: - ext, launcher = '.py', 'cli.exe' + ext, launcher = '-script.py', 'cli.exe' + old = ['.py','.pyc','.pyo'] new_header = re.sub('(?i)pythonw.exe','pythonw.exe',header) - if os.path.exists(new_header[2:-1]): header = new_header + + self.delete_blockers( # clean up old .py/.pyw w/o a script + [os.path.join(self.script_dir,name+x) for x in old]) self.write_script(name+ext, header+script_text) self.write_script( @@ -487,9 +490,6 @@ class easy_install(Command): # write the stub with no extension. self.write_script(name, header+script_text) - - - def install_script(self, dist, script_name, script_text, dev_path=None): """Generate a legacy script wrapper and install it""" spec = str(dist.as_requirement()) diff --git a/setuptools/gui.exe b/setuptools/gui.exe Binary files differindex 4021a4e4..056f554f 100755 --- a/setuptools/gui.exe +++ b/setuptools/gui.exe |