style: apply black via pre-commit run -a
This commit is contained in:
committed by
Henry Schreiner
parent
9cbed6a9be
commit
178aaea6c7
+36
-17
@@ -37,11 +37,18 @@ def bump_version() -> None:
|
||||
current_version = cibuildwheel.__version__
|
||||
|
||||
try:
|
||||
commit_date_str = subprocess.run([
|
||||
'git',
|
||||
'show', '--no-patch', '--pretty=format:%ci',
|
||||
f'v{current_version}^{{commit}}',
|
||||
], check=True, capture_output=True, encoding='utf8').stdout
|
||||
commit_date_str = subprocess.run(
|
||||
[
|
||||
'git',
|
||||
'show',
|
||||
'--no-patch',
|
||||
'--pretty=format:%ci',
|
||||
f'v{current_version}^{{commit}}',
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
encoding='utf8',
|
||||
).stdout
|
||||
cd_date, cd_time, cd_tz = commit_date_str.split(' ')
|
||||
|
||||
url_opts = urllib.parse.urlencode({'q': f'is:pr merged:>{cd_date}T{cd_time}{cd_tz}'})
|
||||
@@ -90,7 +97,11 @@ def bump_version() -> None:
|
||||
if find_pattern in contents:
|
||||
found_at_least_one_file_needing_update = True
|
||||
actions.append(
|
||||
(path, find_pattern, replace_pattern,)
|
||||
(
|
||||
path,
|
||||
find_pattern,
|
||||
replace_pattern,
|
||||
)
|
||||
)
|
||||
|
||||
if not found_at_least_one_file_needing_update:
|
||||
@@ -125,18 +136,26 @@ def bump_version() -> None:
|
||||
while input('Type "done" to continue: ').strip().lower() != 'done':
|
||||
pass
|
||||
|
||||
subprocess.run([
|
||||
'git', 'commit',
|
||||
'--all',
|
||||
f"--message=Bump version: v{new_version}",
|
||||
], check=True)
|
||||
subprocess.run(
|
||||
[
|
||||
'git',
|
||||
'commit',
|
||||
'--all',
|
||||
f"--message=Bump version: v{new_version}",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
subprocess.run([
|
||||
'git', 'tag',
|
||||
'--annotate',
|
||||
f"--message=v{new_version}",
|
||||
f'v{new_version}',
|
||||
], check=True)
|
||||
subprocess.run(
|
||||
[
|
||||
'git',
|
||||
'tag',
|
||||
'--annotate',
|
||||
f"--message=v{new_version}",
|
||||
f'v{new_version}',
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
print('Done.')
|
||||
|
||||
|
||||
@@ -31,10 +31,9 @@ def main():
|
||||
print('Your git repo has uncommitted changes. Commit or stash before continuing.')
|
||||
sys.exit(1)
|
||||
|
||||
previous_branch = shell('git rev-parse --abbrev-ref HEAD',
|
||||
check=True,
|
||||
capture_output=True,
|
||||
encoding='utf8').stdout.strip()
|
||||
previous_branch = shell(
|
||||
'git rev-parse --abbrev-ref HEAD', check=True, capture_output=True, encoding='utf8'
|
||||
).stdout.strip()
|
||||
|
||||
shell('git fetch origin', check=True)
|
||||
|
||||
@@ -51,20 +50,24 @@ def main():
|
||||
return
|
||||
|
||||
shell('git commit -a -m "Update dependencies"', check=True)
|
||||
body = textwrap.dedent(f'''
|
||||
body = textwrap.dedent(
|
||||
f'''
|
||||
Update the versions of our dependencies.
|
||||
|
||||
PR generated by `{os.path.basename(__file__)}`.
|
||||
''')
|
||||
'''
|
||||
)
|
||||
run(
|
||||
[
|
||||
'gh', 'pr', 'create',
|
||||
'gh',
|
||||
'pr',
|
||||
'create',
|
||||
'--repo=joerick/cibuildwheel',
|
||||
'--base=master',
|
||||
"--title=Update dependencies",
|
||||
f"--body='{body}'",
|
||||
],
|
||||
check=True
|
||||
check=True,
|
||||
)
|
||||
|
||||
print('Done.')
|
||||
|
||||
+12
-4
@@ -83,9 +83,11 @@ class Project:
|
||||
|
||||
@classmethod
|
||||
def header(cls) -> str:
|
||||
return textwrap.dedent(f"""\
|
||||
return textwrap.dedent(
|
||||
f"""\
|
||||
| {'Name':{cls.NAME}} | CI | OS | Notes |
|
||||
|{'':-^{cls.NAME+2 }}|----|----|:------|""")
|
||||
|{'':-^{cls.NAME+2 }}|----|----|:------|"""
|
||||
)
|
||||
|
||||
@property
|
||||
def namelink(self) -> str:
|
||||
@@ -142,7 +144,10 @@ def path_for_icon(icon_name: str) -> Path:
|
||||
|
||||
|
||||
def str_projects(
|
||||
config: list[dict[str, Any]], *, online: bool = True, auth: str | None = None,
|
||||
config: list[dict[str, Any]],
|
||||
*,
|
||||
online: bool = True,
|
||||
auth: str | None = None,
|
||||
) -> str:
|
||||
io = StringIO()
|
||||
print = functools.partial(builtins.print, file=io)
|
||||
@@ -180,7 +185,10 @@ 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)
|
||||
|
||||
@@ -64,7 +64,7 @@ services = [
|
||||
CIService(
|
||||
name='gitlab',
|
||||
dst_config_path='.gitlab-ci.yml',
|
||||
badge_md='[](https://gitlab.com/joerick/cibuildwheel/-/commits/{branch})'
|
||||
badge_md='[](https://gitlab.com/joerick/cibuildwheel/-/commits/{branch})',
|
||||
),
|
||||
]
|
||||
|
||||
@@ -83,8 +83,8 @@ def ci_service_for_config_file(config_file):
|
||||
@click.argument('config_files', nargs=-1, type=click.Path())
|
||||
def run_example_ci_configs(config_files=None):
|
||||
'''
|
||||
Test the example configs. If no files are specified, will test
|
||||
examples/*-minimal.yml
|
||||
Test the example configs. If no files are specified, will test
|
||||
examples/*-minimal.yml
|
||||
'''
|
||||
|
||||
if len(config_files) == 0:
|
||||
@@ -102,10 +102,9 @@ def run_example_ci_configs(config_files=None):
|
||||
print('Your git repo has uncommitted changes. Commit or stash before continuing.')
|
||||
sys.exit(1)
|
||||
|
||||
previous_branch = shell('git rev-parse --abbrev-ref HEAD',
|
||||
check=True,
|
||||
capture_output=True,
|
||||
encoding='utf8').stdout.strip()
|
||||
previous_branch = shell(
|
||||
'git rev-parse --abbrev-ref HEAD', check=True, capture_output=True, encoding='utf8'
|
||||
).stdout.strip()
|
||||
|
||||
timestamp = time.strftime('%Y-%m-%dT%H-%M-%S', time.gmtime())
|
||||
branch_name = f'example-config-test---{previous_branch}-{timestamp}'
|
||||
@@ -125,13 +124,15 @@ 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}
|
||||
Generated from branch: {previous_branch}
|
||||
Time: {timestamp}
|
||||
''')
|
||||
'''
|
||||
)
|
||||
run(['git', 'commit', '--no-verify', '--message', message], check=True)
|
||||
shell(f'git subtree --prefix={example_project} push origin {branch_name}', check=True)
|
||||
|
||||
@@ -139,13 +140,17 @@ def run_example_ci_configs(config_files=None):
|
||||
print()
|
||||
print('> **Examples test run**')
|
||||
print('> ')
|
||||
print(f'> Branch: [{branch_name}](https://github.com/joerick/cibuildwheel/tree/{branch_name})')
|
||||
print(
|
||||
f'> Branch: [{branch_name}](https://github.com/joerick/cibuildwheel/tree/{branch_name})'
|
||||
)
|
||||
print('> ')
|
||||
print('> | Service | Config | Status |')
|
||||
print('> |---|---|---|')
|
||||
for config_file in config_files:
|
||||
service = ci_service_for_config_file(config_file)
|
||||
badge = service.badge_md.format(branch=branch_name, branch_escaped=quote(branch_name, safe=''))
|
||||
badge = service.badge_md.format(
|
||||
branch=branch_name, branch_escaped=quote(branch_name, safe='')
|
||||
)
|
||||
print(f'> | {service.name} | `{config_file}` | {badge} |')
|
||||
print('> ')
|
||||
print('> Generated by `bin/run_example_ci_config.py`')
|
||||
|
||||
+4
-1
@@ -17,4 +17,7 @@ if __name__ == '__main__':
|
||||
subprocess.run(unit_test_args, check=True)
|
||||
|
||||
# run the integration tests
|
||||
subprocess.run([sys.executable, '-m', 'pytest', '-x', '--durations', '0', '--timeout=2400', 'test'], check=True)
|
||||
subprocess.run(
|
||||
[sys.executable, '-m', 'pytest', '-x', '--durations', '0', '--timeout=2400', 'test'],
|
||||
check=True,
|
||||
)
|
||||
|
||||
+4
-4
@@ -19,9 +19,9 @@ if __name__ == '__main__':
|
||||
options = parser.parse_args()
|
||||
|
||||
project_dir = tempfile.mkdtemp()
|
||||
subprocess.run([
|
||||
sys.executable, '-m', 'test.test_projects',
|
||||
options.project_python_path, project_dir
|
||||
], check=True,)
|
||||
subprocess.run(
|
||||
[sys.executable, '-m', 'test.test_projects', options.project_python_path, project_dir],
|
||||
check=True,
|
||||
)
|
||||
|
||||
sys.exit(subprocess.run([sys.executable, '-m', 'cibuildwheel'], cwd=project_dir).returncode)
|
||||
|
||||
+32
-31
@@ -21,13 +21,16 @@ PYTHON_VERSIONS = ['27', '35', '36', '37', '38', '39']
|
||||
|
||||
if '--no-docker' in sys.argv:
|
||||
for python_version in PYTHON_VERSIONS:
|
||||
subprocess.run([
|
||||
f'./env{python_version}/bin/pip-compile',
|
||||
'--allow-unsafe',
|
||||
'--upgrade',
|
||||
'cibuildwheel/resources/constraints.in',
|
||||
'--output-file=cibuildwheel/resources/constraints-python{python_version}.txt',
|
||||
], check=True)
|
||||
subprocess.run(
|
||||
[
|
||||
f'./env{python_version}/bin/pip-compile',
|
||||
'--allow-unsafe',
|
||||
'--upgrade',
|
||||
'cibuildwheel/resources/constraints.in',
|
||||
'--output-file=cibuildwheel/resources/constraints-python{python_version}.txt',
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
else:
|
||||
# latest manylinux2010 image with cpython 2.7 support
|
||||
image_runner = 'quay.io/pypa/manylinux2010_x86_64:2021-02-06-3d322a5'
|
||||
@@ -41,19 +44,27 @@ else:
|
||||
'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)
|
||||
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
|
||||
shutil.copyfile(f'cibuildwheel/resources/constraints-python{PYTHON_VERSIONS[-1]}.txt', 'cibuildwheel/resources/constraints.txt',)
|
||||
shutil.copyfile(
|
||||
f'cibuildwheel/resources/constraints-python{PYTHON_VERSIONS[-1]}.txt',
|
||||
'cibuildwheel/resources/constraints.txt',
|
||||
)
|
||||
|
||||
|
||||
class Image(NamedTuple):
|
||||
@@ -66,20 +77,16 @@ class Image(NamedTuple):
|
||||
images = [
|
||||
Image('manylinux1', 'x86_64', 'quay.io/pypa/manylinux1_x86_64', None),
|
||||
Image('manylinux1', 'i686', 'quay.io/pypa/manylinux1_i686', None),
|
||||
|
||||
# Images for manylinux2010 are pinned to the latest tag supporting cp27
|
||||
Image('manylinux2010', 'x86_64', 'quay.io/pypa/manylinux2010_x86_64', '2021-02-06-3d322a5'),
|
||||
Image('manylinux2010', 'i686', 'quay.io/pypa/manylinux2010_i686', '2021-02-06-3d322a5'),
|
||||
|
||||
Image('manylinux2010', 'pypy_x86_64', 'pypywheels/manylinux2010-pypy_x86_64', None),
|
||||
|
||||
# 2014 images
|
||||
Image('manylinux2014', 'x86_64', 'quay.io/pypa/manylinux2014_x86_64', None),
|
||||
Image('manylinux2014', 'i686', 'quay.io/pypa/manylinux2014_i686', None),
|
||||
Image('manylinux2014', 'aarch64', 'quay.io/pypa/manylinux2014_aarch64', None),
|
||||
Image('manylinux2014', 'ppc64le', 'quay.io/pypa/manylinux2014_ppc64le', None),
|
||||
Image('manylinux2014', 's390x', 'quay.io/pypa/manylinux2014_s390x', None),
|
||||
|
||||
# 2_24 images
|
||||
Image('manylinux_2_24', 'x86_64', 'quay.io/pypa/manylinux_2_24_x86_64', None),
|
||||
Image('manylinux_2_24', 'i686', 'quay.io/pypa/manylinux_2_24_i686', None),
|
||||
@@ -112,23 +119,17 @@ for image in images:
|
||||
if info['manifest_digest'] == latest_tag['manifest_digest']
|
||||
)
|
||||
else:
|
||||
response = requests.get(
|
||||
f'https://hub.docker.com/v2/repositories/{image.image_name}/tags'
|
||||
)
|
||||
response = requests.get(f'https://hub.docker.com/v2/repositories/{image.image_name}/tags')
|
||||
response.raise_for_status()
|
||||
tags = response.json()['results']
|
||||
|
||||
latest_tag = next(
|
||||
tag for tag in tags if tag['name'] == 'latest'
|
||||
)
|
||||
latest_tag = next(tag for tag in tags if tag['name'] == 'latest')
|
||||
# i don't know what it would mean to have multiple images per tag
|
||||
assert len(latest_tag['images']) == 1
|
||||
digest = latest_tag['images'][0]['digest']
|
||||
|
||||
pinned_tag = next(
|
||||
tag
|
||||
for tag in tags
|
||||
if tag != latest_tag and tag['images'][0]['digest'] == digest
|
||||
tag for tag in tags if tag != latest_tag and tag['images'][0]['digest'] == digest
|
||||
)
|
||||
tag_name = pinned_tag['name']
|
||||
|
||||
|
||||
+15
-5
@@ -112,7 +112,9 @@ class PyPyVersions:
|
||||
release["python_version"] = Version(release["python_version"])
|
||||
|
||||
self.releases = [
|
||||
r for r in releases if not r["pypy_version"].is_prerelease and not r["pypy_version"].is_devrelease
|
||||
r
|
||||
for r in releases
|
||||
if not r["pypy_version"].is_prerelease and not r["pypy_version"].is_devrelease
|
||||
]
|
||||
self.arch = arch_str
|
||||
|
||||
@@ -154,7 +156,9 @@ class PyPyVersions:
|
||||
identifier = f"pp{version.major}{version.minor}-macosx_x86_64"
|
||||
|
||||
(url,) = [
|
||||
rf["download_url"] for rf in release["files"] if "" in rf["platform"] == "darwin" and rf["arch"] == "x64"
|
||||
rf["download_url"]
|
||||
for rf in release["files"]
|
||||
if "" in rf["platform"] == "darwin" and rf["arch"] == "x64"
|
||||
]
|
||||
|
||||
return ConfigMacOS(
|
||||
@@ -167,7 +171,9 @@ class PyPyVersions:
|
||||
class CPythonVersions:
|
||||
def __init__(self) -> None:
|
||||
|
||||
response = requests.get("https://www.python.org/api/v2/downloads/release/?is_published=true")
|
||||
response = requests.get(
|
||||
"https://www.python.org/api/v2/downloads/release/?is_published=true"
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
releases_info = response.json()
|
||||
@@ -188,7 +194,9 @@ class CPythonVersions:
|
||||
for version in reversed(sorted_versions):
|
||||
# Find the first patch version that contains the requested file
|
||||
uri = self.versions_dict[version]
|
||||
response = requests.get(f"https://www.python.org/api/v2/downloads/release_file/?release={uri}")
|
||||
response = requests.get(
|
||||
f"https://www.python.org/api/v2/downloads/release_file/?release={uri}"
|
||||
)
|
||||
response.raise_for_status()
|
||||
file_info = response.json()
|
||||
|
||||
@@ -252,7 +260,9 @@ class AllVersions:
|
||||
|
||||
@click.command()
|
||||
@click.option("--force", is_flag=True)
|
||||
@click.option("--level", default="INFO", type=click.Choice(["INFO", "DEBUG", "TRACE"], case_sensitive=False))
|
||||
@click.option(
|
||||
"--level", default="INFO", type=click.Choice(["INFO", "DEBUG", "TRACE"], case_sensitive=False)
|
||||
)
|
||||
def update_pythons(force: bool, level: str) -> None:
|
||||
|
||||
logging.basicConfig(
|
||||
|
||||
Reference in New Issue
Block a user