patch to utils.py for Windows os.path.isdir glitch
I was finally able to install the distutils 0.1 package on my Windows NT machine running Python 1.5.2, after getting around two problems: 1) I had a very old python.exe sitting in my PATH, which when run would report itself as Python version 1.5.2 but would cause sys.prefix and sys.exec_prefix to be empty because Python couldn't find the expected libraries relative to the python.exe location. I deleted that old python.exe and now sys.prefix and sys.exec_prefix are set correctly. Thanks to Mark Hammond for suggesting the fix. 2) Running 'python -v start.py install' would result in an exception in utils.py when os.mkdir() would be called on an existing directory. It seems that on Windows, os.path.isdir() does not accept trailing backslashes on a directory name. For example, os.path.isdir('c:\\progra~1') returns 1 on my machine, but os.path.isdir('c:\\progra~1\\') returns 0. I tweaked utils.py to account for that and now the installation seems to finish OK. I have attached the patch with my suggested change. -- Fred Yankowski fred@OntoSys.com tel: +1.630.879.1312 Principal Consultant www.OntoSys.com fax: +1.630.879.1370 OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA -- =================================================================== RCS file: RCS/util.py retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** util.py 1999/10/22 18:32:41 1.1 --- util.py 1999/10/22 19:35:03 1.2 *************** *** 37,50 **** # the creation of the whole path? (quite easy to do the latter since # we're not using a recursive algorithm) if os.path.isdir (name): return if PATH_CREATED.get (name): return (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 while head and tail and not os.path.isdir (head): --- 37,52 ---- # the creation of the whole path? (quite easy to do the latter since # we're not using a recursive algorithm) + (head, tail) = os.path.split (name) + if not tail: # in case 'name' has trailing slash + name = head + if os.path.isdir (name): return if PATH_CREATED.get (name): return (head, tail) = os.path.split (name) tails = [tail] # stack of lone dirs to create while head and tail and not os.path.isdir (head):
On 22 October 1999, Fred Yankowski said:
I was finally able to install the distutils 0.1 package on my Windows NT machine running Python 1.5.2, after getting around two problems:
Great!
1) I had a very old python.exe sitting in my PATH, which when run would report itself as Python version 1.5.2 but would cause sys.prefix and sys.exec_prefix to be empty because Python couldn't find the expected libraries relative to the python.exe location. I deleted that old python.exe and now sys.prefix and sys.exec_prefix are set correctly. Thanks to Mark Hammond for suggesting the fix.
Ahh, good -- when I read your first post, I was inclined to shoot back with a "Sounds like a broken Python installation", but I know very very little about Python on Windows so I kept my mouth shut. Looks like I would have been right. Should I add code somewhere in Distutils to detect empty sys.prefix or exec_prefix? This really sounds like a clear indication that the Python installation is badly broken, so there's no point in trying to install anything because it simply won't work.
2) Running 'python -v start.py install' would result in an exception in utils.py when os.mkdir() would be called on an existing directory. It seems that on Windows, os.path.isdir() does not accept trailing backslashes on a directory name. For example, os.path.isdir('c:\\progra~1') returns 1 on my machine, but os.path.isdir('c:\\progra~1\\') returns 0. I tweaked utils.py to account for that and now the installation seems to finish OK. I have attached the patch with my suggested change.
Yep, that's already been fixed. It just took me a couple of weeks to get around to trying it out on a Windows machine myself. Now done. See my next post... 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)
-
Fred Yankowski
-
Greg Ward