Add migration for build identifier change, and test for migration
This commit is contained in:
@@ -198,15 +198,18 @@ def detect_obsolete_options():
|
||||
print("Option '{}' is not empty. Please unset '{}'".format(alternative, deprecated))
|
||||
exit(2)
|
||||
|
||||
# Check for 'manylinux1' in the 'CIBW_BUILD' and 'CIBW_SKIP' options
|
||||
for deprecated in ['CIBW_BUILD', 'CIBW_SKIP']:
|
||||
if deprecated in os.environ and 'manylinux1' in os.environ[deprecated]:
|
||||
print("Build identifiers with 'manylinux1' have been deprecated. Replacing all occurences of 'manylinux1' by 'manylinux' in the option '{}'".format(deprecated))
|
||||
os.environ[deprecated] = os.environ[deprecated].replace('manylinux1', 'manylinux')
|
||||
if deprecated in os.environ and ("macosx_10_6" in os.environ[deprecated] or "macosx_10_9" in os.environ[deprecated]):
|
||||
print("Build identifiers with 'macosx_10_6' or 'macosx_10_9' have been deprecated. Replacing all occurences with 'macosx' in the option '{}'".format(deprecated))
|
||||
os.environ[deprecated] = os.environ[deprecated].replace('macosx_10_6', 'macosx').replace('macosx_10_9', 'macosx')
|
||||
|
||||
# Check for deprecated identifiers in 'CIBW_BUILD' and 'CIBW_SKIP' options
|
||||
for option in ['CIBW_BUILD', 'CIBW_SKIP']:
|
||||
for deprecated, alternative in [('manylinux1', 'manylinux'),
|
||||
('macosx_10_6_intel', 'macosx_x86_64'),
|
||||
('macosx_10_9_x86_64', 'macosx_x86_64')]:
|
||||
if option in os.environ and deprecated in os.environ[option]:
|
||||
print("Build identifiers with '{deprecated}' have been deprecated. Replacing all occurences of '{deprecated}' with '{alternative}' in the option '{option}'".format(
|
||||
deprecated=deprecated,
|
||||
alternative=alternative,
|
||||
option=option,
|
||||
))
|
||||
os.environ[option] = os.environ[option].replace(deprecated, alternative)
|
||||
|
||||
def print_preamble(platform, build_options):
|
||||
print(textwrap.dedent('''
|
||||
|
||||
@@ -204,3 +204,26 @@ def test_build_verbosity(build_verbosity, platform_specific, platform, intercept
|
||||
|
||||
expected_verbosity = max(-3, min(3, int(build_verbosity or 0)))
|
||||
assert intercepted_build_args.kwargs['build_verbosity'] == expected_verbosity
|
||||
|
||||
|
||||
@pytest.mark.parametrize('option_name', ['CIBW_BUILD', 'CIBW_SKIP'])
|
||||
@pytest.mark.parametrize('option_value, build_selector_patterns', [
|
||||
('*-manylinux1_*', ['*-manylinux_*']),
|
||||
('*-macosx_10_6_intel', ['*-macosx_x86_64']),
|
||||
('*-macosx_10_9_x86_64', ['*-macosx_x86_64']),
|
||||
('cp37-macosx_10_9_x86_64', ['cp37-macosx_x86_64']),
|
||||
])
|
||||
def test_build_selector_migrations(intercepted_build_args, monkeypatch, option_name, option_value, build_selector_patterns):
|
||||
monkeypatch.setenv(option_name, option_value)
|
||||
|
||||
main()
|
||||
|
||||
intercepted_build_selector = intercepted_build_args.kwargs['build_selector']
|
||||
assert isinstance(intercepted_build_selector, BuildSelector)
|
||||
|
||||
if option_name == 'CIBW_BUILD':
|
||||
assert intercepted_build_selector.build_patterns == build_selector_patterns
|
||||
else:
|
||||
assert intercepted_build_selector.skip_patterns == build_selector_patterns
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user