D3958: Allow to run setup.py with python 3 without a mercurial checkout
glandium (Mike Hommey)
phabricator at mercurial-scm.org
Tue Jul 17 00:43:11 UTC 2018
glandium created this revision.
glandium added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Some people may want to test mercurial in a python 3 environment through e.g. pip, in which case setup.py doesn't run in a mercurial checkout, so the hack in setup.py to allow python 3 cannot be overcome.
This change allows a manual override with the HGPYTHON3 environment variable.
Additionally, when for some reason the version is unknown (for crazy people like me, who have a git checkout of the mercurial repo), the version variable ends up being an unicode string, which fails the `isinstance(version, bytes)` assertion. So fix that at the same time.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3958
AFFECTED FILES
setup.py
CHANGE DETAILS
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -74,7 +74,7 @@
badpython = True
# Allow Python 3 from source checkouts.
- if os.path.isdir('.hg'):
+ if os.path.isdir('.hg') or 'HGPYTHON3' in os.environ:
badpython = False
if badpython:
@@ -369,7 +369,7 @@
from mercurial import __version__
version = __version__.version
except ImportError:
- version = 'unknown'
+ version = b'unknown'
finally:
if oldpolicy is None:
del os.environ['HGMODULEPOLICY']
To: glandium, indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list