Chris Hogan added the comment:

I think ensure_relative is incorrect. The comment in the function states:

 "Take the full path 'path', and make it a relative path. This is useful to 
make 'path' the second argument to os.path.join()."

However, according to the docs for os.path.join, if a component contains a 
drive letter, all previous components are thrown away and the drive letter is 
reset.  This makes the result from ensure_relative a poor candidate as a 
"second argument to os.path.join" on Windows because it will always contain a 
drive letter which will always wipe out the first argument.

>>> os.path.join('bar', 'c:foo')
'c:foo'

This is what happens when I try to build a simple distro with the command 
python setup.py bdist_dumb --relative. In 
Lib/distutils/command/bdist_dumb.py:bdist_dumb.run:

archive_root = os.path.join(self.bdist_dir, 
ensure_relative(install.install_base))

the call is

>>> os.path.join('build\\bdist.win-amd64\\dumb', 'C:path\\to\\python')
'C:path\\to\\python'

It seems to me that the intention is to return

'build\\bdist.win-amd64\\dumb\\path\\to\\python27'

Later in distutils.archive_util.make_archive, it tries to os.chdir into 
'C:path\\to\\python', which it can't do because that's not an absolute path 
(it's missing a '\' after 'C:').
As far as I can tell, the only thing the --relative flag does is to append the 
python install path onto the build location and build the archive there. 
However, this build location is temporary and gets deleted at the end of the 
process, so I don't really see the point.

I think there are two options here: 
1) Get rid of ensure_relative and do it like this:

archive_root = os.path.join(self.bdist_dir, 
os.path.splitdrive(install.install_base)[1].lstrip(os.sep))

This is the only place ensure_relative is ever used anyway.

2) Keep ensure_relative and do it like this:

archive_root = os.path.join(self.bdist_dir, 
os.path.splitdrive(ensure_relative(install.install_base))[1])

----------
nosy: +christopher.hogan

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue993766>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to