From cd64547fea37055b6b45db57c4228ad6fa45fa83 Mon Sep 17 00:00:00 2001 From: Jeremy Kubica <104161096+jeremykubica@users.noreply.github.com> Date: Fri, 9 Oct 2026 13:19:42 -0400 Subject: [PATCH 1/2] Address Issue600 --- copier.yml | 15 +++++++++++++-- ...s_code %}publish-to-pypi.yml{% endif %}.jinja} | 0 ...ntains_code %}smoke-test.yml{% endif %}.jinja} | 0 ...e %}testing-and-coverage.yml{% endif %}.jinja} | 0 .../.pre-commit-config.yaml.jinja | 2 ++ ... in enforce_style %}.pylintrc{% endif %}.jinja | 0 .../{{package_name}}/__init__.py.jinja | 0 ..._example_module %}example_module.py{% endif %} | 0 ..._benchmarks %}example_benchmarks.py{% endif %} | 0 ...checking != 'none' %}py.typed{% endif %}.jinja | 0 ... in enforce_style %}.pylintrc{% endif %}.jinja | 0 ...ruff' in enforce_style %}.ruff.toml{% endif %} | 0 .../{{package_name}}/conftest.py | 0 .../{{package_name}}/test_packaging.py.jinja | 0 ...dule %}test_example_module.py{% endif %}.jinja | 0 15 files changed, 15 insertions(+), 2 deletions(-) rename python-project-template/.github/workflows/{publish-to-pypi.yml.jinja => {% if contains_code %}publish-to-pypi.yml{% endif %}.jinja} (100%) rename python-project-template/.github/workflows/{smoke-test.yml.jinja => {% if contains_code %}smoke-test.yml{% endif %}.jinja} (100%) rename python-project-template/.github/workflows/{testing-and-coverage.yml.jinja => {% if contains_code %}testing-and-coverage.yml{% endif %}.jinja} (100%) rename python-project-template/{src => {% if contains_code %}src{% endif %}}/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja (100%) rename python-project-template/{src => {% if contains_code %}src{% endif %}}/{{package_name}}/__init__.py.jinja (100%) rename python-project-template/{src => {% if contains_code %}src{% endif %}}/{{package_name}}/{% if create_example_module %}example_module.py{% endif %} (100%) rename python-project-template/{src => {% if contains_code %}src{% endif %}}/{{package_name}}/{% if include_benchmarks %}example_benchmarks.py{% endif %} (100%) rename python-project-template/{src => {% if contains_code %}src{% endif %}}/{{package_name}}/{% if mypy_type_checking != 'none' %}py.typed{% endif %}.jinja (100%) rename python-project-template/{tests => {% if contains_code %}tests{% endif %}}/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja (100%) rename python-project-template/{tests => {% if contains_code %}tests{% endif %}}/{% if 'ruff' in enforce_style %}.ruff.toml{% endif %} (100%) rename python-project-template/{tests => {% if contains_code %}tests{% endif %}}/{{package_name}}/conftest.py (100%) rename python-project-template/{tests => {% if contains_code %}tests{% endif %}}/{{package_name}}/test_packaging.py.jinja (100%) rename python-project-template/{tests => {% if contains_code %}tests{% endif %}}/{{package_name}}/{% if create_example_module %}test_example_module.py{% endif %}.jinja (100%) diff --git a/copier.yml b/copier.yml index ff255dc2..282ae717 100644 --- a/copier.yml +++ b/copier.yml @@ -18,6 +18,17 @@ custom_install: retrofitting existing project: retrofit custom: custom +contains_code: + help: The repo contains some code that should be tested. + type: bool + default: >- + {% if custom_install != 'notebook' %} + true + {% else %} + false + {% endif %} + when: false # Automatically determined, not asked to the user. + project_name: type: str help: What is the name of your project? @@ -119,7 +130,7 @@ mypy_type_checking: create_example_module: help: Do you want to create some example module code? type: bool - default: yes + default: "{{ contains_code }}" choices: yes: true no: false @@ -145,7 +156,7 @@ include_notebooks: include_benchmarks: help: Do you want to enable benchmarking? type: bool - default: yes + default: "{{ contains_code }}" choices: yes: true no: false diff --git a/python-project-template/.github/workflows/publish-to-pypi.yml.jinja b/python-project-template/.github/workflows/{% if contains_code %}publish-to-pypi.yml{% endif %}.jinja similarity index 100% rename from python-project-template/.github/workflows/publish-to-pypi.yml.jinja rename to python-project-template/.github/workflows/{% if contains_code %}publish-to-pypi.yml{% endif %}.jinja diff --git a/python-project-template/.github/workflows/smoke-test.yml.jinja b/python-project-template/.github/workflows/{% if contains_code %}smoke-test.yml{% endif %}.jinja similarity index 100% rename from python-project-template/.github/workflows/smoke-test.yml.jinja rename to python-project-template/.github/workflows/{% if contains_code %}smoke-test.yml{% endif %}.jinja diff --git a/python-project-template/.github/workflows/testing-and-coverage.yml.jinja b/python-project-template/.github/workflows/{% if contains_code %}testing-and-coverage.yml{% endif %}.jinja similarity index 100% rename from python-project-template/.github/workflows/testing-and-coverage.yml.jinja rename to python-project-template/.github/workflows/{% if contains_code %}testing-and-coverage.yml{% endif %}.jinja diff --git a/python-project-template/.pre-commit-config.yaml.jinja b/python-project-template/.pre-commit-config.yaml.jinja index 64956f6b..8aa10f94 100644 --- a/python-project-template/.pre-commit-config.yaml.jinja +++ b/python-project-template/.pre-commit-config.yaml.jinja @@ -151,6 +151,7 @@ repos: args: ["docs/pre_executed/"] {%- endif %} +{%- if not skip_all_source %} # Run unit tests, verify that they pass. Note that coverage is run against # the ./src directory here because that is what will be committed. In the # github workflow script, the coverage is run against the installed package @@ -165,3 +166,4 @@ repos: language: system pass_filenames: false always_run: true +{%- endif %} diff --git a/python-project-template/src/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja b/python-project-template/{% if contains_code %}src{% endif %}/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja similarity index 100% rename from python-project-template/src/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja rename to python-project-template/{% if contains_code %}src{% endif %}/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja diff --git a/python-project-template/src/{{package_name}}/__init__.py.jinja b/python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/__init__.py.jinja similarity index 100% rename from python-project-template/src/{{package_name}}/__init__.py.jinja rename to python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/__init__.py.jinja diff --git a/python-project-template/src/{{package_name}}/{% if create_example_module %}example_module.py{% endif %} b/python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/{% if create_example_module %}example_module.py{% endif %} similarity index 100% rename from python-project-template/src/{{package_name}}/{% if create_example_module %}example_module.py{% endif %} rename to python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/{% if create_example_module %}example_module.py{% endif %} diff --git a/python-project-template/src/{{package_name}}/{% if include_benchmarks %}example_benchmarks.py{% endif %} b/python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/{% if include_benchmarks %}example_benchmarks.py{% endif %} similarity index 100% rename from python-project-template/src/{{package_name}}/{% if include_benchmarks %}example_benchmarks.py{% endif %} rename to python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/{% if include_benchmarks %}example_benchmarks.py{% endif %} diff --git a/python-project-template/src/{{package_name}}/{% if mypy_type_checking != 'none' %}py.typed{% endif %}.jinja b/python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/{% if mypy_type_checking != 'none' %}py.typed{% endif %}.jinja similarity index 100% rename from python-project-template/src/{{package_name}}/{% if mypy_type_checking != 'none' %}py.typed{% endif %}.jinja rename to python-project-template/{% if contains_code %}src{% endif %}/{{package_name}}/{% if mypy_type_checking != 'none' %}py.typed{% endif %}.jinja diff --git a/python-project-template/tests/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja b/python-project-template/{% if contains_code %}tests{% endif %}/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja similarity index 100% rename from python-project-template/tests/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja rename to python-project-template/{% if contains_code %}tests{% endif %}/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}.jinja diff --git a/python-project-template/tests/{% if 'ruff' in enforce_style %}.ruff.toml{% endif %} b/python-project-template/{% if contains_code %}tests{% endif %}/{% if 'ruff' in enforce_style %}.ruff.toml{% endif %} similarity index 100% rename from python-project-template/tests/{% if 'ruff' in enforce_style %}.ruff.toml{% endif %} rename to python-project-template/{% if contains_code %}tests{% endif %}/{% if 'ruff' in enforce_style %}.ruff.toml{% endif %} diff --git a/python-project-template/tests/{{package_name}}/conftest.py b/python-project-template/{% if contains_code %}tests{% endif %}/{{package_name}}/conftest.py similarity index 100% rename from python-project-template/tests/{{package_name}}/conftest.py rename to python-project-template/{% if contains_code %}tests{% endif %}/{{package_name}}/conftest.py diff --git a/python-project-template/tests/{{package_name}}/test_packaging.py.jinja b/python-project-template/{% if contains_code %}tests{% endif %}/{{package_name}}/test_packaging.py.jinja similarity index 100% rename from python-project-template/tests/{{package_name}}/test_packaging.py.jinja rename to python-project-template/{% if contains_code %}tests{% endif %}/{{package_name}}/test_packaging.py.jinja diff --git a/python-project-template/tests/{{package_name}}/{% if create_example_module %}test_example_module.py{% endif %}.jinja b/python-project-template/{% if contains_code %}tests{% endif %}/{{package_name}}/{% if create_example_module %}test_example_module.py{% endif %}.jinja similarity index 100% rename from python-project-template/tests/{{package_name}}/{% if create_example_module %}test_example_module.py{% endif %}.jinja rename to python-project-template/{% if contains_code %}tests{% endif %}/{{package_name}}/{% if create_example_module %}test_example_module.py{% endif %}.jinja From 20f12af6eda91950f20a0632779ec0a77f424dcf Mon Sep 17 00:00:00 2001 From: Jeremy Kubica <104161096+jeremykubica@users.noreply.github.com> Date: Fri, 9 Oct 2026 13:27:05 -0400 Subject: [PATCH 2/2] Update .pre-commit-config.yaml.jinja --- python-project-template/.pre-commit-config.yaml.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-project-template/.pre-commit-config.yaml.jinja b/python-project-template/.pre-commit-config.yaml.jinja index 8aa10f94..4be5d0a8 100644 --- a/python-project-template/.pre-commit-config.yaml.jinja +++ b/python-project-template/.pre-commit-config.yaml.jinja @@ -151,7 +151,7 @@ repos: args: ["docs/pre_executed/"] {%- endif %} -{%- if not skip_all_source %} +{%- if contains_code %} # Run unit tests, verify that they pass. Note that coverage is run against # the ./src directory here because that is what will be committed. In the # github workflow script, the coverage is run against the installed package