From 417ca9901118befca0733278ea7a33f519fa59e2 Mon Sep 17 00:00:00 2001 From: Ninja3047 <1284324+Ninja3047@users.noreply.github.com> Date: Sat, 27 Jun 2026 13:42:01 -0400 Subject: [PATCH 1/3] Use uv audit in generated projects --- {{cookiecutter.project_slug}}/Makefile | 3 +-- {{cookiecutter.project_slug}}/pyproject.toml | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index 2ec2b42..45bfb77 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -54,8 +54,7 @@ test: .PHONY: audit audit: - uv sync --group audit - uv run pip-audit . + uv audit .PHONY: doc {%- if cookiecutter.documentation == 'pdoc' %} diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index ba9da69..25c3c0c 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -41,12 +41,10 @@ lint = [ "interrogate", {%- endif %} ] -audit = ["pip-audit"] dev = [ {include-group = "doc"}, {include-group = "test"}, {include-group = "lint"}, - {include-group = "audit"}, "prek", ] From d9b647c5adfaac627bc7516e35f81f664a65ba60 Mon Sep 17 00:00:00 2001 From: Ninja3047 <1284324+Ninja3047@users.noreply.github.com> Date: Sat, 27 Jun 2026 13:42:53 -0400 Subject: [PATCH 2/3] Use Make default shell --- {{cookiecutter.project_slug}}/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index 45bfb77..065e302 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -1,5 +1,3 @@ -SHELL := /bin/bash - PY_IMPORT = {{ cookiecutter.__project_import }} # Optionally overridden by the user in the `test` target. From 33a995bfdd2104f71a1b1ecb8e723ba26dd51774 Mon Sep 17 00:00:00 2001 From: Ninja3047 <1284324+Ninja3047@users.noreply.github.com> Date: Sat, 27 Jun 2026 13:43:01 -0400 Subject: [PATCH 3/3] Fix namespace library generation --- .github/workflows/tests.yml | 22 ++++++++++++++++++++++ hooks/post_gen_project.py | 18 +++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 432d482..203e275 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ff8ac06..b2530d1 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -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 %}", @@ -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))