This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: distutils chops the first character of filenames
Type: Stage:
Components: Distutils Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: draghuram, freecondiments, nnorwitz
Priority: normal Keywords:

Created on 2007-02-25 22:15 by freecondiments, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
setup.py freecondiments, 2007-02-25 22:15 example setup.py
Messages (6)
msg31353 - (view) Author: Sam Pointon (freecondiments) Date: 2007-02-25 22:15
Python 2.5c1, Windows XP SP2.

distutils chops the first character from some filenames if the package_data key is ''.

Minimal example:
The setup.py attached, and a directory named 'doc' in the same directory as setup.py with files in it. Running "python setup.py bdist" triggers the error.

On my box, this fails with:
running bdist
running bdist_dumb
running build
running build_py
error: can't copy 'oc\architecture.rst': doesn't exist or not a regular file

http://mail.python.org/pipermail/distutils-sig/2005-April/004453.html 
describes the same problem, and http://mail.python.org/pipermail/distutils-sig/2005-April/004458.html has a commentary on the code in distutils/commands/build_py.py which causes the error.

On lines 117-122, it tries to chop the directory path from the files it has found, using len() and slicing. This job is better done by os.path.split (and is probably more portable, too).
msg31354 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2007-03-27 16:19

Hi,

I reproduced the problem with the latest build on linux. The "fix" may be trivial but I am not entirely sure if there is a problem in the first place. The distutils document does not mention about having null value for package_dir as is the case in your setup.py. I may be missing something here but can you please explain the conclusion that "" is a perfectly valid value for package_dir (as mentioned in one of the threads in mailing list)? I am assuming that you mean "distribution root" directory by "". If this is found to be valid usage, the  document should be updated along with the code fix. Otherwise, a check can be put in to disallow null values. 

Raghu.


msg31355 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2007-05-16 15:47

After reading the distutils example section today, I did find one example using null string as package_dir value. So there may be something to this bug after all.
msg31356 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2007-05-17 18:21

It appears that I misunderstood the problem. Also, the attached setup.py has a typo. Instead of

package_data = {'': ['doc/*']}

it should read

package_data = {'foobar': ['doc/*']}

Any way, I reproduced the problem and created a patch (1720897).
msg31357 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-06-01 07:32
Committed revision 55731. (2.6)
Still needs to be backported.
msg31358 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-06-02 18:53
Committed revision 55747. (2.5)
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44618
2007-02-25 22:15:20freecondimentscreate