classification
Title: bdist_dumb and --relative on Windows fails
Type: behavior Stage: needs patch
Components: Distutils Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: tarek Nosy List: lacouture, mhammond, tarek, weck
Priority: normal Keywords:

Created on 2004-07-19 13:03 by mhammond, last changed 2010-08-19 15:26 by BreamoreBoy.

Messages (4)
msg60531 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2004-07-19 13:03
The following setup.py file:
"""
from distutils.core import setup, Extension
setup(name="foo", scripts= ["foo.py"])
"""
(plus any 'foo.py') fails when creating a .zip binary
on windows:

>setup.py bdist_dumb --relative
running bdist_dumb
...
error: build\bdist.win32\dumb\e:src\python-2.3-cvs:
Invalid argument
msg60532 - (view) Author: Patrice LACOUTURE (lacouture) Date: 2005-02-02 16:43
Logged In: YES 
user_id=1120079

It seems related to the function ensure_relative
(distutils/dir_utils.py, line 217), that keeps the drive
name in the relative path built.

>>> ensure_relative("C:\\Python24")
"C:Python24"

It is called by bdist_dumb to manage the relative path
properly, but fails so.

I can't guess what was the original intent (maybe for some
other OS, maybe just a simple error?), but the following
change seems to fix the issue:

$ diff --from-file=dir_util.old.py dir_util.py
226c226
<             path = drive + path[1:]
---
>             path = path[1:]

(just skip the drive name and the initial os.sep if any).

The ensure_relative() function is only used by bdist_dumb,
so I believe this change is safe, unless the "bogus" line
had some hidden intent I couldn't figure (other OS???).
msg60533 - (view) Author: Patrice LACOUTURE (lacouture) Date: 2005-02-02 17:16
Logged In: YES 
user_id=1120079

BTW, the patch shown in my previous comment applies to
distutils/dir_util.py from Python 2.4.

226c226
<             path = drive + path[1:]
---
>             path = path[1:]
msg68816 - (view) Author: zouguangxian (weck) Date: 2008-06-27 05:44
I encounter the same problem of Mark Hammond. I check the code in
repository, the ensure_relative function in python25 is:

def ensure_relative (path):
    """Take the full path 'path', and make it a relative path so
    it can be the second argument to os.path.join().
    """
    drive, path = os.path.splitdrive(path)
    if sys.platform == 'mac':
        return os.sep + path
    else:
        if path[0:1] == os.sep:
            path = drive + path[1:]
        return path

I also checked python24, and didn't find the code which described by 
Patrice LACOUTURE in msg60533 (view).
History
Date User Action Args
2010-08-19 15:26:51BreamoreBoysetstage: needs patch
type: behavior
versions: + Python 3.1, Python 2.7, Python 3.2
2009-02-11 02:55:24ajaksu2setassignee: tarek
nosy: + tarek
2008-06-27 05:44:26wecksetnosy: + weck
messages: + msg68816
2004-07-19 13:03:59mhammondcreate