Skip to content

Commit

Permalink
✨ OZI spec 0.6
Browse files Browse the repository at this point in the history
Adds cibuildwheel and twine and dist plugins.

Signed-off-by: rjdbcm <[email protected]>
  • Loading branch information
rjdbcm committed Aug 16, 2024
1 parent 955a299 commit 66a7f90
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 38 deletions.
26 changes: 14 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ project(
from packaging.version import Version
v = get_version(normalize=False)
if Version(v) < Version("0.1"):
print("0.4")
print("0.6")
else:
print(v)
''',
Expand Down Expand Up @@ -164,9 +164,11 @@ replace_ruff_target_version = run_command(
check: true,
).stdout()
run_command(python, ['-c', replace_ruff_target_version], check: true)
pip = find_program('pip', required: true, disabler: true)
pip = find_program(get_option('install-requirements-command')[0], 'pip', required: true, disabler: true)
pipx = find_program('pipx', required: true, disabler: true)
pip_compile = find_program('pip-compile', required: true)
if get_option('compile-requirements-command')[0] != get_option('install-requirements-command')[0]
pip_compile = find_program(get_option('compile-requirements-command')[0], 'pip-compile', required: true)
endif
if not meson.is_subproject()
custom_target(
'requirements.txt',
Expand All @@ -175,7 +177,7 @@ if not meson.is_subproject()
build_always_stale: true,
build_by_default: true,
command: [
'pip-compile',
get_option('compile-requirements-command'),
'--allow-unsafe',
'--strip-extras',
'-q',
Expand All @@ -197,7 +199,7 @@ configure_file(
command: [python, '-c', meson_setuptools_scm],
output: 'PKG-INFO',
)
meson.add_dist_script(pip, 'install', 'tomli>=2.0.0')
meson.add_dist_script(get_option('install-requirements-command'), 'install', 'tomli>=2.0.0')
meson.add_dist_script(python, '-c', meson_dist_setuptools_scm)
vcs_tag(input: 'pyproject.toml', output: 'pyproject.orig.toml')
message('backed up pyproject.toml as pyproject.orig.toml')
Expand Down Expand Up @@ -265,9 +267,9 @@ foreach name : namespace
check: true
)
else
message('install', command, 'with pip')
message('install', command, 'with', ' '.join(get_option('install-requirements-command')))
run_command(
pip,
get_option('install-requirements-command'),
[
'install',
get_option('install-args-'+command),
Expand Down Expand Up @@ -334,7 +336,7 @@ foreach name : namespace
kwargs: no_check,
).stdout().strip()
fallback_version = run_command(
pip,
get_option('install-requirements-command'),
['show', app],
kwargs: no_check,
).stdout().split('\n')
Expand All @@ -361,7 +363,7 @@ foreach name : namespace
).stdout().strip()
if app in module_only
fallback_version = run_command(
pip,
get_option('install-requirements-command'),
[
'show',
run_command(
Expand All @@ -374,7 +376,7 @@ foreach name : namespace
).stdout().split('\n')
else
fallback_version = run_command(
pip,
get_option('install-requirements-command'),
['show', app],
kwargs: no_check,
).stdout().split('\n')
Expand Down Expand Up @@ -514,7 +516,7 @@ summary('path', python.full_path(), section: 'Python')
summary('version', python.language_version(), section: 'Python')

installed_packages = []
foreach line : run_command('pip', 'freeze', check: true).stdout().split('\n')
foreach line : run_command(get_option('install-requirements-command'), 'freeze', check: true).stdout().split('\n')
if line == ''
continue
endif
Expand Down Expand Up @@ -547,5 +549,5 @@ foreach legacy_package: ['wheel', 'setuptools', 'distribute']
endif
endif
endforeach
pip_version = run_command(pip, '-V', check: true).stdout().split()
pip_version = run_command(get_option('install-requirements-command'), '-V', check: true).stdout().split()
summary(pip_version[0], pip_version[1], section: 'Python packages')
24 changes: 19 additions & 5 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ option(
value: 'disabled',
description: 'blastpipe integration tests package',
)
option(
'compile-requirements-command',
type: 'array',
value: ['uv', 'pip', 'compile'],
yield: true,
)
option(
'install-requirements-command',
type: 'array',
value: ['uv', 'pip'],
yield: true,
)
option('dev', type: 'feature', value: 'auto')
option('install-subprojects', type: 'feature', value: 'disabled')
option('source-to-build', type: 'feature', value: 'auto')
Expand Down Expand Up @@ -139,12 +151,8 @@ option(
type: 'array',
description: 'install only - plugins for other utility applications',
value: [
'pytest-asyncio',
'pytest-cov',
'pytest-xdist',
'pytest-tcpclient',
'pytest-randomly',
'Flake8-pyproject',
'cibuildwheel',
'flake8-annotations',
'flake8-broken-line',
'flake8-bugbear',
Expand All @@ -161,8 +169,14 @@ option(
'flake8-tidy-imports',
'flake8-type-checking',
'hypothesis',
'pytest-asyncio',
'pytest-cov',
'pytest-randomly',
'pytest-tcpclient',
'pytest-xdist',
'sphinxawesome-codelinter',
'sphinxawesome-theme',
'twine',
],
)

Expand Down
12 changes: 12 additions & 0 deletions ozi/dist/cibuildwheel/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Part of the OZI Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: [
get_option('compile-requirements-command'), get_option('config-args-semantic_release'),
'-o', '@OUTPUT@', '@INPUT@',
]
)
1 change: 1 addition & 0 deletions ozi/dist/cibuildwheel/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cibuildwheel~=2.20
2 changes: 1 addition & 1 deletion ozi/dist/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source_child_dist_children = [
]
if (get_option('dev').enabled() or get_option('dist').enabled())
foreach package : source_child_dist_children
message('configure', package, 'with pip-compile')
message('configure', package, 'with', ' '.join(get_option('compile-requirements-command')))
subdir(package)
endforeach
endif
2 changes: 1 addition & 1 deletion ozi/dist/semantic_release/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ configure_file(
input: requirements,
output: 'requirements.txt',
command: [
'pip-compile', get_option('config-args-semantic_release'),
get_option('compile-requirements-command'), get_option('config-args-semantic_release'),
'-o', '@OUTPUT@', '@INPUT@',
]
)
2 changes: 1 addition & 1 deletion ozi/dist/sigstore/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-sigstore'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-sigstore'), '-o', '@OUTPUT@', '@INPUT@']
)
12 changes: 12 additions & 0 deletions ozi/dist/twine/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Part of the OZI Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: [
get_option('compile-requirements-command'), get_option('config-args-semantic_release'),
'-o', '@OUTPUT@', '@INPUT@',
]
)
1 change: 1 addition & 0 deletions ozi/dist/twine/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
twine
2 changes: 1 addition & 1 deletion ozi/lint/bandit/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-bandit'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-bandit'), '-o', '@OUTPUT@', '@INPUT@']
)
2 changes: 1 addition & 1 deletion ozi/lint/black/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-black'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-black'), '-o', '@OUTPUT@', '@INPUT@']
)
2 changes: 1 addition & 1 deletion ozi/lint/flake8/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-flake8'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-flake8'), '-o', '@OUTPUT@', '@INPUT@']
)
2 changes: 1 addition & 1 deletion ozi/lint/isort/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-isort'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-isort'), '-o', '@OUTPUT@', '@INPUT@']
)
2 changes: 1 addition & 1 deletion ozi/lint/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source_child_lint_children = [
]
if (get_option('dev').enabled() or get_option('lint').enabled())
foreach package : source_child_lint_children
message('configure', package, 'with pip-compile')
message('configure', package, 'with', ' '.join(get_option('compile-requirements-command')))
subdir(package)
endforeach
endif
2 changes: 1 addition & 1 deletion ozi/lint/mypy/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-mypy'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-mypy'), '-o', '@OUTPUT@', '@INPUT@']
)
2 changes: 1 addition & 1 deletion ozi/lint/pyright/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ endif
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-pyright'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-pyright'), '-o', '@OUTPUT@', '@INPUT@']
)
2 changes: 1 addition & 1 deletion ozi/lint/readme-renderer/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-readme-renderer'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-readme-renderer'), '-o', '@OUTPUT@', '@INPUT@']
)
17 changes: 12 additions & 5 deletions ozi/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@
@task
def sign_log(c: Context, suite: str | None = None) -> None:
banned = './'
host = f'py{sys.version_info.major}{sys.version_info.minor}'
if not suite:
return print('No suite target provided', file=sys.stderr)
if any(i in suite for i in banned):
return print(f'Invalid sign target suite: {suite}', file=sys.stderr)
log = Path(f'.tox/{suite}/tmp/meson-logs/testlog-{suite}.txt') # noqa: S108
if log.exists():
c.run(f'sigstore sign --output-dir=sig {log}')
testlog = Path(f'.tox/{suite}/tmp/meson-logs/testlog-{suite}.txt') # noqa: S108
if testlog.exists():
c.run(f'sigstore sign --output-dir=sig/{host}/{suite} {testlog}')
else:
print(f'Log not found for {suite}.', file=sys.stderr)
print(f'Test log not found for suite: {suite}.', file=sys.stderr)
meson_log = Path(f'.tox/{suite}/tmp/meson-logs/meson-log.txt') # noqa: S108
if meson_log.exists():
c.run(f'sigstore sign --output-dir=sig/{host}/{suite} {meson_log}')
else:
print(f'Meson log not found for suite: {suite}.', file=sys.stderr)


@task(
Expand All @@ -46,7 +52,7 @@ def release(c: Context, sdist: bool = False) -> None:
if sdist:
c.run('python -m build --sdist')
c.run('sigstore sign dist/*.tar.gz')
ext_wheel = c.run('cibuildwheel --output-dir dist .')
ext_wheel = c.run('cibuildwheel --prerelease-pythons --output-dir dist .')
if ext_wheel and ext_wheel.exited != 0:
c.run('python -m build --wheel')
c.run('sigstore sign --output-dir=sig dist/*.whl')
Expand All @@ -61,4 +67,5 @@ def provenance(c: Context) -> None:
def publish(c: Context) -> None:
"""Publishes a release tag"""
c.run('psr publish')
c.run('twine check dist/*')
c.run('twine upload dist/*')
2 changes: 1 addition & 1 deletion ozi/test/coverage/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-coverage'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-coverage'), '-o', '@OUTPUT@', '@INPUT@']
)
2 changes: 1 addition & 1 deletion ozi/test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
source_child_test_children = ['coverage', 'pytest']
if (get_option('dev').enabled() or get_option('test').enabled())
foreach package : source_child_test_children
message('configure', package, 'with pip-compile')
message('configure', package, 'with', ' '.join(get_option('compile-requirements-command')))
subdir(package)
endforeach
endif
2 changes: 1 addition & 1 deletion ozi/test/pytest/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requirements = ['requirements.in']
configure_file(
input: requirements,
output: 'requirements.txt',
command: ['pip-compile', get_option('config-args-pytest'), '-o', '@OUTPUT@', '@INPUT@']
command: [get_option('compile-requirements-command'), get_option('config-args-pytest'), '-o', '@OUTPUT@', '@INPUT@']
)
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
[build-system]
build-backend = "ozi_build.buildapi"
requires = [
"OZI.build>=0.0.27",
"OZI.build>=1.0.2",
"pip-tools>=7",
'uv',
"pipx~=1.5",
"setuptools_scm[toml]~=8.0",
]
Expand Down Expand Up @@ -77,7 +78,7 @@ fix = ["black", "ruff>=0.1.6", "autoflake", "isort"]
# Default meson test setup
dev = ["[dist,lint,test]"]
## Packaging Setup
dist = ["python-semantic-release", "sigstore"]
dist = ["cibuildwheel", "python-semantic-release", "sigstore", "twine"]
## Linting and Formatting Setup
lint = ["bandit[toml]", "black", "flake8", "flake8-quotes",
"flake8-pytest-style", "flake8-type-checking", "flake8-annotations",
Expand All @@ -99,6 +100,9 @@ verbose = true
extend-exclude = "(\\.pyi|meson-private|venv)"
line-length = 93

[tool.cibuildwheel]
build-frontend = "build[uv]"

[tool.coverage.report]
exclude_lines = [
"^.*#\\s*(pragma|PRAGMA)[:\\s]?\\s*(no|NO)\\s*(cover|COVER)",
Expand Down

0 comments on commit 66a7f90

Please sign in to comment.