From 04e6216582030884d2c7e498aaad77f144dac6d9 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 10 Aug 2023 10:07:43 +0200 Subject: [PATCH] Use hatch scripts Signed-off-by: Cristian Le --- .github/workflows/release.yml | 2 +- .packit.yaml | 11 +++++---- Makefile | 18 +++++++------- pyproject.toml | 45 +++++++++++++++++++++++++++++++---- 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3368da12..747edf2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,6 @@ jobs: ref: ${{ github.event.inputs.ref }} if: ${{ github.event_name == 'workflow_dispatch' }} - name: Build package - run: pipx run build + run: pipx hatch build - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.packit.yaml b/.packit.yaml index cf35ac09..f59aedd8 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -5,15 +5,18 @@ synced_files: upstream_package_name: fmf downstream_package_name: fmf +# Epel9 fails to build with dynamic version. Need to create archive with PKG-INFO +# F37 works with setuptools_scm 7.0 actions: create-archive: - - make tarball + - "hatch build -t sdist" + - "sh -c 'echo dist/fmf-*.tar.gz'" get-current-version: - - make version + - "hatch version" srpm_build_deps: - - make - - python3-docutils + - hatch + - python3-hatch-vcs jobs: - job: copr_build diff --git a/Makefile b/Makefile index e80d7be8..0c50731a 100644 --- a/Makefile +++ b/Makefile @@ -17,18 +17,16 @@ tmp: # Run the test suite, optionally with coverage test: tmp - pytest tests/unit + hatch run test:unit smoke: tmp - pytest tests/unit/test_smoke.py + hatch run test:smoke coverage: tmp - coverage run --source=fmf -m py.test tests - coverage report - coverage annotate + hatch run cov:cov # Build documentation, prepare man page docs: man - cd docs && make html + hatch run docs:html man: cp docs/header.txt $(TMP)/man.rst tail -n+7 README.rst >> $(TMP)/man.rst @@ -37,7 +35,7 @@ man: # RPM packaging tarball: man - python3 -m build --sdist + hatch build -t sdist rpm: tarball rpmbuild --define '_topdir $(TMP)' -bb fmf.spec srpm: tarball @@ -47,9 +45,9 @@ packages: rpm srpm # Python packaging wheel: - python3 -m build -upload: wheel tarball - twine upload dist/* + hatch build +upload: + hatch publish # Vim tags and cleanup diff --git a/pyproject.toml b/pyproject.toml index f8f7965b..9ba3621c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,10 +39,6 @@ Homepage = 'https://github.com/teemtee/fmf' Documentation = 'https://fmf.readthedocs.io' [project.optional-dependencies] -tests-cov = [ - 'fmf[tests]', - 'pytest-cov', -] # Needed for tests inside rpm build. Not being pacakged in rpm tests = [ 'pytest', @@ -56,6 +52,47 @@ docs = [ [project.scripts] fmf = 'fmf.cli:cli_entry' +[tool.hatch.envs.default] +platforms = ["linux"] + +[tool.hatch.envs.dev] +description = "Development environment" +dependencies = [ + "pytest-cov" +] +features = ["tests"] + +[tool.hatch.envs.dev.scripts] +type = ["mypy {args:tmt}"] +check = ["lint", "type"] + +unit = "pytest -vvv -ra --showlocals tests/unit" +smoke = "pytest -vvv -ra --showlocals tests/unit/test_cli.py" + +cov = [ + "coverage run --source=fmf -m pytest -vvv -ra --showlocals tests", + "coverage report", + "coverage annotate", + ] + +[tool.hatch.envs.dev-not-editable] +template = "dev" +description = "Same as 'dev', but not using editable install" +dev-mode = false + +[tool.hatch.envs.test] +template = "dev" +description = "Run scripts with multiple Python versions" + +[[tool.hatch.envs.test.matrix]] +python = ["3.9", "3.11", "3.12"] + +[tool.hatch.envs.docs] +features = ["docs"] + +[tool.hatch.envs.docs.scripts] +html = "sphinx-build -b html {root}/docs {root}/docs/_build {args}" + [tool.pytest.ini_options] markers = [ "web: tests which need to access the web",