Skip to content

Commit 76f945d

Browse files
committed
update
1 parent 54b691b commit 76f945d

3 files changed

Lines changed: 32 additions & 63 deletions

File tree

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Copier Python Template
1+
# Python Project Template
22

3-
My personal Copier template for Python projects.
3+
My personal template for Python projects.
44

55
## Features
66

@@ -16,26 +16,20 @@ My personal Copier template for Python projects.
1616
## Requirements
1717

1818
* Python 3.8+
19-
* [Copier](https://copier.readthedocs.io/) (`pip install copier copier_templates_extensions`)
19+
* [sprout](https://github.com/zigai/sprout)
2020
* Git
2121

2222
## Quick Setup
2323

2424
Create a new Python project:
2525

2626
```bash
27-
copier copy --trust "https://github.com/zigai/python-project-template.git" /path/to/your/project
28-
```
29-
30-
or
31-
32-
```bash
33-
copier copy --trust "gh:zigai/python-project-template" /path/to/your/project
27+
sprout "https://github.com/zigai/python-project-template.git" /path/to/your/project
3428
```
3529

3630
## Generated Project Structure
3731

38-
```
32+
```text
3933
your-project/
4034
├── your_package/
4135
│ └── __init__.py
@@ -53,9 +47,10 @@ your-project/
5347

5448
## Similar Templates
5549

50+
* [cookiecutter-uv](https://github.com/fpgmaas/cookiecutter-uv)
5651
* [copier-uv](https://github.com/pawamoy/copier-uv)
5752
* [python-copier-template](https://github.com/DiamondLightSource/python-copier-template)
5853

5954
## License
6055

61-
This template is released under the [MIT License](https://github.com/zigai/python-project-template/blob/master/LICENSE).
56+
[MIT License](https://github.com/zigai/python-project-template/blob/master/LICENSE).

__pycache__/sprout.cpython-312.pyc

-973 Bytes
Binary file not shown.

sprout.py

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88

99
from jinja2 import Environment
1010
from jinja2.ext import Extension
11-
from rich.text import Text
1211

13-
from sprout import GitDefaultsExtension, Question, Style, validate_repository_url
14-
from sprout.cli import render_templates
15-
from sprout.prompt import console
12+
from sprout import GitDefaultsExtension, Question, validate_repository_url
1613

1714

1815
class PythonVersionExtension(Extension):
@@ -42,27 +39,6 @@ def __init__(self, environment: Environment):
4239
environment.globals["current_year"] = date.today().year
4340

4441

45-
def should_skip(relative_path: Path, answers: dict[str, Any]) -> bool:
46-
as_posix = relative_path.as_posix()
47-
github_actions = answers.get("github_actions", [])
48-
49-
if as_posix == "LICENSE.jinja" and answers.get("copyright_license") == "None":
50-
return True
51-
if (
52-
as_posix == ".github/workflows/tests.yml.jinja"
53-
and "tests" not in github_actions
54-
):
55-
return True
56-
if as_posix == ".github/workflows/lint.yml.jinja" and "lint" not in github_actions:
57-
return True
58-
if (
59-
as_posix == ".github/workflows/publish.yml.jinja"
60-
and "publish" not in github_actions
61-
):
62-
return True
63-
return False
64-
65-
6642
def validate_package_name(
6743
value: str, answers: dict[str, Any]
6844
) -> tuple[bool, str | None]:
@@ -179,6 +155,29 @@ def _python_identifier(name: str) -> str:
179155
]
180156

181157

158+
def should_skip_file(relative_path: str, answers: dict[str, Any]) -> bool:
159+
github_actions = answers.get("github_actions", [])
160+
161+
if relative_path == "LICENSE.jinja" and answers.get("copyright_license") == "None":
162+
return True
163+
if (
164+
relative_path == ".github/workflows/tests.yml.jinja"
165+
and "tests" not in github_actions
166+
):
167+
return True
168+
if (
169+
relative_path == ".github/workflows/lint.yml.jinja"
170+
and "lint" not in github_actions
171+
):
172+
return True
173+
if (
174+
relative_path == ".github/workflows/publish.yml.jinja"
175+
and "publish" not in github_actions
176+
):
177+
return True
178+
return False
179+
180+
182181
def questions(env: Environment, destination: Path) -> list[Question]:
183182
git_user_name = env.globals.get("git_user_name", "")
184183
git_user_email = env.globals.get("git_user_email", "")
@@ -320,7 +319,6 @@ def default_python_default_version(answers: dict[str, Any]) -> str:
320319
Question(
321320
key="copyright_license",
322321
prompt="Project license",
323-
help="Select 'None' to skip generating a license file.",
324322
choices=license_choices,
325323
default="None",
326324
),
@@ -349,28 +347,4 @@ def default_python_default_version(answers: dict[str, Any]) -> str:
349347
)
350348

351349

352-
def apply(
353-
*,
354-
env: Environment,
355-
template_dir: Path,
356-
destination: Path,
357-
answers: dict[str, Any],
358-
style: Style,
359-
) -> Sequence[Path]:
360-
"""Render the `template/` directory into the destination using answers.
361-
362-
Also renders Jinja expressions in path names (folders/files).
363-
Returns the list of created paths for Sprout to summarize.
364-
"""
365-
template_root = template_dir / "template"
366-
367-
created = render_templates(
368-
None,
369-
template_root,
370-
destination,
371-
answers,
372-
skip=should_skip,
373-
render_paths=True,
374-
extensions=extensions,
375-
)
376-
return list(created)
350+
template_dir = "template"

0 commit comments

Comments
 (0)