From f1a2390f3e986ee1ea53f00e17bd704c8f27ae2f Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Wed, 29 Dec 2021 18:22:10 -0600 Subject: [PATCH] Fix shell syntax in build_wheel Follow up to #11872 The cross repo split makes this a bit of a pain to test. --- misc/build_wheel.py | 13 +++++++++---- mypyc/test/config.py | 12 ++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/misc/build_wheel.py b/misc/build_wheel.py index 4738115aae26..b124a11d8c95 100644 --- a/misc/build_wheel.py +++ b/misc/build_wheel.py @@ -75,9 +75,14 @@ def create_environ(python_version: str) -> Dict[str, str]: # lxml doesn't have a wheel for Python 3.10 on the manylinux image we use. # lxml has historically been slow to support new Pythons as well. - env['CIBW_BEFORE_TEST'] = ( - 'pip install -r <(grep -v lxml {project}/mypy/test-requirements.txt)' - ) + env['CIBW_BEFORE_TEST'] = """ + ( + grep -v lxml {project}/mypy/test-requirements.txt > /tmp/test-requirements.txt + && cp {project}/mypy/mypy-requirements.txt /tmp/mypy-requirements.txt + && cp {project}/mypy/build-requirements.txt /tmp/build-requirements.txt + && pip install -r /tmp/test-requirements.txt + ) + """.replace('\n', ' ') # pytest looks for configuration files in the parent directories of where the tests live. # since we are trying to run the tests from their installed location, we copy those into @@ -94,7 +99,7 @@ def create_environ(python_version: str) -> Dict[str, str]: && MYPY_TEST_PREFIX='{project}/mypy' pytest $MYPY_TEST_DIR -k 'not (reports.test or testreports)' && MYPYC_TEST_DIR=$(python -c 'import mypyc.test; print(mypyc.test.__path__[0])') - && pytest $MYPYC_TEST_DIR -k 'not test_external' + && MYPY_TEST_PREFIX='{project}/mypy' pytest $MYPYC_TEST_DIR -k 'not test_external' ) """.replace('\n', ' ') diff --git a/mypyc/test/config.py b/mypyc/test/config.py index 6b2c09d1ebfb..1158c5c459be 100644 --- a/mypyc/test/config.py +++ b/mypyc/test/config.py @@ -1,7 +1,11 @@ import os -this_file_dir = os.path.dirname(os.path.realpath(__file__)) -prefix = os.path.dirname(os.path.dirname(this_file_dir)) +provided_prefix = os.getenv('MYPY_TEST_PREFIX', None) +if provided_prefix: + PREFIX = provided_prefix +else: + this_file_dir = os.path.dirname(os.path.realpath(__file__)) + PREFIX = os.path.dirname(os.path.dirname(this_file_dir)) -# Locations of test data files such as test case descriptions (.test). -test_data_prefix = os.path.join(prefix, 'mypyc', 'test-data') +# Location of test data files such as test case descriptions. +test_data_prefix = os.path.join(PREFIX, 'mypyc', 'test-data')