From 4a0d05df493f7f4bfe9c3c39ed281995e0ce4d99 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Wed, 4 Jul 2018 15:56:12 +0100 Subject: [PATCH 1/5] macOS: run test_command in shell Fixes https://github.com/joerick/cibuildwheel/issues/39. --- cibuildwheel/macos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index e743c6f5..a1239261 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -128,7 +128,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # (this ensures that Python runs the tests against the installed wheel # and not the repo code) test_command_prepared = prepare_command(test_command, project=abs_project_dir) - call(shlex.split(test_command_prepared), cwd=os.environ['HOME'], env=env) + call(test_command_prepared, cwd=os.environ['HOME'], env=env, shell=True) # we're all done here; move it to output shutil.move(delocated_wheel, output_dir) From b18281867bdbceb7a09b0d11141c195e0b461fb6 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Thu, 5 Jul 2018 09:28:44 +0100 Subject: [PATCH 2/5] Add test for CIBW_TEST_COMMAND running in a shell on mac and linux --- test/02_test/environment.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/02_test/environment.json b/test/02_test/environment.json index a9b6ac2b..3a541dd4 100644 --- a/test/02_test/environment.json +++ b/test/02_test/environment.json @@ -1,4 +1,6 @@ { "CIBW_TEST_REQUIRES": "nose", - "CIBW_TEST_COMMAND": "nosetests {project}/test" + "CIBW_TEST_COMMAND": "false || nosetests {project}/test", + "comment": "The 'false ||' bit is to ensure this command runs in a shell on Mac and Linux", + "CIBW_TEST_COMMAND_WINDOWS": "nosetests {project}/test" } From ea3c52631fa16f495737814173abb265127fe815 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Thu, 5 Jul 2018 09:58:05 +0100 Subject: [PATCH 3/5] Add platform-specific CIBW_TEST_COMMAND and CIBW_TEST_REQUIRES variants --- cibuildwheel/__main__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 775a20e2..1a9e3c5e 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -6,7 +6,7 @@ import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos from cibuildwheel.environment import parse_environment, EnvironmentParseError from cibuildwheel.util import BuildSkipper -def get_option_from_environment(option_name, platform=None): +def get_option_from_environment(option_name, platform=None, default=None): ''' Returns an option from the environment, optionally scoped by the platform. @@ -21,7 +21,7 @@ def get_option_from_environment(option_name, platform=None): if option is not None: return option - return os.environ.get(option_name) + return os.environ.get(option_name, default) def main(): @@ -70,13 +70,13 @@ def main(): exit(2) output_dir = args.output_dir - test_command = os.environ.get('CIBW_TEST_COMMAND', None) - test_requires = os.environ.get('CIBW_TEST_REQUIRES', '').split() + test_command = get_option_from_environment('CIBW_TEST_COMMAND', platform=platform) + test_requires = get_option_from_environment('CIBW_TEST_REQUIRES', platform=platform, default='').split() project_dir = args.project_dir before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform) - build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform) or '' + build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='') skip_config = os.environ.get('CIBW_SKIP', '') - environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform) or '' + environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='') try: build_verbosity = min(3, max(-3, int(build_verbosity))) From 5c47700d315161c4f40a900e7ad90557a33f0998 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 10 Jul 2018 18:44:27 +0100 Subject: [PATCH 4/5] Add platform-specific notes to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 5d818c5f..817d5c47 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,9 @@ Shell command to run tests after the build. The wheel will be installed automati Example: `nosetests {project}/tests` +Platform-specific variants also available: +`CIBW_TEST_COMMAND_MACOS` | `CIBW_TEST_COMMAND_WINDOWS` | `CIBW_TEST_COMMAND_LINUX` + | Environment variable: `CIBW_TEST_REQUIRES` | --- @@ -248,6 +251,9 @@ Space-separated list of dependencies required for running the tests. Example: `pytest` Example: `nose==1.3.7 moto==0.4.31` +Platform-specific variants also available: +`CIBW_TEST_REQUIRES_MACOS` | `CIBW_TEST_REQUIRES_WINDOWS` | `CIBW_TEST_REQUIRES_LINUX` + -- #### Example YML syntax From 0789842ef089e51b2ee8cb1c012b0a8b599d63fa Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 10 Jul 2018 18:46:10 +0100 Subject: [PATCH 5/5] Add note about shell use on mac and linux --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 817d5c47..840266cc 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,8 @@ Optional. Shell command to run tests after the build. The wheel will be installed automatically and available for import from the tests. `{project}` can be used as a placeholder for the absolute path to the project's root and will be replaced by `cibuildwheel`. +On Linux and Mac, the command runs in a shell, so you can write things like `cmd1 && cmd2`. + Example: `nosetests {project}/tests` Platform-specific variants also available: