diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index da3a31e..e095b5c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -21,7 +21,7 @@ jobs: - name: Install packages run: | - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel setuptools spin python -m pip install ".[test]" python -m pip install --upgrade numpy python -m pip uninstall --yes scipy @@ -29,9 +29,9 @@ jobs: - name: Measure test coverage run: | - python -m pytest --cov=lazy_loader --durations=10 + spin test -c -- --durations=10 # Tests fail if using `--doctest-modules`. I.e., - # python -m pytest --cov=src --durations=10 --doctest-modules + # spin test -- --doctest-modules - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c454680..6cf247b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,8 +26,8 @@ jobs: - name: Build wheels run: | git clean -fxd - pip install -U build twine wheel - python -m build --sdist --wheel + pip install -U build twine wheel spin + spin sdist -- --wheel - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0785ea8..a299fe7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,9 +25,9 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip + python -m pip install --upgrade pip spin python -m pip install ".[test]" - name: Test run: | - python -m pytest + spin test diff --git a/.spin/cmds.py b/.spin/cmds.py new file mode 100644 index 0000000..7db4b98 --- /dev/null +++ b/.spin/cmds.py @@ -0,0 +1,35 @@ +import importlib +import sys +import textwrap + +import click +from spin.cmds.util import run + + +@click.command() +@click.argument("pytest_args", nargs=-1) +@click.option( + "-c", + "--coverage", + is_flag=True, + help="Generate a coverage report of executed tests.", +) +def test(pytest_args, coverage=False): + """🔧 Run tests""" + if not importlib.util.find_spec("lazy_loader"): + click.secho( + textwrap.dedent("""\ + ERROR: The package is not installed. + + Please do an editable install: + + pip install -e .[test] + + prior to running the tests."""), + fg="red", + ) + sys.exit(1) + + if coverage: + pytest_args = ("--cov=lazy_loader", *pytest_args) + run([sys.executable, "-m", "pytest", *list(pytest_args)]) diff --git a/pyproject.toml b/pyproject.toml index 3040854..32c1dcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,15 +3,14 @@ requires = ["setuptools>=61.2"] build-backend = "setuptools.build_meta" [project] -name = "lazy_loader" +name = "lazy-loader" requires-python = ">=3.9" authors = [{name = "Scientific Python Developers"}] readme = "README.md" -license = {file = "LICENSE.md"} +license = "BSD-3-Clause" dynamic = ['version'] classifiers = [ "Development Status :: 5 - Production/Stable", - "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -27,7 +26,7 @@ dependencies = [ [project.optional-dependencies] test = ["pytest >= 8.0", "pytest-cov >= 5.0", "coverage[toml] >= 7.2"] lint = ["pre-commit == 4.2.0"] -dev = ["changelist == 0.5"] +dev = ["changelist == 0.5", "spin == 0.14"] [project.urls] Home = "https://scientific-python.org/specs/spec-0001/" @@ -102,3 +101,13 @@ source = [ "src/lazy_loader", "*/site-packages/lazy_loader", ] + +[tool.spin] +package = 'lazy_loader' + +[tool.spin.commands] +Build = [ + 'spin.cmds.pip.install', + '.spin/cmds.py:test', + 'spin.cmds.build.sdist', +]