![](https://secure.gravatar.com/avatar/7e4674d6b59b7794729224c9475c638b.jpg?s=120&d=mm&r=g)
Three cheers for distutils 0.1! Unfortunately it fails to install itself on my NT box. D:\TEMP\Distutils-0.1>python setup.py -v install running install running build running build_py not copying distutils\ccompiler.py (output up-to-date) not copying distutils\core.py (output up-to-date) not copying distutils\errors.py (output up-to-date) not copying distutils\fancy_getopt.py (output up-to-date) not copying distutils\msvccompiler.py (output up-to-date) not copying distutils\spawn.py (output up-to-date) not copying distutils\sysconfig.py (output up-to-date) not copying distutils\text_file.py (output up-to-date) not copying distutils\unixccompiler.py (output up-to-date) not copying distutils\util.py (output up-to-date) not copying distutils\version.py (output up-to-date) not copying distutils\__init__.py (output up-to-date) not copying distutils\command\build.py (output up-to-date) not copying distutils\command\build_ext.py (output up-to-date) not copying distutils\command\build_py.py (output up-to-date) not copying distutils\command\dist.py (output up-to-date) not copying distutils\command\install.py (output up-to-date) not copying distutils\command\install_ext.py (output up-to-date) not copying distutils\command\install_py.py (output up-to-date) not copying distutils\command\__init__.py (output up-to-date) running install_py creating D:\Python1.5.2 Traceback (innermost last): File "setup.py", line 22, in ? packages = ['distutils', 'distutils.command'], File "distutils\core.py", line 87, in setup dist.run_commands () File "distutils\core.py", line 377, in run_commands self.run_command (cmd) File "distutils\core.py", line 426, in run_command cmd_obj.run () File "distutils\command\install.py", line 287, in run self.run_peer ('install_py') File "distutils\core.py", line 710, in run_peer self.distribution.run_command (command) File "distutils\core.py", line 426, in run_command cmd_obj.run () File "distutils\command\install_py.py", line 51, in run outfiles = self.copy_tree (self.build_dir, self.install_dir) File "distutils\core.py", line 773, in copy_tree self.distribution.dry_run) File "distutils\util.py", line 318, in copy_tree mkpath (dst, verbose=verbose) File "distutils\util.py", line 74, in mkpath raise DistutilsFileError, "%s: %s" % (head, errstr) distutils.errors.DistutilsFileError: D:\Python1.5.2: File exists To fix this I changed line 317 of distutils/util.py to: if not dry_run and not os.path.exists(os.path.normpath(dst)): This checks to see if the destination directory already exists before creating it. Note: I had to use normpath since for me dst was 'D:\\Python1.5.2\\' which os.path.exists claims doesn't exist, while 'D:\\Python1.5.2' does exist. -Amos
![](https://secure.gravatar.com/avatar/a82637fa0213d54497b281967404b6a0.jpg?s=120&d=mm&r=g)
On 29 September 1999, Amos Latteier said:
Three cheers for distutils 0.1!
Unfortunately it fails to install itself on my NT box.
Details, details. You Windows people are so picky. ;-)
running install_py creating D:\Python1.5.2 Traceback (innermost last): File "setup.py", line 22, in ? packages = ['distutils', 'distutils.command'], [...yikes -- at least my tracebacks aren't as bad as JPython's...] File "distutils\util.py", line 318, in copy_tree mkpath (dst, verbose=verbose) File "distutils\util.py", line 74, in mkpath raise DistutilsFileError, "%s: %s" % (head, errstr) distutils.errors.DistutilsFileError: D:\Python1.5.2: File exists
To fix this I changed line 317 of distutils/util.py to:
if not dry_run and not os.path.exists(os.path.normpath(dst)):
Hmm, no, this is really mkpath's fault. But thanks for reminding me of the existence of normpath() -- somehow I forgot all about it. Anyone on a Windows box with Python and the Distutils handy, please try this out to see if I've fixed it. First, verify the bug:
from distutils.util import mkpath mkpath ("\blah\")
where "\blah" doesn't already exist on the current drive. Should blow up with that "File exists" error. Try it without the trailing backslash, too. Now apply this patch (in "Distutils-0.1\distutils"): *** util.py 1999/09/29 12:14:16 1.7 --- util.py 1999/10/01 00:25:18 *************** *** 39,40 **** --- 39,42 ---- + name = os.path.normpath (name) + if os.path.isdir (name): *************** *** 45,48 **** (head, tail) = os.path.split (name) - if not tail: # in case 'name' has trailing slash - (head, tail) = os.path.split (head) tails = [tail] # stack of lone dirs to create --- 47,48 ---- and try it again. Try it with and without the trailing backslash, on different and the same directories. Of course, I'll do all this tomorrow at work, where I have access to a Windows machine. Let me know if you find other bugs in mkpath though -- this is a surprisingly tricky little thing to get right. Greg -- Greg Ward - software developer gward@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive voice: +1-703-620-8990 Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
participants (2)
-
Amos Latteier
-
Greg Ward