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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ htmlcov
.pytest_cache/
/.vscode/
.mypy_cache
test_folder/
test_catalog/
28 changes: 27 additions & 1 deletion copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,33 @@ _answers_file: .copier-answers.copier-python-project.yml
# For a complete list of prompt options, see https://copier.readthedocs.io/en/stable/configuring/#advanced-prompt-formatting
project_name:
type: str
help: Provide the project name (snake case, e.g. my_project)
help: Provide the project name (use kebab-case, e.g. my-project-name)

# Computed variables for different case formats
sanitized_project_name:
type: str
default: "{{ project_name | trim }}"
when: false

project_name_kebab_case:
type: str
default: "{{ sanitized_project_name }}"
when: false

project_name_snake_case:
type: str
default: "{{ sanitized_project_name | replace('-', '_') }}"
when: false

project_name_flat_case:
type: str
default: "{{ sanitized_project_name | replace('-', '') }}"
when: false

project_name_title_case:
type: str
default: "{{ sanitized_project_name | replace('-', ' ') | title }}"
when: false

description:
type: str
Expand Down
12 changes: 6 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
PROJECT_NAME := "copier-python-project"
TEST_ANSWERS_FILE := ".copier/.copier-answers." + PROJECT_NAME + ".yml"

copy output="test_folder":
copy output="test_catalog":
uv run copier copy . {{ output }} \
--vcs-ref=HEAD

recopy output="test_folder":
recopy output="test_catalog":
uv run copier recopy {{ output }} \
--vcs-ref=HEAD \
--answers-file {{ TEST_ANSWERS_FILE }} \
--skip-answered \
--overwrite

update output="test_folder":
update output="test_catalog":
uv run copier recopy {{ output }} \
--vcs-ref=HEAD \
--answers-file {{ TEST_ANSWERS_FILE }} \
--overwrite

all_ff output="test_folder":
all_ff output="test_catalog":
just recopy {{ output }}
just --justfile {{ output }}/justfile all_ff

test:
uv run pytest
uv run pytest tests

ci_lint_full:
uv run copier copy . tmp/test_catalog \
--vcs-ref=HEAD \
--data project_name="test_project" \
--data project_name="test-project" \
--data description="..." \
--data author_name="Test Author" \
--data author_email="test@test.com" \
Expand Down
6 changes: 3 additions & 3 deletions skeleton/README.md.jinja
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# {{ project_name }}
# {{ project_name_title_case }}

{{ description }}

{%- if docker %}
1. Build docker image:
```
docker compose build {{ project_name }}
docker compose build {{ project_name_snake_case }}
```

2. Run docker container:
```
docker compose {{ project_name }} run bash
docker compose run {{ project_name_snake_case }} bash
```
or with just
```
Expand Down
6 changes: 3 additions & 3 deletions skeleton/justfile.jinja
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
set dotenv-load := true

PYTHONPATH := "{{ project_name }}"
SRC_PATH := "{{ project_name }}"
PYTHONPATH := "{{ project_name_snake_case }}"
SRC_PATH := "{{ project_name_snake_case }}"
TEST_PATH := "tests"
ANSWERS_FILE := ".copier/.copier-answers.copier-python-project.yml"
{%- if docker %}
CONTAINER_NAME := "{{ project_name }}"
CONTAINER_NAME := "{{ project_name_snake_case }}"
WORKDIR := "/code/"
{%- endif %}

Expand Down
6 changes: 3 additions & 3 deletions skeleton/pyproject.toml.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "{{ project_name }}"
name = "{{ project_name_kebab_case }}"
version = "0.1.0"
description = "{{ description }}"
authors = [{ name = "{{ author_name }}", email = "{{ author_email }}" }]
Expand Down Expand Up @@ -38,7 +38,7 @@ exclude_lines = [
]

[tool.fawltydeps]
code = ["{{ project_name }}"]
code = ["{{ project_name_snake_case }}"]
deps = ["pyproject.toml"]
ignore_unused = [
# Dev dependencies. This list should contain ALL of them!
Expand All @@ -49,7 +49,6 @@ ignore_unused = [
"flake8-pyproject",
"isort",
"mypy",
"poetry-dynamic-versioning",
"pytest",
"pytest-cov",
]
Expand All @@ -64,6 +63,7 @@ max-line-length = 120
profile = "black"
line_length = 120
order_by_type = false
known_first_party = ["{{ project_name_snake_case }}"]

[tool.mypy]
disallow_untyped_defs = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
services:
{{ project_name }}:
{{ project_name_snake_case }}:
build:
context: .
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

export APP=${APP:-{{project_name}}}
export APP=${APP:-{{project_name_kebab_case}}}

function log() {
local date status message
Expand Down
Empty file.