style: second set of updates (#651)
* style: second set of updates * style: more updates from joerick Co-authored-by: Joe Rickerby <joerick@mac.com> Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
co-authored by
Joe Rickerby
parent
38ae494c0d
commit
dff3aca4b6
@@ -19,7 +19,7 @@ repos:
|
|||||||
- id: isort
|
- id: isort
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 21.4b0
|
rev: 21.4b1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
files: ^bin/update_pythons.py|setup.py$
|
files: ^bin/update_pythons.py|setup.py$
|
||||||
|
|||||||
@@ -73,19 +73,22 @@ def main() -> None:
|
|||||||
Python. Default: auto.
|
Python. Default: auto.
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
arch_list_str = ", ".join(a.name for a in Architecture)
|
||||||
parser.add_argument('--archs',
|
parser.add_argument('--archs',
|
||||||
default=None,
|
default=None,
|
||||||
help='''
|
help=f'''
|
||||||
Comma-separated list of CPU architectures to build for.
|
Comma-separated list of CPU architectures to build for.
|
||||||
When set to 'auto', builds the architectures natively supported
|
When set to 'auto', builds the architectures natively supported
|
||||||
on this machine. Set this option to build an architecture
|
on this machine. Set this option to build an architecture
|
||||||
via emulation, for example, using binfmt_misc and QEMU.
|
via emulation, for example, using binfmt_misc and QEMU.
|
||||||
Default: auto.
|
Default: auto.
|
||||||
Choices: auto, auto64, auto32, native, all, {}
|
Choices: auto, auto64, auto32, native, all, {arch_list_str}
|
||||||
'''.format(", ".join(a.name for a in Architecture)))
|
''')
|
||||||
|
|
||||||
parser.add_argument('--output-dir',
|
parser.add_argument('--output-dir',
|
||||||
default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),
|
default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),
|
||||||
help='Destination folder for the wheels.')
|
help='Destination folder for the wheels.')
|
||||||
|
|
||||||
parser.add_argument('package_dir',
|
parser.add_argument('package_dir',
|
||||||
default='.',
|
default='.',
|
||||||
nargs='?',
|
nargs='?',
|
||||||
@@ -99,6 +102,7 @@ def main() -> None:
|
|||||||
parser.add_argument('--print-build-identifiers',
|
parser.add_argument('--print-build-identifiers',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Print the build identifiers matched by the current invocation and exit.')
|
help='Print the build identifiers matched by the current invocation and exit.')
|
||||||
|
|
||||||
parser.add_argument('--allow-empty',
|
parser.add_argument('--allow-empty',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Do not report an error code if the build does not match any wheels.')
|
help='Do not report an error code if the build does not match any wheels.')
|
||||||
@@ -368,7 +372,12 @@ def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]:
|
|||||||
option_value = getattr(build_options, option_name)
|
option_value = getattr(build_options, option_name)
|
||||||
|
|
||||||
if option_value and ('{python}' in option_value or '{pip}' in option_value):
|
if option_value and ('{python}' in option_value or '{pip}' in option_value):
|
||||||
warnings.append(option_name + ": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.")
|
# Reminder: in an f-string, double braces means literal single brace
|
||||||
|
msg = (
|
||||||
|
f"{option_name}: '{{python}}' and '{{pip}}' are no longer needed, "
|
||||||
|
"and will be removed in a future release. Simply use 'python' or 'pip' instead."
|
||||||
|
)
|
||||||
|
warnings.append(msg)
|
||||||
|
|
||||||
return warnings
|
return warnings
|
||||||
|
|
||||||
|
|||||||
@@ -58,9 +58,8 @@ def evaluate_word_node(node: bashlex.ast.node, context: NodeExecutionContext) ->
|
|||||||
|
|
||||||
if part_string not in value:
|
if part_string not in value:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
'bash parse failed. part "{}" not found in "{}". Word was "{}". Full input was "{}"'.format(
|
f'bash parse failed. part "{part_string}" not found in "{value}". '
|
||||||
part_string, value, node.word, context.input,
|
f'Word was "{node.word}". Full input was "{context.input}"'
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
value = value.replace(part_string, part_value, 1)
|
value = value.replace(part_string, part_value, 1)
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ class DockerContainer:
|
|||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
'docker', 'create',
|
'docker', 'create',
|
||||||
'--env', 'CIBUILDWHEEL',
|
'--env=CIBUILDWHEEL',
|
||||||
'--name', self.name,
|
f'--name={self.name}',
|
||||||
'-i',
|
'--interactive',
|
||||||
'-v', '/:/host', # ignored on CircleCI
|
'--volume=/:/host', # ignored on CircleCI
|
||||||
*cwd_args,
|
*cwd_args,
|
||||||
self.docker_image,
|
self.docker_image,
|
||||||
*shell_args
|
*shell_args
|
||||||
@@ -169,13 +169,15 @@ class DockerContainer:
|
|||||||
while True:
|
while True:
|
||||||
line = self.bash_stdout.readline()
|
line = self.bash_stdout.readline()
|
||||||
|
|
||||||
if line.endswith(b'%s\n' % (bytes(end_of_message, encoding='utf8'))):
|
if line.endswith(bytes(end_of_message, encoding='utf8') + b'\n'):
|
||||||
|
# fmt: off
|
||||||
footer_offset = (
|
footer_offset = (
|
||||||
len(line)
|
len(line)
|
||||||
- 1 # newline character
|
- 1 # newline character
|
||||||
- len(end_of_message) # delimiter
|
- len(end_of_message) # delimiter
|
||||||
- 4 # 4 returncode decimals
|
- 4 # 4 returncode decimals
|
||||||
)
|
)
|
||||||
|
# fmt: on
|
||||||
returncode_str = line[footer_offset:footer_offset+4]
|
returncode_str = line[footer_offset:footer_offset+4]
|
||||||
returncode = int(returncode_str)
|
returncode = int(returncode_str)
|
||||||
# add the last line to output, without the footer
|
# add the last line to output, without the footer
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class PythonConfiguration(NamedTuple):
|
|||||||
|
|
||||||
def get_python_configurations(
|
def get_python_configurations(
|
||||||
build_selector: BuildSelector,
|
build_selector: BuildSelector,
|
||||||
architectures: Set[Architecture]
|
architectures: Set[Architecture],
|
||||||
) -> List[PythonConfiguration]:
|
) -> List[PythonConfiguration]:
|
||||||
|
|
||||||
full_python_configs = read_python_configs('linux')
|
full_python_configs = read_python_configs('linux')
|
||||||
@@ -159,7 +159,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
docker.call([
|
docker.call([
|
||||||
'pip', 'wheel',
|
'pip', 'wheel',
|
||||||
container_package_dir,
|
container_package_dir,
|
||||||
'-w', built_wheel_dir,
|
'--wheel-dir', built_wheel_dir,
|
||||||
'--no-deps',
|
'--no-deps',
|
||||||
*get_build_verbosity_extra_flags(options.build_verbosity)
|
*get_build_verbosity_extra_flags(options.build_verbosity)
|
||||||
], env=env)
|
], env=env)
|
||||||
|
|||||||
+18
-12
@@ -233,6 +233,9 @@ def setup_python(python_configuration: PythonConfiguration,
|
|||||||
# inconsistencies if it's left unset.
|
# inconsistencies if it's left unset.
|
||||||
env.setdefault('MACOSX_DEPLOYMENT_TARGET', '10.9')
|
env.setdefault('MACOSX_DEPLOYMENT_TARGET', '10.9')
|
||||||
|
|
||||||
|
config_is_arm64 = python_configuration.identifier.endswith('arm64')
|
||||||
|
config_is_universal2 = python_configuration.identifier.endswith('universal2')
|
||||||
|
|
||||||
if python_configuration.version == '3.5':
|
if python_configuration.version == '3.5':
|
||||||
# Cross-compilation platform override - CPython 3.5 has an
|
# Cross-compilation platform override - CPython 3.5 has an
|
||||||
# i386/x86_64 version of Python, but we only want a x64_64 build
|
# i386/x86_64 version of Python, but we only want a x64_64 build
|
||||||
@@ -246,18 +249,18 @@ def setup_python(python_configuration: PythonConfiguration,
|
|||||||
# compatible back to 10.9.
|
# compatible back to 10.9.
|
||||||
env.setdefault('_PYTHON_HOST_PLATFORM', 'macosx-10.9-x86_64')
|
env.setdefault('_PYTHON_HOST_PLATFORM', 'macosx-10.9-x86_64')
|
||||||
env.setdefault('ARCHFLAGS', '-arch x86_64')
|
env.setdefault('ARCHFLAGS', '-arch x86_64')
|
||||||
elif python_configuration.identifier.endswith('arm64'):
|
elif config_is_arm64:
|
||||||
# macOS 11 is the first OS with arm64 support, so the wheels
|
# macOS 11 is the first OS with arm64 support, so the wheels
|
||||||
# have that as a minimum.
|
# have that as a minimum.
|
||||||
env.setdefault('_PYTHON_HOST_PLATFORM', 'macosx-11.0-arm64')
|
env.setdefault('_PYTHON_HOST_PLATFORM', 'macosx-11.0-arm64')
|
||||||
env.setdefault('ARCHFLAGS', '-arch arm64')
|
env.setdefault('ARCHFLAGS', '-arch arm64')
|
||||||
elif python_configuration.identifier.endswith('universal2'):
|
elif config_is_universal2:
|
||||||
if get_macos_version() < (10, 16):
|
if get_macos_version() < (10, 16):
|
||||||
# we can do universal2 builds on macos 10.15, but we need to
|
# we can do universal2 builds on macos 10.15, but we need to
|
||||||
# set ARCHFLAGS otherwise CPython sets it to `-arch x86_64`
|
# set ARCHFLAGS otherwise CPython sets it to `-arch x86_64`
|
||||||
env.setdefault('ARCHFLAGS', '-arch arm64 -arch x86_64')
|
env.setdefault('ARCHFLAGS', '-arch arm64 -arch x86_64')
|
||||||
|
|
||||||
building_arm64 = python_configuration.identifier.endswith('arm64') or python_configuration.identifier.endswith('universal2')
|
building_arm64 = config_is_arm64 or config_is_universal2
|
||||||
if building_arm64 and get_macos_version() < (10, 16) and 'SDKROOT' not in env:
|
if building_arm64 and get_macos_version() < (10, 16) and 'SDKROOT' not in env:
|
||||||
# xcode 12.2 or higher can build arm64 on macos 10.15 or below, but
|
# xcode 12.2 or higher can build arm64 on macos 10.15 or below, but
|
||||||
# needs the correct SDK selected.
|
# needs the correct SDK selected.
|
||||||
@@ -299,6 +302,9 @@ def build(options: BuildOptions) -> None:
|
|||||||
for config in python_configurations:
|
for config in python_configurations:
|
||||||
log.build_start(config.identifier)
|
log.build_start(config.identifier)
|
||||||
|
|
||||||
|
config_is_arm64 = config.identifier.endswith('arm64')
|
||||||
|
config_is_universal2 = config.identifier.endswith('universal2')
|
||||||
|
|
||||||
dependency_constraint_flags: Sequence[PathOrStr] = []
|
dependency_constraint_flags: Sequence[PathOrStr] = []
|
||||||
if options.dependency_constraints:
|
if options.dependency_constraints:
|
||||||
dependency_constraint_flags = [
|
dependency_constraint_flags = [
|
||||||
@@ -322,7 +328,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
call([
|
call([
|
||||||
'pip', 'wheel',
|
'pip', 'wheel',
|
||||||
options.package_dir.resolve(),
|
options.package_dir.resolve(),
|
||||||
'-w', built_wheel_dir,
|
'--wheel-dir', built_wheel_dir,
|
||||||
'--no-deps',
|
'--no-deps',
|
||||||
*get_build_verbosity_extra_flags(options.build_verbosity)
|
*get_build_verbosity_extra_flags(options.build_verbosity)
|
||||||
], env=env)
|
], env=env)
|
||||||
@@ -339,9 +345,9 @@ def build(options: BuildOptions) -> None:
|
|||||||
if options.repair_command:
|
if options.repair_command:
|
||||||
log.step('Repairing wheel...')
|
log.step('Repairing wheel...')
|
||||||
|
|
||||||
if config.identifier.endswith('universal2'):
|
if config_is_universal2:
|
||||||
delocate_archs = 'x86_64,arm64'
|
delocate_archs = 'x86_64,arm64'
|
||||||
elif config.identifier.endswith('arm64'):
|
elif config_is_arm64:
|
||||||
delocate_archs = 'arm64'
|
delocate_archs = 'arm64'
|
||||||
else:
|
else:
|
||||||
delocate_archs = 'x86_64'
|
delocate_archs = 'x86_64'
|
||||||
@@ -364,28 +370,28 @@ def build(options: BuildOptions) -> None:
|
|||||||
machine_arch = platform.machine()
|
machine_arch = platform.machine()
|
||||||
testing_archs: List[Literal['x86_64', 'arm64']] = []
|
testing_archs: List[Literal['x86_64', 'arm64']] = []
|
||||||
|
|
||||||
if config.identifier.endswith('_arm64'):
|
if config_is_arm64:
|
||||||
testing_archs = ['arm64']
|
testing_archs = ['arm64']
|
||||||
elif config.identifier.endswith('_universal2'):
|
elif config_is_universal2:
|
||||||
testing_archs = ['x86_64', 'arm64']
|
testing_archs = ['x86_64', 'arm64']
|
||||||
else:
|
else:
|
||||||
testing_archs = ['x86_64']
|
testing_archs = ['x86_64']
|
||||||
|
|
||||||
for testing_arch in testing_archs:
|
for testing_arch in testing_archs:
|
||||||
if config.identifier.endswith('_universal2'):
|
if config_is_universal2:
|
||||||
arch_specific_identifier = f'{config.identifier}:{testing_arch}'
|
arch_specific_identifier = f'{config.identifier}:{testing_arch}'
|
||||||
if not options.test_selector(arch_specific_identifier):
|
if not options.test_selector(arch_specific_identifier):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if machine_arch == 'x86_64' and testing_arch == 'arm64':
|
if machine_arch == 'x86_64' and testing_arch == 'arm64':
|
||||||
if config.identifier.endswith('_arm64'):
|
if config_is_arm64:
|
||||||
log.warning(unwrap('''
|
log.warning(unwrap('''
|
||||||
While arm64 wheels can be built on x86_64, they cannot be tested. The
|
While arm64 wheels can be built on x86_64, they cannot be tested. The
|
||||||
ability to test the arm64 wheels will be added in a future release of
|
ability to test the arm64 wheels will be added in a future release of
|
||||||
cibuildwheel, once Apple Silicon CI runners are widely available. To
|
cibuildwheel, once Apple Silicon CI runners are widely available. To
|
||||||
silence this warning, set `CIBW_TEST_SKIP: *-macosx_arm64`.
|
silence this warning, set `CIBW_TEST_SKIP: *-macosx_arm64`.
|
||||||
'''))
|
'''))
|
||||||
elif config.identifier.endswith('_universal2'):
|
elif config_is_universal2:
|
||||||
log.warning(unwrap('''
|
log.warning(unwrap('''
|
||||||
While universal2 wheels can be built on x86_64, the arm64 part of them
|
While universal2 wheels can be built on x86_64, the arm64 part of them
|
||||||
cannot currently be tested. The ability to test the arm64 part of a
|
cannot currently be tested. The ability to test the arm64 part of a
|
||||||
@@ -440,7 +446,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
call_with_arch(before_test_prepared, env=virtualenv_env, shell=True)
|
call_with_arch(before_test_prepared, env=virtualenv_env, shell=True)
|
||||||
|
|
||||||
# install the wheel
|
# install the wheel
|
||||||
call_with_arch(['pip', 'install', str(repaired_wheel) + options.test_extras], env=virtualenv_env)
|
call_with_arch(['pip', 'install', f"{repaired_wheel}{options.test_extras}"], env=virtualenv_env)
|
||||||
|
|
||||||
# test the wheel
|
# test the wheel
|
||||||
if options.test_requires:
|
if options.test_requires:
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
before_test_prepared = prepare_command(
|
before_test_prepared = prepare_command(
|
||||||
options.before_test,
|
options.before_test,
|
||||||
project='.',
|
project='.',
|
||||||
package=options.package_dir
|
package=options.package_dir,
|
||||||
)
|
)
|
||||||
shell(before_test_prepared, env=virtualenv_env)
|
shell(before_test_prepared, env=virtualenv_env)
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
test_command_prepared = prepare_command(
|
test_command_prepared = prepare_command(
|
||||||
options.test_command,
|
options.test_command,
|
||||||
project=Path('.').resolve(),
|
project=Path('.').resolve(),
|
||||||
package=options.package_dir.resolve()
|
package=options.package_dir.resolve(),
|
||||||
)
|
)
|
||||||
shell(test_command_prepared, cwd='c:\\', env=virtualenv_env)
|
shell(test_command_prepared, cwd='c:\\', env=virtualenv_env)
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ def test(tmp_path):
|
|||||||
# write python version information to a temporary file, this is
|
# write python version information to a temporary file, this is
|
||||||
# checked in setup.py
|
# checked in setup.py
|
||||||
'CIBW_BEFORE_ALL': before_all_command,
|
'CIBW_BEFORE_ALL': before_all_command,
|
||||||
'CIBW_BEFORE_ALL_LINUX': before_all_command + ''' && python -c "import sys; assert sys.version_info >= (3, 6)"''',
|
'CIBW_BEFORE_ALL_LINUX': f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 6)"',
|
||||||
'CIBW_ENVIRONMENT': "TEST_VAL='123'"
|
'CIBW_ENVIRONMENT': "TEST_VAL='123'"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user