|
3 | 3 | [Copier](https://copier.readthedocs.io/) is a library for rendering project templates, which lives at [github.com/copier-org/copier](https://github.com/copier-org/copier/). |
4 | 4 | [Poetry](https://python-poetry.org/) makes Python packaging and dependency management easy using pyproject.toml, and lives at [github.com/python-poetry/poetry](https://github.com/python-poetry/poetry/) |
5 | 5 |
|
6 | | -This copier template is my first attempt at using these two tools togehter to make creating new Python projects easier. |
| 6 | +This copier template is my first attempt at using these two tools togehter to make creating new Python projects easier on Windows. |
7 | 7 |
|
8 | 8 | ## Usage |
9 | 9 |
|
| 10 | +I'm more of a traditionalist and want the virtual environment files in a .venv directory in each project, so I have done: |
| 11 | +``` shell |
| 12 | +PS C:\> poetry config virtualenvs.in-project true |
| 13 | +``` |
| 14 | +This will globally configure poetry to do so and will let me do the following: |
| 15 | + |
| 16 | +``` shell |
| 17 | +PS C:\> copier https://github.com/Cecron/copier-python.git myproj |
| 18 | +PS C:\> cd myproj |
| 19 | +PS C:\> poetry install |
| 20 | +PS C:\> py -3 -m venv .\.venv\ --prompt . # Set virtual env prompt to show directory name |
| 21 | +PS C:\> .venv\Scripts\activate.ps1 |
| 22 | +``` |
| 23 | + |
| 24 | + |
10 | 25 | To give a basic understanding of how to create and use a copier template, I'll show how the first versions of this template was created, including how to apply the template to both generate a new project and also how to update the project whith a an improved version of the template. |
11 | 26 |
|
12 | 27 | ### Create a directory to place the template in |
@@ -44,7 +59,7 @@ pytest = "^5.2" |
44 | 59 |
|
45 | 60 | ``` shell |
46 | 61 | PS C:\copier-template> type copier.yaml |
47 | | -package_name: my-package |
| 62 | +package_name: mypackage |
48 | 63 | package_description: A short description of the package. |
49 | 64 | author_name: Cecron |
50 | 65 | author_email: Cecron@example.com |
@@ -81,7 +96,7 @@ PS C:\copier-template> cd .. |
81 | 96 | PS C:\> copier copier-template myproj |
82 | 97 | # Answer questions |
83 | 98 | package_name? Format: yaml |
84 | | -🎤 [my-package]: |
| 99 | +🎤 [mypackage]: |
85 | 100 |
|
86 | 101 | package_description? Format: yaml |
87 | 102 | 🎤 [A short description of the package.]: |
@@ -147,7 +162,7 @@ PS C:\copier-template> cd .. |
147 | 162 | PS C:\> copier update myproj |
148 | 163 |
|
149 | 164 | package_name? Format: yaml |
150 | | -🎤 [my-package]: |
| 165 | +🎤 [mypackage]: |
151 | 166 |
|
152 | 167 | package_description? Format: yaml |
153 | 168 | 🎤 [A short description of the package.]: |
|
0 commit comments