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
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ jobs:
make doc
cd .. && rm -rf /tmp/tob-r-and-e-python-project

- name: run template (namespace, library)
run: |
uvx cookiecutter --no-input -o /tmp . project_namespace_import=tob.r_and_e repo_type=library

[[ -d /tmp/tob-r-and-e-python-project/src/tob/r_and_e/python_project ]] || { >&2 echo "not generated?"; exit 1; }
[[ ! -f /tmp/tob-r-and-e-python-project/src/tob/r_and_e/python_project/_cli.py ]] || { >&2 echo "not expecting CLI module"; exit 1; }
[[ ! -f /tmp/tob-r-and-e-python-project/src/tob/r_and_e/python_project/__main__.py ]] || { >&2 echo "not expecting main module"; exit 1; }

cd /tmp/tob-r-and-e-python-project
git init . && git add . && git commit -m "Initial commit"
make format

git diff --exit-code || { >&2 echo "please format"; exit 1; }

uv run prek run --all-files
make lint
make test
make audit
make build
make doc
cd .. && rm -rf /tmp/tob-r-and-e-python-project

- name: run template (namespace, short slug)
run: |
uvx cookiecutter --no-input -o /tmp . project_namespace_import=tob.r_and_e "project_name=Bit Trails" project_slug=bit-trails
Expand Down
18 changes: 9 additions & 9 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import os

# Potentially new directory for namespace project
namespace_project_dir = os.path.join(
os.getcwd(), "{{ cookiecutter.__project_src_path }}"
)
if not os.path.exists(namespace_project_dir):
module_dir = os.path.join(os.getcwd(), "src", "{{ cookiecutter.__module_import }}")
os.makedirs(os.path.dirname(namespace_project_dir), exist_ok=True)
os.rename(module_dir, namespace_project_dir)

REMOVE_PATHS = [
# We delete _cli.py and __main__.py if we're not generating a CLI.
"{% if cookiecutter.entry_point == '' %} {{ cookiecutter.__project_src_path }}/_cli.py {% endif %}",
Expand All @@ -15,12 +24,3 @@
os.rmdir(path)
else:
os.unlink(path)

# Potentially new directory for namespace project
namespace_project_dir = os.path.join(
os.getcwd(), "{{ cookiecutter.__project_src_path }}"
)
if not os.path.exists(namespace_project_dir):
module_dir = os.path.join(os.getcwd(), "src", "{{ cookiecutter.__module_import }}")
os.makedirs(namespace_project_dir)
os.rename(module_dir, os.path.join(namespace_project_dir))
5 changes: 1 addition & 4 deletions {{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
SHELL := /bin/bash

PY_IMPORT = {{ cookiecutter.__project_import }}

# Optionally overridden by the user in the `test` target.
Expand Down Expand Up @@ -54,8 +52,7 @@ test:

.PHONY: audit
audit:
uv sync --group audit
uv run pip-audit .
uv audit

.PHONY: doc
{%- if cookiecutter.documentation == 'pdoc' %}
Expand Down
2 changes: 0 additions & 2 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ lint = [
"interrogate",
{%- endif %}
]
audit = ["pip-audit"]
dev = [
{include-group = "doc"},
{include-group = "test"},
{include-group = "lint"},
{include-group = "audit"},
"prek",
]

Expand Down