Author christopher.hogan
Recipients BreamoreBoy, PatriceL, christopher.hogan, dstufft, eric.araujo, lacouture, mhammond, tarek, weck
Date 2015-08-21.18:16:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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')

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

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

the call is

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

It seems to me that the intention is to return


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])
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: <>
2015-08-21 18:16:14christopher.hoganlinkissue993766 messages
2015-08-21 18:16:12christopher.hogancreate