Skip to content

Add spin configuration #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ 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
pip list

- 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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
35 changes: 35 additions & 0 deletions .spin/cmds.py
Original file line number Diff line number Diff line change
@@ -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)])
17 changes: 13 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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/"
Expand Down Expand Up @@ -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',
]