Skip to content

Commit 23ccb3e

Browse files
blazewiczdpgeorge
authored andcommitted
tools/gen-cpydiff.py: configurable CPython and micropython executables
1 parent ae116c2 commit 23ccb3e

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

tools/gen-cpydiff.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,18 @@
3333
import re
3434
from collections import namedtuple
3535

36+
# Micropython supports syntax of CPython 3.4 with some features from 3.5, and
37+
# such version should be used to test for differences. If your default python3
38+
# executable is of lower version, you can point MICROPY_CPYTHON3 environment var
39+
# to the correct executable.
40+
if os.name == 'nt':
41+
CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3.exe')
42+
MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../windows/micropython.exe')
43+
else:
44+
CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3')
45+
MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../unix/micropython')
46+
3647
TESTPATH = '../tests/cpydiff/'
37-
UPYPATH = '../unix/micropython'
3848
DOCPATH = '../docs/genrst/'
3949
INDEXTEMPLATE = '../docs/differences/index_template.txt'
4050
INDEX = 'index.rst'
@@ -84,10 +94,10 @@ def run_tests(tests):
8494
input_cpy = f.read()
8595
input_upy = uimports(input_cpy)
8696

87-
process = subprocess.Popen('python', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
97+
process = subprocess.Popen(CPYTHON3, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
8898
output_cpy = [com.decode('utf8') for com in process.communicate(input_cpy)]
8999

90-
process = subprocess.Popen(UPYPATH, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
100+
process = subprocess.Popen(MICROPYTHON, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
91101
output_upy = [com.decode('utf8') for com in process.communicate(input_upy)]
92102

93103
if output_cpy[0] == output_upy[0] and output_cpy[1] == output_upy[1]:

0 commit comments

Comments
 (0)