Mercurial > hg
diff setup.py @ 44080:4e05272dd681
packaging: leverage os.path.relpath() in setup.py
`os.path.relpath()` has existed since Python 2.6, so we can safely use
it. This fixes a bug in the current code when the common prefix is "/"
(in which case `uplevel` would be one less than it should).
Differential Revision: https://phab.mercurial-scm.org/D7875
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 14 Jan 2020 14:18:11 -0800 |
parents | bde1cd4c99d9 |
children | e1b8b4e4f496 |
line wrap: on
line diff
--- a/setup.py Tue Jan 14 18:00:05 2020 +0100 +++ b/setup.py Tue Jan 14 14:18:11 2020 -0800 @@ -1064,11 +1064,7 @@ # absolute path instead libdir = self.install_lib else: - common = os.path.commonprefix((self.install_dir, self.install_lib)) - rest = self.install_dir[len(common) :] - uplevel = len([n for n in os.path.split(rest) if n]) - - libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common) :] + libdir = os.path.relpath(self.install_lib, self.install_dir) for outfile in self.outfiles: with open(outfile, 'rb') as fp: