Skip to content
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@
// Mount the parent as /workspaces so we can pip install peers as editable
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// After the container is created, install the python project in editable form
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]'"
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
}
2 changes: 1 addition & 1 deletion docs/how-to/make-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

To make a new release, please follow this checklist:

- Ensure that you have previously followed `./pypi`
- Ensure that you have previously followed [](./pypi)
- Choose a new PEP440 compliant release number (see <https://peps.python.org/pep-0440/>)
- Go to the GitHub [release] page
- Choose `Draft New Release`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2", "wheel"]
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
Expand Down
5 changes: 3 additions & 2 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ how it does it, and why people should use it.
Source | <{{repo_url}}>
:---: | :---:
PyPI | `pip install {{pypi_name}}`
Documentation | <{{docs_url}}>
{% if sphinx %}Documentation | <{{docs_url}}>{% endif %}
Releases | <{{repo_url}}/releases>

This is where you should put some images or code snippets that illustrate
Expand All @@ -29,7 +29,8 @@ Or if it is a commandline tool then you might put some example commands here:
```
python -m {{package_name}} --version
```

{% if sphinx %}
<!-- README only content. Anything below this line won't be included in index.md -->

See {{docs_url}} for more detailed documentation.
{% endif %}
16 changes: 8 additions & 8 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2", "wheel"]
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -19,7 +19,7 @@ dependencies = [
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
readme = "README.rst"
readme = "README.md"
requires-python = ">=3.7"

[project.optional-dependencies]
Expand Down Expand Up @@ -60,7 +60,7 @@ reportMissingImports = false # Ignore missing stubs in imported modules
[tool.pytest.ini_options]
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
addopts = """
--tb=native -vv --doctest-modules --doctest-glob="*.rst"
--tb=native -vv{% if sphinx %} --doctest-modules --doctest-glob="*.rst"{% endif %}
"""
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
filterwarnings = "error"
Expand All @@ -81,22 +81,22 @@ legacy_tox_ini = """
[tox]
skipsdist=True

[testenv:{pre-commit,pyright,pytest,docs}]
[testenv:{pre-commit,pyright,pytest{% if sphinx %},docs{% endif %}}]
# Don't create a virtualenv for the command, requires tox-direct plugin
direct = True
passenv = *
allowlist_externals =
pytest
pre-commit
pyright
sphinx-build
{% if sphinx %} sphinx-build
sphinx-autobuild
commands =
{% endif %}commands =
pytest: pytest --cov={{ package_name }} --cov-report term --cov-report xml:cov.xml {posargs}
pyright: pyright src tests {posargs}
pre-commit: pre-commit run --all-files {posargs}
docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
"""
{% if sphinx %} docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
{% endif %}"""

[tool.ruff]
src = ["src", "tests"]
Expand Down
27 changes: 20 additions & 7 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,27 @@ def run_pipe(cmd: str, cwd=None):
return output


def test_template(tmp_path: Path):
project_path = tmp_path / "project"
venv_path = tmp_path / "venv"
copy_project(project_path)
def make_venv(project_path: Path) -> callable:
venv_path = project_path / "venv"
run_pipe(f"python -m venv {venv_path}")
run = functools.partial(run_pipe, cwd=str(project_path))
run(f"python -m venv {venv_path}")
run(f"{venv_path}/bin/python -m pip install -e .[dev]")
run(f"{venv_path}/bin/tox -p")
run("./venv/bin/pip install -e .[dev]")
return run


def test_template(tmp_path: Path):
copy_project(tmp_path)
run = make_venv(tmp_path)
run("./venv/bin/tox -p")
run("./venv/bin/pip install build twine")
run("./venv/bin/python -m build")
run("./venv/bin/twine check --strict dist/*")


def test_template_no_docs(tmp_path: Path):
copy_project(tmp_path, docs_type="README")
run = make_venv(tmp_path)
run("./venv/bin/tox -p")


def test_bad_repo_name(tmp_path: Path):
Expand Down