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
12 changes: 12 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ python_version_minimum:
- '3.13'
- '3.14'

python_version_maximum:
type: str
qmark: 🐍
help: Maximum Python version
default: No maximum
choices: |
- 'No maximum'
{%- set min_minor = python_version_minimum.split(".")[1] | int -%}
{%- for minor in range(min_minor, 15) %}
- '3.{{ minor }}'
{%- endfor %}

enable_coverage:
type: bool
qmark: 📊
Expand Down
20 changes: 18 additions & 2 deletions includes/python.jinja
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
{%- set all_versions = ["3.10", "3.11", "3.12", "3.13", "3.14"] -%}
{%- set min_minor = python_version_minimum.split(".")[1] | int -%}
{%- set max_minor = (
python_version_maximum.split(".")[1] | int
if python_version_maximum != 'No maximum' else
(all_versions|last).split(".")[1] | int
) -%}
{%- macro for_each_version() -%}
{%- for v in all_versions if v.split(".")[1] | int >= min_minor -%}
{%- for v in all_versions if (
v.split(".")[1] | int >= min_minor and v.split(".")[1] | int <= max_minor
) -%}
{{ caller(loop, v) }}
{%- endfor -%}
{%- endmacro -%}

{%- macro latest() -%}
{{- all_versions|last -}}
{%- for v in all_versions if v.split(".")[1] | int <= max_minor -%}
{{ v if loop.last }}
{%- endfor -%}
{%- endmacro -%}

{%- macro requires_python() -%}
>={{ python_version_minimum }}
{%- if python_version_maximum != 'No maximum' -%}
,<3.{{ max_minor + 1 }}
{%- endif %}
{%- endmacro -%}
2 changes: 1 addition & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "{{ project_description }}"
readme = "README.md"
license = "{{ copyright_license }}"
license-files = ["LICENSE"]
requires-python = ">={{ python_version_minimum }}"
requires-python = "{{ py.requires_python() }}"
authors = [
{ name = "{{ user_name }}", email = "{{ user_email }}" },
]
Expand Down
Loading
Loading