Skip to content

Commit

Permalink
Feature/1.8 pipx integration (#540)
Browse files Browse the repository at this point in the history
* ✨ Enable pipx isolation of apps.
* 🔨 Update spec files.
* ⬆️ OZI Spec v0.4
* 🔧 add 1.8 release branch pattern.

The following are no longer in ``meson.options:module-only``:
* sigstore
* Flake8-pyproject
* coverage
* flake8
* bandit
* black
* isort
* pyright
* mypy

---------

Signed-off-by: rjdbcm <[email protected]>
  • Loading branch information
rjdbcm authored May 18, 2024
1 parent 1c5da94 commit 50d4509
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 73 deletions.
35 changes: 26 additions & 9 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ replace_ruff_target_version = run_command(
).stdout()
run_command(python, ['-c', replace_ruff_target_version], check: true)
pip = find_program('pip', required: true, disabler: true)
pipx = find_program('pipx', required: true, disabler: true)
pip_compile = find_program('pip-compile', required: true)
if not meson.is_subproject()
custom_target(
Expand Down Expand Up @@ -240,20 +241,36 @@ foreach name : namespace
(get_option('dev').enabled() or suite.enabled())
and command not in plugin_only
)
run_command(
pip,
[
'install',
'-r',
meson.project_build_root() / 'ozi' / name / command / 'requirements.txt',
],
check: true
)
if command not in module_only and get_option('tox-env-dir') != ''
run_command(
pipx,
[
'runpip',
'meson',
'--python', python,
'install',
'-r',
meson.project_build_root() / 'ozi' / name / command / 'requirements.txt',
],
check: true
)
else
run_command(
pip,
[
'install',
'-r',
meson.project_build_root() / 'ozi' / name / command / 'requirements.txt',
],
check: true
)
endif
if not flag.found() and command not in module_only
flag = find_program(
command,
required: false,
disabler: true,
dirs: [get_option('tox-env-dir') / 'bin']
)
elif command in module_only
command = command.replace('-', '_')
Expand Down
15 changes: 5 additions & 10 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,20 @@ option(
'flake8-comprehensions',
],
)

option(
'tox-env-dir',
type: 'string',
value: ''
)
option(
'module-only',
type: 'array',
description: 'no application - python module entry point only',
value: [
'semantic_release',
'sigstore',
'sphinxawesome-codelinter',
'sphinxawesome-theme',
'Flake8-pyproject',
'pytest',
'coverage',
'flake8',
'bandit',
'black',
'isort',
'pyright',
'mypy',
'readme-renderer',
],
)
Expand Down
7 changes: 6 additions & 1 deletion ozi/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Linter comment check utilities."""
from __future__ import annotations

import re
from collections import Counter
from enum import IntFlag
from functools import lru_cache
from math import log
from math import log10
from pathlib import Path # noqa: TC003, RUF100
from typing import TYPE_CHECKING
from typing import Generator
from typing import Sequence

from ozi.spec import METADATA
from ozi.tap import TAP

if TYPE_CHECKING:
from pathlib import Path

TIER3_COMMENTS = [
'nosec',
'pragma_defer_to',
Expand Down
2 changes: 2 additions & 0 deletions ozi/fix/build_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Build definition check utilities."""
from __future__ import annotations

import os
from pathlib import Path
from typing import Generator
Expand Down
8 changes: 7 additions & 1 deletion ozi/fix/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Find missing OZI project files."""
from __future__ import annotations

import re
import sys
from email import message_from_string
from email.message import Message # noqa: TC003, RUF100
from pathlib import Path

if sys.version_info >= (3, 11): # pragma: no cover
import tomllib as toml
elif sys.version_info < (3, 11): # pragma: no cover
import tomli as toml

from typing import TYPE_CHECKING

from blastpipe.ozi_templates.filter import underscorify # pyright: ignore

from ozi.fix.build_definition import walk
Expand All @@ -23,6 +26,9 @@
from ozi.spec import METADATA
from ozi.tap import TAP

if TYPE_CHECKING:
from email.message import Message


def render_requirements(target: Path) -> str:
"""Render requirements.in as it would appear in PKG-INFO"""
Expand Down
2 changes: 1 addition & 1 deletion ozi/lint/readme-renderer/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
readme-renderer
readme-renderer[md]
2 changes: 2 additions & 0 deletions ozi/pkg_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Extra packaging metadata used by OZI."""
from __future__ import annotations

from email.message import Message
from typing import Any

Expand Down
2 changes: 1 addition & 1 deletion ozi/spec/_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def current_version() -> str:
class Spec(Default):
"""OZI Specification metadata."""

version: str = '0.3'
version: str = '0.4'
python: PythonProject = ClassicProject()


Expand Down
19 changes: 9 additions & 10 deletions ozi/spec/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Continuous integration specification."""
from __future__ import annotations

from collections.abc import Mapping # noqa: TCH003,TC003,RUF100
from dataclasses import dataclass
Expand All @@ -16,29 +17,29 @@ class Publish(Default):
"""Publishing patterns for packaged project."""

include: tuple[str, ...] = ('*.tar.gz', '*.whl', 'sig/*')
version: str = '0.1.1'
version: str = '0.1.2'


@dataclass(slots=True, frozen=True, eq=True)
class Draft(Default):
"""Draft release patterns for packaged project."""

version: str = '0.1.1'
version: str = '0.1.2'


@dataclass(slots=True, frozen=True, eq=True)
class Release(Default):
"""Release patterns for packaged project."""

version: str = '0.4.0'
version: str = '0.4.1'


@dataclass(slots=True, frozen=True, eq=True)
class Checkpoint(Default):
"""Checkpoint suites to run."""

suites: tuple[str, ...] = ('dist', 'lint', 'test')
version: str = '0.1.6'
version: str = '0.1.7'


@dataclass(kw_only=True, frozen=True, eq=True)
Expand Down Expand Up @@ -113,7 +114,7 @@ class ClassicLint(CheckpointSuite):
'isort': 'isort',
'mypy': 'mypy',
'pyright': 'pyright',
'readme-renderer': 'readme-renderer',
'readme-renderer': 'readme-renderer[md]',
},
)
plugin: Mapping[str, str] = field(
Expand Down Expand Up @@ -181,12 +182,10 @@ class Build(Default):
backend: str = 'ozi_build.buildapi'
requires: Mapping[str, str] = field(
default_factory=lambda: {
'OZI.build': 'OZI.build>=0.0.15',
'meson': 'meson[ninja]>=1.1.0',
'OZI.build': 'OZI.build>=0.0.18',
'pip-tools': 'pip-tools>=7',
'setuptools': 'setuptools>=64',
'setuptools_scm': 'setuptools_scm>=8.0',
'tomli': 'tomli>=2.0.0;python_version<"3.11"',
'pipx': 'pipx~=1.5',
'setuptools_scm': 'setuptools_scm[toml]~=8.0',
},
)

Expand Down
64 changes: 27 additions & 37 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
build-backend = "ozi_build.buildapi"
requires = [
"OZI.build>=0.0.18",
"meson[ninja]>=1.1.0",
"pip-tools>=7",
"setuptools>=64",
"setuptools_scm>=8.0",
'tomli>=2.0.0;python_version<"3.11"',
"pipx~=1.5",
"setuptools_scm[toml]~=8.0",
]

[tool.ozi-build.entry-points]
Expand All @@ -21,21 +19,8 @@ console_scripts = [
]

[tool.ozi-build.metadata]
summary = 'Packager for Python projects using Meson.'
pkg-info-file = 'PKG-INFO'

[tool.cibuildwheel]
build-frontend = "build"
before-build = [
"pip install --upgrade pip",
"pip install --upgrade build",
"pip install --upgrade sigstore",
"pip install --upgrade meson[ninja]>=1.1.0",
"pip install --upgrade OZI.build",
"pip install --upgrade setuptools_scm",
"pip install --upgrade pip-tools",
]

[tool.setuptools_scm]
version_file_template = """
Metadata-Version: 2.1
Expand Down Expand Up @@ -83,8 +68,6 @@ dependencies = { file = ["requirements.in"] }
[project]
dynamic = ["dependencies", "version"]
license = {file = "LICENSE.txt"}
readme = "README.rst"
requires-python = ">=3.10, <3.13"

[project.optional_dependencies] # also meson test suite names
# continuous integration
Expand Down Expand Up @@ -325,6 +308,11 @@ match = "release/1.7"
prerelease_token = "alpha"
prerelease = false

[tool.semantic_release.branches."release/1.8"]
match = "release/1.8"
prerelease_token = "alpha"
prerelease = false

[tool.semantic_release.commit_parser_options]
major_tags = [":boom:"]
minor_tags = [
Expand Down Expand Up @@ -404,47 +392,49 @@ python =
3.10 = dist,lint,test
[testenv]
allowlist_externals = rm
allowlist_externals =
rm
pipx
meson
python
package = wheel
deps =
meson >= 1.1.0
ninja >= 1.8.2
pip-tools
setuptools_scm[toml]
tomli >= 2.0.0
-r requirements.in
virtualenv
commands =
meson compile -C {env_tmp_dir}
rm -rf {env_tmp_dir}/.gitignore
[testenv:dist]
description = OZI distribution checkpoint
commands_pre = meson setup {env_tmp_dir} -Ddist=enabled
commands_pre =
pipx install --python=python meson
meson setup {env_tmp_dir} -Ddist=enabled -Dtox-env-dir={env_dir}
commands_post = meson test --no-rebuild --maxfail=1 -C {env_tmp_dir} --setup=dist
[testenv:lint]
description = OZI format/lint checkpoint
commands_pre = meson setup {env_tmp_dir} -Dlint=enabled
commands_pre =
pipx install --python=python meson
meson setup {env_tmp_dir} -Dlint=enabled -Dtox-env-dir={env_dir}
commands_post = meson test --no-rebuild --maxfail=1 -C {env_tmp_dir} --setup=lint
[testenv:test]
description = OZI unit tests checkpoint
commands_pre = meson setup {env_tmp_dir} -Dtest=enabled -Dozi-blastpipe=enabled
commands_pre =
pipx install --python=python meson
meson setup {env_tmp_dir} -Dtest=enabled -Dozi-blastpipe=enabled -Dtox-env-dir={env_dir}
commands_post = meson test --no-rebuild --maxfail=1 -C {env_tmp_dir} --setup=test
[testenv:fix]
description = OZI project fix issues utility (black, isort, autoflake, ruff)
deps =
black>=24.3
isort
autoflake
ruff
deps = pipx
skip_install = true
commands =
{env_python} -m black -S .
{env_python} -m isort .
{env_python} -m autoflake -i -r .
{env_python} -m ruff check ozi --fix
pipx run --python {env_python} black -S .
pipx run --python {env_python} isort .
pipx run --python {env_python} autoflake -i -r .
pipx run --python {env_python} ruff check ozi --fix
[testenv:scm]
description = OZI supply chain management (setuptools_scm)
Expand Down
9 changes: 6 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
blastpipe~=2024.7.4
GitPython>=3
blastpipe~=2024.7.4
dnspython
idna>=2
jinja2>=3
meson>=1.1.0
meson[ninja]>=1.1.0
packaging~=24.0
pip-tools
pyparsing~=3.1
requests
setuptools_scm[toml]
spdx-license-list
tomli>=2.0.0;python_version<"3.11"
trove-classifiers
types-requests
typing-extensions;python_version=="3.10"
typing-extensions;python_version=="3.10"

0 comments on commit 50d4509

Please sign in to comment.