Skip to content

Commit 21e5d04

Browse files
authored
Add spin configuration (#152)
* Add spin configuration * Check for editable install before running tests * Use spin in CI pipelines
1 parent 112b7f8 commit 21e5d04

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

.github/workflows/coverage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ jobs:
2121

2222
- name: Install packages
2323
run: |
24-
python -m pip install --upgrade pip wheel setuptools
24+
python -m pip install --upgrade pip wheel setuptools spin
2525
python -m pip install ".[test]"
2626
python -m pip install --upgrade numpy
2727
python -m pip uninstall --yes scipy
2828
pip list
2929
3030
- name: Measure test coverage
3131
run: |
32-
python -m pytest --cov=lazy_loader --durations=10
32+
spin test -c -- --durations=10
3333
# Tests fail if using `--doctest-modules`. I.e.,
34-
# python -m pytest --cov=src --durations=10 --doctest-modules
34+
# spin test -- --doctest-modules
3535
3636
- name: Upload coverage to Codecov
3737
uses: codecov/codecov-action@v5

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
- name: Build wheels
2727
run: |
2828
git clean -fxd
29-
pip install -U build twine wheel
30-
python -m build --sdist --wheel
29+
pip install -U build twine wheel spin
30+
spin sdist -- --wheel
3131
3232
- name: Publish package distributions to PyPI
3333
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525

2626
- name: Install dependencies
2727
run: |
28-
python -m pip install --upgrade pip
28+
python -m pip install --upgrade pip spin
2929
python -m pip install ".[test]"
3030
3131
- name: Test
3232
run: |
33-
python -m pytest
33+
spin test

.spin/cmds.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import importlib
2+
import sys
3+
import textwrap
4+
5+
import click
6+
from spin.cmds.util import run
7+
8+
9+
@click.command()
10+
@click.argument("pytest_args", nargs=-1)
11+
@click.option(
12+
"-c",
13+
"--coverage",
14+
is_flag=True,
15+
help="Generate a coverage report of executed tests.",
16+
)
17+
def test(pytest_args, coverage=False):
18+
"""🔧 Run tests"""
19+
if not importlib.util.find_spec("lazy_loader"):
20+
click.secho(
21+
textwrap.dedent("""\
22+
ERROR: The package is not installed.
23+
24+
Please do an editable install:
25+
26+
pip install -e .[test]
27+
28+
prior to running the tests."""),
29+
fg="red",
30+
)
31+
sys.exit(1)
32+
33+
if coverage:
34+
pytest_args = ("--cov=lazy_loader", *pytest_args)
35+
run([sys.executable, "-m", "pytest", *list(pytest_args)])

pyproject.toml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ requires = ["setuptools>=61.2"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "lazy_loader"
6+
name = "lazy-loader"
77
requires-python = ">=3.9"
88
authors = [{name = "Scientific Python Developers"}]
99
readme = "README.md"
10-
license = {file = "LICENSE.md"}
10+
license = "BSD-3-Clause"
1111
dynamic = ['version']
1212
classifiers = [
1313
"Development Status :: 5 - Production/Stable",
14-
"License :: OSI Approved :: BSD License",
1514
"Programming Language :: Python :: 3",
1615
"Programming Language :: Python :: 3.9",
1716
"Programming Language :: Python :: 3.10",
@@ -27,7 +26,7 @@ dependencies = [
2726
[project.optional-dependencies]
2827
test = ["pytest >= 8.0", "pytest-cov >= 5.0", "coverage[toml] >= 7.2"]
2928
lint = ["pre-commit == 4.2.0"]
30-
dev = ["changelist == 0.5"]
29+
dev = ["changelist == 0.5", "spin == 0.14"]
3130

3231
[project.urls]
3332
Home = "https://scientific-python.org/specs/spec-0001/"
@@ -102,3 +101,13 @@ source = [
102101
"src/lazy_loader",
103102
"*/site-packages/lazy_loader",
104103
]
104+
105+
[tool.spin]
106+
package = 'lazy_loader'
107+
108+
[tool.spin.commands]
109+
Build = [
110+
'spin.cmds.pip.install',
111+
'.spin/cmds.py:test',
112+
'spin.cmds.build.sdist',
113+
]

0 commit comments

Comments
 (0)