Patchwork D7875: packaging: leverage os.path.relpath() in setup.py

login
register
mail settings
Submitter phabricator
Date Jan. 15, 2020, 1:17 p.m.
Message ID <17e2e307297459ee7ddc3e159d6b95ee@localhost.localdomain>
Download mbox | patch
Permalink /patch/44360/
State Not Applicable
Headers show

Comments

phabricator - Jan. 15, 2020, 1:17 p.m.
Closed by commit rHG4e05272dd681: packaging: leverage os.path.relpath() in setup.py (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7875?vs=19268&id=19286

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7875/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7875

AFFECTED FILES
  setup.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -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: