Skip to content

Commit 3b56ef8

Browse files
YannickJadoulCzaki
authored andcommitted
Moving MACOSX_DEPLOYMENT_TARGET from test utils' expected_wheels to run_cibuildwheel, and some minor style fixes
1 parent 8434f0c commit 3b56ef8

File tree

4 files changed

+48
-49
lines changed

4 files changed

+48
-49
lines changed

test/10_cpp_standards/cibuildwheel_test.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,55 @@
66
import utils
77

88

9+
project_dir = os.path.dirname(__file__)
10+
911
def test_cpp11(tmp_path):
10-
add_env = {"CIBW_SKIP": "cp27-win*", "CIBW_ENVIRONMENT": "STANDARD=11"}
11-
# VC for python 2.7 do not support modern standards
12-
if utils.platform == "macos":
13-
add_env["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
14-
project_dir = os.path.dirname(__file__)
15-
# this test checks if c++11 standard is supported.
12+
# This test checks that the C++11 standard is supported
13+
14+
add_env = {'CIBW_SKIP': 'cp27-win*', 'CIBW_ENVIRONMENT': 'STANDARD=11'}
15+
# VC++ for Python 2.7 does not support modern standards
16+
if utils.platform == 'macos':
17+
add_env['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
1618

1719
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
18-
expected_wheels = [x for x in utils.expected_wheels('spam', '0.1.0',
19-
macosx_deployment_target="10.9") if "cp27-cp27m-win" not in x]
20+
expected_wheels = [x for x in utils.expected_wheels(
21+
'spam', '0.1.0', macosx_deployment_target='10.9')
22+
if 'cp27-cp27m-win' not in x]
2023
assert set(actual_wheels) == set(expected_wheels)
2124

2225

2326
def test_cpp14():
24-
add_env = {"CIBW_SKIP": "cp27-win* cp35-win*", "CIBW_ENVIRONMENT": "STANDARD=14"}
25-
# VC for python 2.7 do not support modern standards
26-
# manylinux1 docker image do not support compilers with standards newer than c++11
27-
# python 3.4 and 3.5 are compiled with MSVC 10. which not support c++14
28-
if utils.platform == "macos":
29-
add_env["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
30-
project_dir = os.path.dirname(__file__)
31-
# this test checks if c++14 standard is supported.
27+
# This test checks that the C++14 standard is supported
28+
29+
add_env = {'CIBW_SKIP': 'cp27-win* cp35-win*', 'CIBW_ENVIRONMENT': 'STANDARD=14'}
30+
# VC++ for Python 2.7 does not support modern standards
31+
# The manylinux1 docker image does not have a compiler which supports C++11
32+
# Python 3.4 and 3.5 are compiled with MSVC 10, which does not support C++14
33+
if utils.platform == 'macos':
34+
add_env['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
3235

3336
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
3437
expected_wheels = [x for x in utils.expected_wheels(
35-
'spam', '0.1.0', macosx_deployment_target="10.9")
36-
if "cp27-cp27m-win" not in x and "cp35-cp35m-win" not in x]
38+
'spam', '0.1.0', macosx_deployment_target='10.9')
39+
if 'cp27-cp27m-win' not in x and 'cp35-cp35m-win' not in x]
3740
assert set(actual_wheels) == set(expected_wheels)
3841

42+
3943
def test_cpp17():
40-
# python 2.7 use `register` keyword which is forbidden in c++17 standard
41-
# manylinux1 docker image do not support compilers with standards newer than c++11
42-
# python 3.4 and 3.5 are compiled with MSVC 10. which not support c++17
43-
if os.environ.get("APPVEYOR_BUILD_WORKER_IMAGE", "") == "Visual Studio 2015":
44-
pytest.skip("Visual Studio 2015 does not support c++17")
44+
# This test checks that the C++17 standard is supported
4545

46-
add_env = {"CIBW_SKIP": "cp27-win* cp35-win*", "CIBW_ENVIRONMENT": "STANDARD=17"}
47-
if utils.platform == "macos":
48-
add_env["MACOSX_DEPLOYMENT_TARGET"] = "10.13"
46+
# Python 2.7 uses the `register` keyword which is forbidden in the C++17 standard
47+
# The manylinux1 docker image does not have a compiler which supports C++11
48+
# Python 3.4 and 3.5 are compiled with MSVC 10, which does not support C++17
49+
if os.environ.get('APPVEYOR_BUILD_WORKER_IMAGE', '') == 'Visual Studio 2015':
50+
pytest.skip('Visual Studio 2015 does not support C++17')
4951

50-
project_dir = os.path.dirname(__file__)
51-
# this test checks if c++17 standard is supported.
52+
add_env = {'CIBW_SKIP': 'cp27-win* cp35-win*', 'CIBW_ENVIRONMENT': 'STANDARD=17'}
53+
if utils.platform == 'macos':
54+
add_env['MACOSX_DEPLOYMENT_TARGET'] = '10.13'
5255

5356
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
54-
expected_wheels = [x for x in utils.expected_wheels('spam', '0.1.0',
55-
macosx_deployment_target="10.13")
56-
if "cp27-cp27m-win" not in x and "cp35-cp35m-win" not in x]
57+
expected_wheels = [x for x in utils.expected_wheels(
58+
'spam', '0.1.0', macosx_deployment_target='10.13')
59+
if 'cp27-cp27m-win' not in x and 'cp35-cp35m-win' not in x]
5760
assert set(actual_wheels) == set(expected_wheels)
58-

test/10_cpp_standards/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
language_standard = "/std:c++" + standard if platform.system() == "Windows" else "-std=c++" + standard
88

9-
extra_compile_args=[language_standard, "-DSTANDARD=" + standard]
9+
extra_compile_args = [language_standard, "-DSTANDARD=" + standard]
1010

1111
if standard == "17":
1212
if platform.system() == "Windows":

test/10_cpp_standards/spam.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#include <Python.h>
22
#include <string>
3+
4+
// Depending on the requested standard, use a modern C++ feature
5+
// that was introduced in that standard.
36
#if STANDARD == 11
4-
#include <array>
7+
#include <array>
58
#elif STANDARD == 14
6-
int a = 100'000;
9+
int a = 100'000;
710
#elif STANDARD == 17
8-
#include <utility>
9-
auto a = std::pair(5.0, false);
11+
#include <utility>
12+
auto a = std::pair(5.0, false);
1013
#else
11-
#error Standard needed
14+
#error Standard needed
1215
#endif
1316

14-
#define STR_HELPER(x) #x
15-
#define STR(x) STR_HELPER(x)
16-
1717
static PyObject *
1818
spam_system(PyObject *self, PyObject *args)
1919
{

test/shared/utils.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def cibuildwheel_run(project_path, env=None, add_env=None, output_dir=None):
5353
'''
5454
if env is None:
5555
env = os.environ.copy()
56+
# If present in the host environment, remove the MACOSX_DEPLOYMENT_TARGET for consistency
57+
env.pop('MACOSX_DEPLOYMENT_TARGET', None)
5658

5759
if add_env is not None:
5860
env.update(add_env)
@@ -94,20 +96,15 @@ def get_platform_tags(python_abi_tag):
9496
return ['win32', 'win_amd64']
9597

9698
elif platform == 'macos':
97-
if macosx_deployment_target is not None:
98-
tag = macosx_deployment_target.replace(".", "_")
99-
tag1 = macosx_deployment_target.replace(".", "_")
100-
else:
101-
tag = os.environ.get("MACOSX_DEPLOYMENT_TARGET", "10_6").replace(".", "_")
102-
tag1 = os.environ.get("MACOSX_DEPLOYMENT_TARGET", "10_9").replace(".", "_")
10399

104100
def get_platform_tags(python_abi_tag):
105101
if python_abi_tag == 'cp38-cp38':
106-
return ['macosx_' + tag1 + '_x86_64']
102+
return ['macosx_' + (macosx_deployment_target or "10.9").replace(".", "_") + '_x86_64']
107103
else:
108-
return ['macosx_' + tag + '_intel']
104+
return ['macosx_' + (macosx_deployment_target or "10.6").replace(".", "_") + '_intel']
109105
else:
110106
raise Exception('unsupported platform')
107+
111108
templates = []
112109
for python_abi_tag in python_abi_tags:
113110
for platform_tag in get_platform_tags(python_abi_tag):

0 commit comments

Comments
 (0)