From 9cbed6a9be846da757769f68135f6eb19dcc0d75 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 26 Mar 2021 10:40:19 -0400 Subject: [PATCH] chore: add black for all code, no string norm --- .pre-commit-config.yaml | 3 +-- bin/projects.py | 2 +- bin/run_example_ci_configs.py | 2 +- bin/sample_build.py | 2 +- bin/update_dependencies.py | 21 +++++++++++++-------- cibuildwheel/__main__.py | 10 +++++----- pyproject.toml | 4 ++-- setup.cfg | 2 +- test/test_cpp_standards.py | 10 ++++++---- test/test_dependency_versions.py | 4 ++-- test/test_macos_archs.py | 8 ++++---- test/test_manylinuxXXXX_only.py | 3 ++- 12 files changed, 39 insertions(+), 32 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bd1b6e9d..764ff43a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,10 +19,9 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 21.4b1 + rev: 21.4b2 hooks: - id: black - files: ^bin/update_pythons.py|setup.py$ - repo: https://github.com/asottile/setup-cfg-fmt rev: v1.17.0 diff --git a/bin/projects.py b/bin/projects.py index fbae3a3d..d6025846 100755 --- a/bin/projects.py +++ b/bin/projects.py @@ -180,7 +180,7 @@ def str_projects( @click.option("--auth", help="GitHub authentication token") @click.option("--readme", type=click.File("r+"), help="Modify a readme file if given") def projects( - input: TextIO, online: bool, auth: str | None, readme: TextIO | None + input: TextIO, online: bool, auth: str | None, readme: TextIO | None, ) -> None: config = yaml.safe_load(input) output = str_projects(config, online=online, auth=auth) diff --git a/bin/run_example_ci_configs.py b/bin/run_example_ci_configs.py index 25a7cb3e..d436cb32 100755 --- a/bin/run_example_ci_configs.py +++ b/bin/run_example_ci_configs.py @@ -125,7 +125,7 @@ def run_example_ci_configs(config_files=None): shutil.copyfile(src_config_file, dst_config_file) run(['git', 'add', example_project], check=True) - message = textwrap.dedent(f''' + message = textwrap.dedent(f'''\ Test example minimal configs Testing files: {config_files} diff --git a/bin/sample_build.py b/bin/sample_build.py index 6a07295d..0f04e5cb 100755 --- a/bin/sample_build.py +++ b/bin/sample_build.py @@ -22,6 +22,6 @@ if __name__ == '__main__': subprocess.run([ sys.executable, '-m', 'test.test_projects', options.project_python_path, project_dir - ], check=True) + ], check=True,) sys.exit(subprocess.run([sys.executable, '-m', 'cibuildwheel'], cwd=project_dir).returncode) diff --git a/bin/update_dependencies.py b/bin/update_dependencies.py index 89d997c7..0b5f7fc4 100755 --- a/bin/update_dependencies.py +++ b/bin/update_dependencies.py @@ -35,16 +35,21 @@ else: for python_version in PYTHON_VERSIONS: abi_flags = '' if int(python_version) >= 38 else 'm' python_path = f'/opt/python/cp{python_version}-cp{python_version}{abi_flags}/bin/' - subprocess.run([ - 'docker', 'run', '--rm', - '-e', 'CUSTOM_COMPILE_COMMAND', - '-v', f'{os.getcwd()}:/volume', - '--workdir', '/volume', image_runner, - 'bash', '-c', - f'{python_path}pip install pip-tools &&' - f'{python_path}pip-compile --allow-unsafe --upgrade ' + command = ( + f'{python_path}pip install pip-tools && ' + '{python_path}pip-compile --allow-unsafe --upgrade ' 'cibuildwheel/resources/constraints.in ' f'--output-file cibuildwheel/resources/constraints-python{python_version}.txt' + ) + subprocess.run([ + 'docker', 'run', + '--rm', + '--env=CUSTOM_COMPILE_COMMAND', + "--volume={os.getcwd()}:/volume", + '--workdir=/volume', + image_runner, + 'bash', '-c', + command, ], check=True) # default constraints.txt diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index d64f02b6..987cdb61 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -105,7 +105,7 @@ def main() -> None: parser.add_argument('--allow-empty', 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.',) args = parser.parse_args() @@ -117,10 +117,10 @@ def main() -> None: ci_provider = detect_ci_provider() if ci_provider is None: print(textwrap.dedent(''' - cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server; - Travis CI, AppVeyor, Azure Pipelines, GitHub Actions, CircleCI, and Gitlab are - supported. You can run on your development machine or other CI providers using the - --platform argument. Check --help output for more information. + cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server; + Travis CI, AppVeyor, Azure Pipelines, GitHub Actions, CircleCI, and Gitlab are + supported. You can run on your development machine or other CI providers using the + --platform argument. Check --help output for more information. '''), file=sys.stderr) sys.exit(2) if sys.platform.startswith('linux'): diff --git a/pyproject.toml b/pyproject.toml index 979c4888..1e98c170 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,6 @@ requires = [ build-backend = "setuptools.build_meta" [tool.black] -line-length = 120 -target-version = ['py36', 'py37', 'py38'] +line-length = 100 +target-version = ['py36', 'py37', 'py38', 'py39'] skip-string-normalization = true diff --git a/setup.cfg b/setup.cfg index 00e0c4ad..722bb2bf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,7 +52,7 @@ include = cibuildwheel [flake8] -ignore = E501,W503,E741,E226,B950 +ignore = E501,W503,E741,E226,B950,E203 select = C,E,F,W,B,B9 application-import-names = cibuildwheel exclude = diff --git a/test/test_cpp_standards.py b/test/test_cpp_standards.py index 762414bf..a614da58 100644 --- a/test/test_cpp_standards.py +++ b/test/test_cpp_standards.py @@ -8,7 +8,7 @@ from .test_projects import TestProject cpp_test_project = TestProject() -cpp_test_project.files['setup.py'] = jinja2.Template(r''' +setup_py_template = r'''\ from setuptools import Extension, setup setup( @@ -16,9 +16,9 @@ setup( ext_modules=[Extension('spam', sources=['spam.cpp'], language="c++", extra_compile_args={{ extra_compile_args }})], version="0.1.0", ) -''') +''' -cpp_test_project.files['spam.cpp'] = jinja2.Template(r''' +spam_cpp_template = r'''\ #include {{ spam_cpp_top_level_add }} @@ -69,8 +69,10 @@ MOD_INIT(spam) MOD_RETURN(m) } -''') +''' +cpp_test_project.files['setup.py'] = jinja2.Template(setup_py_template) +cpp_test_project.files['spam.cpp'] = jinja2.Template(spam_cpp_template) cpp11_project = cpp_test_project.copy() cpp11_project.template_context['extra_compile_args'] = ( diff --git a/test/test_dependency_versions.py b/test/test_dependency_versions.py index e41e6bf2..47af34c1 100644 --- a/test/test_dependency_versions.py +++ b/test/test_dependency_versions.py @@ -54,11 +54,11 @@ def test_pinned_versions(tmp_path, python_version): if utils.platform == 'windows' and python_version == '2.7': pytest.skip('Windows requires a workaround') - is_running_on_macos_11_or_later = ( + is_macos_11_or_later = ( utils.platform == 'macos' and utils.get_macos_version() >= (10, 16) ) - if is_running_on_macos_11_or_later and python_version == '3.5': + if is_macos_11_or_later and python_version == '3.5': pytest.skip('CPython 3.5 doesn\'t work on macOS Big Sur+') project_dir = tmp_path / 'project' diff --git a/test/test_macos_archs.py b/test/test_macos_archs.py index 51256adc..b525c52b 100644 --- a/test/test_macos_archs.py +++ b/test/test_macos_archs.py @@ -8,10 +8,10 @@ from . import test_projects, utils basic_project = test_projects.new_c_project() -ALL_MACOS_WHEELS = ( - utils.expected_wheels('spam', '0.1.0', machine_arch='x86_64') - + utils.expected_wheels('spam', '0.1.0', machine_arch='arm64') -) +ALL_MACOS_WHEELS = { + *utils.expected_wheels('spam', '0.1.0', machine_arch='x86_64'), + *utils.expected_wheels('spam', '0.1.0', machine_arch='arm64') +} def get_xcode_version() -> Tuple[int, int]: diff --git a/test/test_manylinuxXXXX_only.py b/test/test_manylinuxXXXX_only.py index ba143b3e..f71e6708 100644 --- a/test/test_manylinuxXXXX_only.py +++ b/test/test_manylinuxXXXX_only.py @@ -64,7 +64,8 @@ def test(manylinux_image, tmp_path): add_env['CIBW_SKIP'] = 'pp*' elif manylinux_image in {'manylinux2014', 'manylinux_2_24'}: # We don't have a manylinux2014 / 'manylinux_2_24' image for PyPy (yet?) - add_env['CIBW_SKIP'] = 'cp27* pp*' # Python 2.7 not available on manylinux2014 / 'manylinux_2_24' + # Python 2.7 not available on manylinux2014 / 'manylinux_2_24' + add_env['CIBW_SKIP'] = 'cp27* pp*' actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env) expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', manylinux_versions=[manylinux_image])]