diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f82edd0f7..79b85ff41 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" } \ No newline at end of file diff --git a/docs/how-to/make-release.md b/docs/how-to/make-release.md index 9402cb3fa..dd7cbbfc9 100644 --- a/docs/how-to/make-release.md +++ b/docs/how-to/make-release.md @@ -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 ) - Go to the GitHub [release] page - Choose `Draft New Release` diff --git a/pyproject.toml b/pyproject.toml index 86ef30ed8..25ba95f2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/template/README.md.jinja b/template/README.md.jinja index 586f6ee8e..88d8ac040 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -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 @@ -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 %} See {{docs_url}} for more detailed documentation. +{% endif %} \ No newline at end of file diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index fcb4f789d..eee62ee14 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -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] @@ -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] @@ -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" @@ -81,7 +81,7 @@ 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 = * @@ -89,14 +89,14 @@ 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"] diff --git a/tests/test_example.py b/tests/test_example.py index e2801b5b8..0c9a8632b 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -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):