Author christopher.hogan BreamoreBoy, PatriceL, christopher.hogan, dstufft, eric.araujo, lacouture, mhammond, tarek, weck 2015-08-21.18:16:12 -1.0 Yes <1440180974.59.0.501947164152.issue993766@psf.upfronthosting.co.za>
Content
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])
History
Date User Action Args
2015-08-21 18:16:14christopher.hogansetrecipients: + christopher.hogan, mhammond, weck, tarek, lacouture, eric.araujo, BreamoreBoy, dstufft, PatriceL
2015-08-21 18:16:14christopher.hogansetmessageid: <1440180974.59.0.501947164152.issue993766@psf.upfronthosting.co.za>