Skip to content

Commit

Permalink
Allow to run mach with Python3 (>=3.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Dec 9, 2019
1 parent 01c1a6c commit 67c2c11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mach
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import sys
# Check for the current python version as some users (especially on archlinux)
# may not have python 2 installed and their /bin/python binary symlinked to
# python 3.
if sys.version_info >= (3, 0):
print("mach does not support python 3, please install python 2")
if sys.version_info >= (3, 0) and sys.version_info < (3, 5):
print("mach does not support python 3 (< 3.5), please install python 2 or python 3 (>= 3.5)")
sys.exit(1)
Expand Down
9 changes: 5 additions & 4 deletions python/mach_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ def bootstrap(topdir):
# We don't support paths with Unicode characters for now
# https://github.com/servo/servo/issues/10002
try:
topdir.decode('ascii')
# Trick to support both python2 and python3
topdir.encode().decode('ascii')
except UnicodeDecodeError:
print('Cannot run mach in a path with Unicode characters.')
print('Current path:', topdir)
Expand All @@ -269,10 +270,10 @@ def bootstrap(topdir):
print('Current path:', topdir)
sys.exit(1)

# Ensure we are running Python 2.7+. We put this check here so we generate a
# Ensure we are running Python 2.7+ or Python 3.5+. We put this check here so we generate a
# user-friendly error message rather than a cryptic stack trace on module import.
if not (3, 0) > sys.version_info >= (2, 7):
print('Python 2.7 or above (but not Python 3) is required to run mach.')
if sys.version_info < (2, 7) or (sys.version_info >= (3, 0) and sys.version_info < (3, 5)):
print('Python2 (>=2.7) or Python3 (>=3.5) is required to run mach.')
print('You are running Python', platform.python_version())
sys.exit(1)

Expand Down

0 comments on commit 67c2c11

Please sign in to comment.