Skip to content

Commit 67c2c11

Browse files
committed
Allow to run mach with Python3 (>=3.5)
1 parent 01c1a6c commit 67c2c11

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

mach

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import sys
1818
# Check for the current python version as some users (especially on archlinux)
1919
# may not have python 2 installed and their /bin/python binary symlinked to
2020
# python 3.
21-
if sys.version_info >= (3, 0):
22-
print("mach does not support python 3, please install python 2")
21+
if sys.version_info >= (3, 0) and sys.version_info < (3, 5):
22+
print("mach does not support python 3 (< 3.5), please install python 2 or python 3 (>= 3.5)")
2323
sys.exit(1)
2424
2525

python/mach_bootstrap.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ def bootstrap(topdir):
256256
# We don't support paths with Unicode characters for now
257257
# https://github.com/servo/servo/issues/10002
258258
try:
259-
topdir.decode('ascii')
259+
# Trick to support both python2 and python3
260+
topdir.encode().decode('ascii')
260261
except UnicodeDecodeError:
261262
print('Cannot run mach in a path with Unicode characters.')
262263
print('Current path:', topdir)
@@ -269,10 +270,10 @@ def bootstrap(topdir):
269270
print('Current path:', topdir)
270271
sys.exit(1)
271272

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

0 commit comments

Comments
 (0)