style: activate string normalization
This commit is contained in:
committed by
Henry Schreiner
parent
d1900f6a05
commit
bda76b21cb
+42
-42
@@ -17,14 +17,14 @@ import cibuildwheel
|
||||
|
||||
config = [
|
||||
# file path, version find/replace format
|
||||
('README.md', "cibuildwheel=={}"),
|
||||
('cibuildwheel/__init__.py', "__version__ = '{}'"),
|
||||
('docs/faq.md', "cibuildwheel=={}"),
|
||||
('docs/faq.md', "cibuildwheel@v{}"),
|
||||
('docs/setup.md', "cibuildwheel=={}"),
|
||||
('examples/*', "cibuildwheel=={}"),
|
||||
('examples/*', "cibuildwheel@v{}"),
|
||||
('setup.cfg', "version = {}"),
|
||||
("README.md", "cibuildwheel=={}"),
|
||||
("cibuildwheel/__init__.py", "__version__ = '{}'"),
|
||||
("docs/faq.md", "cibuildwheel=={}"),
|
||||
("docs/faq.md", "cibuildwheel@v{}"),
|
||||
("docs/setup.md", "cibuildwheel=={}"),
|
||||
("examples/*", "cibuildwheel=={}"),
|
||||
("examples/*", "cibuildwheel@v{}"),
|
||||
("setup.cfg", "version = {}"),
|
||||
]
|
||||
|
||||
RED = "\u001b[31m"
|
||||
@@ -39,32 +39,32 @@ def bump_version() -> None:
|
||||
try:
|
||||
commit_date_str = subprocess.run(
|
||||
[
|
||||
'git',
|
||||
'show',
|
||||
'--no-patch',
|
||||
'--pretty=format:%ci',
|
||||
f'v{current_version}^{{commit}}',
|
||||
"git",
|
||||
"show",
|
||||
"--no-patch",
|
||||
"--pretty=format:%ci",
|
||||
f"v{current_version}^{{commit}}",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
encoding='utf8',
|
||||
encoding="utf8",
|
||||
).stdout
|
||||
cd_date, cd_time, cd_tz = commit_date_str.split(' ')
|
||||
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}'})
|
||||
url = f'https://github.com/joerick/cibuildwheel/pulls?{url_opts}'
|
||||
url_opts = urllib.parse.urlencode({"q": f"is:pr merged:>{cd_date}T{cd_time}{cd_tz}"})
|
||||
url = f"https://github.com/joerick/cibuildwheel/pulls?{url_opts}"
|
||||
|
||||
print(f'PRs merged since last release:\n {url}')
|
||||
print(f"PRs merged since last release:\n {url}")
|
||||
print()
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e)
|
||||
print('Failed to get previous version tag information.')
|
||||
print("Failed to get previous version tag information.")
|
||||
|
||||
git_changes_result = subprocess.run(['git diff-index --quiet HEAD --'], shell=True)
|
||||
git_changes_result = subprocess.run(["git diff-index --quiet HEAD --"], shell=True)
|
||||
repo_has_uncommitted_changes = git_changes_result.returncode != 0
|
||||
|
||||
if repo_has_uncommitted_changes:
|
||||
print('error: Uncommitted changes detected.')
|
||||
print("error: Uncommitted changes detected.")
|
||||
sys.exit(1)
|
||||
|
||||
# fmt: off
|
||||
@@ -76,7 +76,7 @@ def bump_version() -> None:
|
||||
Version(new_version)
|
||||
except InvalidVersion:
|
||||
print("error: This version doesn't conform to PEP440")
|
||||
print(' https://www.python.org/dev/peps/pep-0440/')
|
||||
print(" https://www.python.org/dev/peps/pep-0440/")
|
||||
sys.exit(1)
|
||||
|
||||
actions = []
|
||||
@@ -93,7 +93,7 @@ def bump_version() -> None:
|
||||
found_at_least_one_file_needing_update = False
|
||||
|
||||
for path in paths:
|
||||
contents = path.read_text(encoding='utf8')
|
||||
contents = path.read_text(encoding="utf8")
|
||||
if find_pattern in contents:
|
||||
found_at_least_one_file_needing_update = True
|
||||
actions.append(
|
||||
@@ -114,33 +114,33 @@ def bump_version() -> None:
|
||||
|
||||
for action in actions:
|
||||
path, find, replace = action
|
||||
print(f'{path} {RED}{find}{OFF} → {GREEN}{replace}{OFF}')
|
||||
print(f"{path} {RED}{find}{OFF} → {GREEN}{replace}{OFF}")
|
||||
|
||||
print(f'Then commit, and tag as v{new_version}')
|
||||
print(f"Then commit, and tag as v{new_version}")
|
||||
|
||||
answer = input('Proceed? [y/N] ').strip()
|
||||
answer = input("Proceed? [y/N] ").strip()
|
||||
|
||||
if answer != 'y':
|
||||
print('Aborted')
|
||||
if answer != "y":
|
||||
print("Aborted")
|
||||
sys.exit(1)
|
||||
|
||||
for path, find, replace in actions:
|
||||
contents = path.read_text(encoding='utf8')
|
||||
contents = path.read_text(encoding="utf8")
|
||||
contents = contents.replace(find, replace)
|
||||
path.write_text(contents, encoding='utf8')
|
||||
path.write_text(contents, encoding="utf8")
|
||||
|
||||
print('Files updated. If you want to update the changelog as part of this')
|
||||
print('commit, do that now.')
|
||||
print("Files updated. If you want to update the changelog as part of this")
|
||||
print("commit, do that now.")
|
||||
print()
|
||||
|
||||
while input('Type "done" to continue: ').strip().lower() != 'done':
|
||||
while input('Type "done" to continue: ').strip().lower() != "done":
|
||||
pass
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
'git',
|
||||
'commit',
|
||||
'--all',
|
||||
"git",
|
||||
"commit",
|
||||
"--all",
|
||||
f"--message=Bump version: v{new_version}",
|
||||
],
|
||||
check=True,
|
||||
@@ -148,18 +148,18 @@ def bump_version() -> None:
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
'git',
|
||||
'tag',
|
||||
'--annotate',
|
||||
"git",
|
||||
"tag",
|
||||
"--annotate",
|
||||
f"--message=v{new_version}",
|
||||
f'v{new_version}',
|
||||
f"v{new_version}",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
print('Done.')
|
||||
print("Done.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
os.chdir(Path(__file__).parent.parent.resolve())
|
||||
bump_version()
|
||||
|
||||
@@ -17,66 +17,66 @@ def shell(cmd, **kwargs):
|
||||
|
||||
|
||||
def git_repo_has_changes():
|
||||
unstaged_changes = shell('git diff-index --quiet HEAD --').returncode != 0
|
||||
staged_changes = shell('git diff-index --quiet --cached HEAD --').returncode != 0
|
||||
unstaged_changes = shell("git diff-index --quiet HEAD --").returncode != 0
|
||||
staged_changes = shell("git diff-index --quiet --cached HEAD --").returncode != 0
|
||||
return unstaged_changes or staged_changes
|
||||
|
||||
|
||||
@click.command()
|
||||
def main():
|
||||
project_root = Path(__file__).parent / '..'
|
||||
project_root = Path(__file__).parent / ".."
|
||||
os.chdir(project_root)
|
||||
|
||||
if git_repo_has_changes():
|
||||
print('Your git repo has uncommitted changes. Commit or stash before continuing.')
|
||||
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'
|
||||
"git rev-parse --abbrev-ref HEAD", check=True, capture_output=True, encoding="utf8"
|
||||
).stdout.strip()
|
||||
|
||||
shell('git fetch origin', check=True)
|
||||
shell("git fetch origin", check=True)
|
||||
|
||||
timestamp = time.strftime('%Y-%m-%dT%H-%M-%S', time.gmtime())
|
||||
branch_name = f'update-constraints-{timestamp}'
|
||||
timestamp = time.strftime("%Y-%m-%dT%H-%M-%S", time.gmtime())
|
||||
branch_name = f"update-constraints-{timestamp}"
|
||||
|
||||
shell(f'git checkout -b {branch_name} origin/master', check=True)
|
||||
shell(f"git checkout -b {branch_name} origin/master", check=True)
|
||||
|
||||
try:
|
||||
shell('bin/update_dependencies.py', check=True)
|
||||
shell("bin/update_dependencies.py", check=True)
|
||||
|
||||
if not git_repo_has_changes():
|
||||
print('Done: no constraint updates required.')
|
||||
print("Done: no constraint updates required.")
|
||||
return
|
||||
|
||||
shell('git commit -a -m "Update dependencies"', check=True)
|
||||
body = textwrap.dedent(
|
||||
f'''
|
||||
f"""
|
||||
Update the versions of our dependencies.
|
||||
|
||||
PR generated by `{os.path.basename(__file__)}`.
|
||||
'''
|
||||
"""
|
||||
)
|
||||
run(
|
||||
[
|
||||
'gh',
|
||||
'pr',
|
||||
'create',
|
||||
'--repo=joerick/cibuildwheel',
|
||||
'--base=master',
|
||||
"gh",
|
||||
"pr",
|
||||
"create",
|
||||
"--repo=joerick/cibuildwheel",
|
||||
"--base=master",
|
||||
"--title=Update dependencies",
|
||||
f"--body='{body}'",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
print('Done.')
|
||||
print("Done.")
|
||||
finally:
|
||||
# remove any local changes
|
||||
shell('git checkout -- .')
|
||||
shell(f'git checkout {previous_branch}', check=True)
|
||||
shell(f'git branch -D --force {branch_name}', check=True)
|
||||
shell("git checkout -- .")
|
||||
shell(f"git checkout {previous_branch}", check=True)
|
||||
shell(f"git branch -D --force {branch_name}", check=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main.main(standalone_mode=True)
|
||||
|
||||
+8
-8
@@ -110,7 +110,7 @@ class Project:
|
||||
return " ".join(f"![{icon} icon][]" for icon in self.os)
|
||||
|
||||
def table_row(self) -> str:
|
||||
notes = self.notes.replace('\n', ' ')
|
||||
notes = self.notes.replace("\n", " ")
|
||||
return f"| {self.namelink: <{self.NAME}} | {self.ci_icons} | {self.os_icons} | {notes} |"
|
||||
|
||||
def links(self) -> str:
|
||||
@@ -122,25 +122,25 @@ class Project:
|
||||
|
||||
|
||||
def fetch_icon(icon_name: str) -> None:
|
||||
url = f'https://cdn.jsdelivr.net/npm/simple-icons@v4/icons/{icon_name}.svg'
|
||||
url = f"https://cdn.jsdelivr.net/npm/simple-icons@v4/icons/{icon_name}.svg"
|
||||
with urllib.request.urlopen(url) as f:
|
||||
original_svg_data = f.read()
|
||||
|
||||
document = xml.dom.minidom.parseString(original_svg_data)
|
||||
svgElement = document.documentElement
|
||||
assert svgElement.nodeName == 'svg'
|
||||
svgElement.setAttribute('width', '16px')
|
||||
svgElement.setAttribute('fill', '#606060')
|
||||
assert svgElement.nodeName == "svg"
|
||||
svgElement.setAttribute("width", "16px")
|
||||
svgElement.setAttribute("fill", "#606060")
|
||||
|
||||
icon_path = path_for_icon(icon_name)
|
||||
icon_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(path_for_icon(icon_name), 'w') as f:
|
||||
with open(path_for_icon(icon_name), "w") as f:
|
||||
f.write(svgElement.toxml())
|
||||
|
||||
|
||||
def path_for_icon(icon_name: str) -> Path:
|
||||
return Path('.') / 'docs' / 'data' / 'readme_icons' / f'{icon_name}.svg'
|
||||
return Path(".") / "docs" / "data" / "readme_icons" / f"{icon_name}.svg"
|
||||
|
||||
|
||||
def str_projects(
|
||||
@@ -200,7 +200,7 @@ def projects(
|
||||
start_str = "<!-- START bin/projects.py -->\n"
|
||||
start = text.find(start_str)
|
||||
end = text.find("<!-- END bin/projects.py -->\n")
|
||||
generated_note = f'<!-- this section is generated by bin/projects.py. Don\'t edit it directly, instead, edit {input.name} -->'
|
||||
generated_note = f"<!-- this section is generated by bin/projects.py. Don't edit it directly, instead, edit {input.name} -->"
|
||||
new_text = f"{text[:start + len(start_str)]}\n{generated_note}\n\n{output}\n{text[end:]}"
|
||||
|
||||
readme.seek(0)
|
||||
|
||||
@@ -21,98 +21,98 @@ def shell(cmd, **kwargs):
|
||||
|
||||
|
||||
def git_repo_has_changes():
|
||||
unstaged_changes = shell('git diff-index --quiet HEAD --').returncode != 0
|
||||
staged_changes = shell('git diff-index --quiet --cached HEAD --').returncode != 0
|
||||
unstaged_changes = shell("git diff-index --quiet HEAD --").returncode != 0
|
||||
staged_changes = shell("git diff-index --quiet --cached HEAD --").returncode != 0
|
||||
return unstaged_changes or staged_changes
|
||||
|
||||
|
||||
def generate_basic_project(path):
|
||||
sys.path.insert(0, '')
|
||||
sys.path.insert(0, "")
|
||||
from test.test_projects.c import new_c_project
|
||||
|
||||
project = new_c_project()
|
||||
project.generate(path)
|
||||
|
||||
|
||||
CIService = namedtuple('CIService', 'name dst_config_path badge_md')
|
||||
CIService = namedtuple("CIService", "name dst_config_path badge_md")
|
||||
services = [
|
||||
CIService(
|
||||
name='appveyor',
|
||||
dst_config_path='appveyor.yml',
|
||||
badge_md='[](https://ci.appveyor.com/project/joerick/cibuildwheel/branch/{branch})',
|
||||
name="appveyor",
|
||||
dst_config_path="appveyor.yml",
|
||||
badge_md="[](https://ci.appveyor.com/project/joerick/cibuildwheel/branch/{branch})",
|
||||
),
|
||||
CIService(
|
||||
name='azure-pipelines',
|
||||
dst_config_path='azure-pipelines.yml',
|
||||
badge_md='[](https://dev.azure.com/joerick0429/cibuildwheel/_build/latest?definitionId=2&branchName={branch})',
|
||||
name="azure-pipelines",
|
||||
dst_config_path="azure-pipelines.yml",
|
||||
badge_md="[](https://dev.azure.com/joerick0429/cibuildwheel/_build/latest?definitionId=2&branchName={branch})",
|
||||
),
|
||||
CIService(
|
||||
name='circleci',
|
||||
dst_config_path='.circleci/config.yml',
|
||||
badge_md='[](https://circleci.com/gh/joerick/cibuildwheel/tree/{branch})',
|
||||
name="circleci",
|
||||
dst_config_path=".circleci/config.yml",
|
||||
badge_md="[](https://circleci.com/gh/joerick/cibuildwheel/tree/{branch})",
|
||||
),
|
||||
CIService(
|
||||
name='github',
|
||||
dst_config_path='.github/workflows/example.yml',
|
||||
badge_md='[](https://github.com/joerick/cibuildwheel/actions)',
|
||||
name="github",
|
||||
dst_config_path=".github/workflows/example.yml",
|
||||
badge_md="[](https://github.com/joerick/cibuildwheel/actions)",
|
||||
),
|
||||
CIService(
|
||||
name='travis-ci',
|
||||
dst_config_path='.travis.yml',
|
||||
badge_md='[](https://travis-ci.org/joerick/cibuildwheel)',
|
||||
name="travis-ci",
|
||||
dst_config_path=".travis.yml",
|
||||
badge_md="[](https://travis-ci.org/joerick/cibuildwheel)",
|
||||
),
|
||||
CIService(
|
||||
name='gitlab',
|
||||
dst_config_path='.gitlab-ci.yml',
|
||||
badge_md='[](https://gitlab.com/joerick/cibuildwheel/-/commits/{branch})',
|
||||
name="gitlab",
|
||||
dst_config_path=".gitlab-ci.yml",
|
||||
badge_md="[](https://gitlab.com/joerick/cibuildwheel/-/commits/{branch})",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def ci_service_for_config_file(config_file):
|
||||
service_name = Path(config_file).name.rsplit('-', 1)[0]
|
||||
service_name = Path(config_file).name.rsplit("-", 1)[0]
|
||||
|
||||
for service in services:
|
||||
if service.name == service_name:
|
||||
return service
|
||||
|
||||
raise ValueError(f'unknown ci service for config file {config_file}')
|
||||
raise ValueError(f"unknown ci service for config file {config_file}")
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument('config_files', nargs=-1, type=click.Path())
|
||||
@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
|
||||
'''
|
||||
"""
|
||||
|
||||
if len(config_files) == 0:
|
||||
config_files = glob('examples/*-minimal.yml')
|
||||
config_files = glob("examples/*-minimal.yml")
|
||||
|
||||
# check each CI service has at most 1 config file
|
||||
configs_by_service = {}
|
||||
for config_file in config_files:
|
||||
service = ci_service_for_config_file(config_file)
|
||||
if service.name in configs_by_service:
|
||||
raise Exception('You cannot specify more than one config per CI service')
|
||||
raise Exception("You cannot specify more than one config per CI service")
|
||||
configs_by_service[service.name] = config_file
|
||||
|
||||
if git_repo_has_changes():
|
||||
print('Your git repo has uncommitted changes. Commit or stash before continuing.')
|
||||
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'
|
||||
"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}'
|
||||
timestamp = time.strftime("%Y-%m-%dT%H-%M-%S", time.gmtime())
|
||||
branch_name = f"example-config-test---{previous_branch}-{timestamp}"
|
||||
|
||||
try:
|
||||
shell(f'git checkout --orphan {branch_name}', check=True)
|
||||
shell(f"git checkout --orphan {branch_name}", check=True)
|
||||
|
||||
example_project = Path('example_root')
|
||||
example_project = Path("example_root")
|
||||
generate_basic_project(example_project)
|
||||
|
||||
for config_file in config_files:
|
||||
@@ -123,48 +123,48 @@ def run_example_ci_configs(config_files=None):
|
||||
dst_config_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(src_config_file, dst_config_file)
|
||||
|
||||
run(['git', 'add', example_project], check=True)
|
||||
run(["git", "add", example_project], check=True)
|
||||
message = textwrap.dedent(
|
||||
f'''\
|
||||
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)
|
||||
run(["git", "commit", "--no-verify", "--message", message], check=True)
|
||||
shell(f"git subtree --prefix={example_project} push origin {branch_name}", check=True)
|
||||
|
||||
print('---')
|
||||
print("---")
|
||||
print()
|
||||
print('> **Examples test run**')
|
||||
print('> ')
|
||||
print("> **Examples test run**")
|
||||
print("> ")
|
||||
print(
|
||||
f'> Branch: [{branch_name}](https://github.com/joerick/cibuildwheel/tree/{branch_name})'
|
||||
f"> Branch: [{branch_name}](https://github.com/joerick/cibuildwheel/tree/{branch_name})"
|
||||
)
|
||||
print('> ')
|
||||
print('> | Service | Config | Status |')
|
||||
print('> |---|---|---|')
|
||||
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='')
|
||||
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`')
|
||||
print(f"> | {service.name} | `{config_file}` | {badge} |")
|
||||
print("> ")
|
||||
print("> Generated by `bin/run_example_ci_config.py`")
|
||||
print()
|
||||
print('---')
|
||||
print("---")
|
||||
finally:
|
||||
# remove any local changes
|
||||
shutil.rmtree(example_project, ignore_errors=True)
|
||||
shell('git checkout -- .')
|
||||
shell(f'git checkout {previous_branch}', check=True)
|
||||
shell(f'git branch -D --force {branch_name}', check=True)
|
||||
shell("git checkout -- .")
|
||||
shell(f"git checkout {previous_branch}", check=True)
|
||||
shell(f"git branch -D --force {branch_name}", check=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
os.chdir('..')
|
||||
os.chdir("..")
|
||||
run_example_ci_configs(standalone_mode=True)
|
||||
|
||||
+5
-5
@@ -5,19 +5,19 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
# move cwd to the project root
|
||||
os.chdir(Path(__file__).resolve().parents[1])
|
||||
|
||||
# run the unit tests
|
||||
unit_test_args = [sys.executable, '-m', 'pytest', 'unit_test']
|
||||
unit_test_args = [sys.executable, "-m", "pytest", "unit_test"]
|
||||
# run the docker unit tests only on Linux
|
||||
if sys.platform.startswith('linux'):
|
||||
unit_test_args += ['--run-docker']
|
||||
if sys.platform.startswith("linux"):
|
||||
unit_test_args += ["--run-docker"]
|
||||
subprocess.run(unit_test_args, check=True)
|
||||
|
||||
# run the integration tests
|
||||
subprocess.run(
|
||||
[sys.executable, '-m', 'pytest', '-x', '--durations', '0', '--timeout=2400', 'test'],
|
||||
[sys.executable, "-m", "pytest", "-x", "--durations", "0", "--timeout=2400", "test"],
|
||||
check=True,
|
||||
)
|
||||
|
||||
+5
-5
@@ -9,19 +9,19 @@ import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
# move cwd to the project root
|
||||
os.chdir(Path(__file__).resolve().parents[1])
|
||||
|
||||
parser = argparse.ArgumentParser(description='Runs a sample build')
|
||||
parser.add_argument('project_python_path', nargs='?', default='test.test_0_basic.basic_project')
|
||||
parser = argparse.ArgumentParser(description="Runs a sample build")
|
||||
parser.add_argument("project_python_path", nargs="?", default="test.test_0_basic.basic_project")
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
project_dir = tempfile.mkdtemp()
|
||||
subprocess.run(
|
||||
[sys.executable, '-m', 'test.test_projects', options.project_python_path, project_dir],
|
||||
[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)
|
||||
sys.exit(subprocess.run([sys.executable, "-m", "cibuildwheel"], cwd=project_dir).returncode)
|
||||
|
||||
+56
-56
@@ -11,50 +11,50 @@ from typing import NamedTuple
|
||||
import requests
|
||||
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
os.chdir('..')
|
||||
os.chdir("..")
|
||||
|
||||
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
|
||||
# regenerate the constraints files
|
||||
os.environ['CUSTOM_COMPILE_COMMAND'] = "bin/update_dependencies.py"
|
||||
os.environ["CUSTOM_COMPILE_COMMAND"] = "bin/update_dependencies.py"
|
||||
|
||||
PYTHON_VERSIONS = ['27', '35', '36', '37', '38', '39']
|
||||
PYTHON_VERSIONS = ["27", "35", "36", "37", "38", "39"]
|
||||
|
||||
if '--no-docker' in sys.argv:
|
||||
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',
|
||||
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'
|
||||
subprocess.run(['docker', 'pull', image_runner], check=True)
|
||||
image_runner = "quay.io/pypa/manylinux2010_x86_64:2021-02-06-3d322a5"
|
||||
subprocess.run(["docker", "pull", image_runner], check=True)
|
||||
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/'
|
||||
abi_flags = "" if int(python_version) >= 38 else "m"
|
||||
python_path = f"/opt/python/cp{python_version}-cp{python_version}{abi_flags}/bin/"
|
||||
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'
|
||||
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',
|
||||
"docker",
|
||||
"run",
|
||||
"--rm",
|
||||
"--env=CUSTOM_COMPILE_COMMAND",
|
||||
"--volume={os.getcwd()}:/volume",
|
||||
'--workdir=/volume',
|
||||
"--workdir=/volume",
|
||||
image_runner,
|
||||
'bash',
|
||||
'-c',
|
||||
"bash",
|
||||
"-c",
|
||||
command,
|
||||
],
|
||||
check=True,
|
||||
@@ -62,8 +62,8 @@ else:
|
||||
|
||||
# default constraints.txt
|
||||
shutil.copyfile(
|
||||
f'cibuildwheel/resources/constraints-python{PYTHON_VERSIONS[-1]}.txt',
|
||||
'cibuildwheel/resources/constraints.txt',
|
||||
f"cibuildwheel/resources/constraints-python{PYTHON_VERSIONS[-1]}.txt",
|
||||
"cibuildwheel/resources/constraints.txt",
|
||||
)
|
||||
|
||||
|
||||
@@ -75,24 +75,24 @@ class Image(NamedTuple):
|
||||
|
||||
|
||||
images = [
|
||||
Image('manylinux1', 'x86_64', 'quay.io/pypa/manylinux1_x86_64', None),
|
||||
Image('manylinux1', 'i686', 'quay.io/pypa/manylinux1_i686', None),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
Image('manylinux_2_24', 'aarch64', 'quay.io/pypa/manylinux_2_24_aarch64', None),
|
||||
Image('manylinux_2_24', 'ppc64le', 'quay.io/pypa/manylinux_2_24_ppc64le', None),
|
||||
Image('manylinux_2_24', 's390x', 'quay.io/pypa/manylinux_2_24_s390x', None),
|
||||
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),
|
||||
Image("manylinux_2_24", "aarch64", "quay.io/pypa/manylinux_2_24_aarch64", None),
|
||||
Image("manylinux_2_24", "ppc64le", "quay.io/pypa/manylinux_2_24_ppc64le", None),
|
||||
Image("manylinux_2_24", "s390x", "quay.io/pypa/manylinux_2_24_s390x", None),
|
||||
]
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
@@ -102,41 +102,41 @@ for image in images:
|
||||
if image.tag is not None:
|
||||
# image has been pinned, do not update
|
||||
tag_name = image.tag
|
||||
elif image.image_name.startswith('quay.io/'):
|
||||
_, _, repository_name = image.image_name.partition('/')
|
||||
elif image.image_name.startswith("quay.io/"):
|
||||
_, _, repository_name = image.image_name.partition("/")
|
||||
response = requests.get(
|
||||
f'https://quay.io/api/v1/repository/{repository_name}?includeTags=true'
|
||||
f"https://quay.io/api/v1/repository/{repository_name}?includeTags=true"
|
||||
)
|
||||
response.raise_for_status()
|
||||
repo_info = response.json()
|
||||
tags_dict = repo_info['tags']
|
||||
tags_dict = repo_info["tags"]
|
||||
|
||||
latest_tag = tags_dict.pop('latest')
|
||||
latest_tag = tags_dict.pop("latest")
|
||||
# find the tag whose manifest matches 'latest'
|
||||
tag_name = next(
|
||||
name
|
||||
for (name, info) in tags_dict.items()
|
||||
if info['manifest_digest'] == latest_tag['manifest_digest']
|
||||
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']
|
||||
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']
|
||||
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']
|
||||
tag_name = pinned_tag["name"]
|
||||
|
||||
if not config.has_section(image.platform):
|
||||
config[image.platform] = {}
|
||||
|
||||
config[image.platform][image.manylinux_version] = f'{image.image_name}:{tag_name}'
|
||||
config[image.platform][image.manylinux_version] = f"{image.image_name}:{tag_name}"
|
||||
|
||||
with open('cibuildwheel/resources/pinned_docker_images.cfg', 'w') as f:
|
||||
with open("cibuildwheel/resources/pinned_docker_images.cfg", "w") as f:
|
||||
config.write(f)
|
||||
|
||||
Reference in New Issue
Block a user