Patchwork D10502: packaging: extract pre-computed version when running from plain tarball

login
register
mail settings
Submitter phabricator
Date April 20, 2021, 6:36 p.m.
Message ID <differential-rev-PHID-DREV-lnv5nqjhf44rdatdby7w-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48819/
State Superseded
Headers show

Comments

phabricator - April 20, 2021, 6:36 p.m.
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The tarballs created by setup.py are not including the usual archive
  markers as `hg export` leaves, so the rewrite of the version number
  computation actually left the empty version string around. This meant
  that installations from PyPI would use 0.0.0 as version string.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  setup.py

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -437,6 +437,9 @@ 
             version = '%(latesttag)s+hg%(latesttagdistance)s.%(node).12s' % kw
     else:
         version = '0+hg' + kw.get('node', '')[:12]
+elif os.path.exists('mercurial/__version__.py'):
+    data = open('mercurial/__version__.py').read()
+    version = re.search('version = b"(.*)"', data).group(1)
 
 if version:
     versionb = version