Skip to content

Commit 3eafb08

Browse files
authored
Merge pull request #399 from NLeSC/dev
Migration from cookiecutter to copier template
2 parents df96ae2 + 7548239 commit 3eafb08

File tree

67 files changed

+875
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+875
-788
lines changed

{{cookiecutter.directory_name}}/docs/_templates/.gitignore renamed to .copier-answers.yml

File renamed without changes.

.github/ISSUE_TEMPLATE/10_generated_package.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ assignees: ''
77

88
---
99
<!--
10-
Whatever you write here must have something to do with the code you get from running `cookiecutter`.
10+
Whatever you write here must have something to do with the code you get from running `copier`.
1111
-->

.github/ISSUE_TEMPLATE/20_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ assignees: ''
77

88
---
99
<!--
10-
Whatever you write here must have something to do with the code of the template itself, i.e. before you run `cookiecutter`.
10+
Whatever you write here must have something to do with the code of the template itself, i.e. before you run `copier`.
1111
-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
<!-- remove what doesn't apply or add more if needed -->
1717
Create a `python-template-test` repo on GitHub (will be overwritten if existing)
1818
```
19+
# Create a temporary directory by running the following command. Keep the XXXXXX in the directory name.
1920
cd $(mktemp -d --tmpdir py-tmpl-XXXXXX)
20-
cookiecutter -c <pr-branch> https://github.com/<pr-user>/python-template
21+
# Use --vcs-ref <pr-branch> to point to the branch you want to test
22+
copier copy --vcs-ref <pr-branch> https://github.com/<pr-user>/python-template .
2123
# Fill with python-template-test info
22-
cd python-template-test
24+
# Create a local git repo to push to GitHub to trigger CI actions
2325
git init
2426
git add --all
2527
git commit -m "First commit"
26-
git remote add origin https://github.com/<you>/python-template-test
28+
git remote add origin git@github.com:<you>/python-template-test.git
2729
git push -u origin main -f
30+
# Create a local environment to test your generated package locally
2831
python -m venv env
2932
source env/bin/activate
3033
python -m pip install --upgrade pip setuptools

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ env
2626
env3
2727
venv
2828
venv3
29+
30+
.swp

ADD_TO_EXISTING_PACKAGE.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ cff-version: "1.2.0"
7272
date-released: 2018-07-17
7373
doi: 10.5281/zenodo.1310751
7474
keywords:
75-
- cookiecutter
75+
- copier
7676
- template
7777
- Python
7878
license: Apache-2.0

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
NLeSC Cookiecutter template for Python
1+
NLeSC Copier template for Python
22
Copyright 2021, Netherlands eScience Center

README.dev.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ If you're looking for user documentation, go [here](README.md).
44

55
## Development install
66

7-
### Install `cookiecutter` in user space
7+
### Install `copier` in user space
88

9-
We recommend installing `cookiecutter` in user space as per `cookiecutter`'s instructions. This way, you don't have to
10-
install `cookiecutter` for every new project.
9+
We recommend installing `copier` in user space. This way, you don't have to
10+
install `copier` for every new project.
1111

1212
```shell
13-
python -m pip install --user --upgrade cookiecutter
13+
python -m pip install --user --upgrade copier
1414
```
1515

16+
17+
1618
### Get your own copy of the repository
1719

1820
Before you can do development work on the template, you'll need to check out a local copy of the repository:
@@ -23,6 +25,13 @@ git clone https://github.com/NLeSC/python-template.git
2325
cd python-template
2426
```
2527

28+
Please note that if you are working from some other branch than `main`, you should switch to that branch. For example, if you are working from the `dev` branch, you should do:
29+
30+
```shell
31+
git fetch origin
32+
git switch -c dev origin/dev
33+
```
34+
2635
### Create a virtual environment
2736

2837
Next, make a virtual environment, activate it, and install the development dependencies in it. This will enable you to
@@ -53,27 +62,28 @@ pytest
5362
pytest tests/
5463
```
5564

56-
## Using `cookiecutter` to generate a new package from the command line
65+
## Using `copier` to generate a new package from the command line
5766

5867
While making changes to the template, you'll regularly want to verify that the packages generated with the template
5968
still work. Any easy way to do this is to generate new packages in a temporary directory (which will get removed
6069
everytime you reboot), for example like so:
6170

6271
```shell
6372
# change directory to a new temporary directory
64-
cd $(mktemp -d --tmpdir cookiecutter-generated.XXXXXX)
73+
cd $(mktemp -d --tmpdir copier-generated.XXXXXX)
6574

66-
# run cookiecutter with the template to generate a new package
67-
cookiecutter <path to where your template is>
75+
# run copier with the template to generate a new package
76+
copier copy --vcs-ref HEAD <path/to/project/template> my-python-project
6877

6978
# when it asks you for the GitHub organization, put in your own name;
7079
# for the other questions, just accept the default
7180

7281
# 'ls' should return just the one directory called 'my-python-project'
7382
ls
7483
```
84+
Notice, that the `--vcs-ref HEAD` flag is used to make sure that the current checked out version of the local template is used.
7585

76-
If your Python package was created successfully, `cookiecutter` will point you to a file
86+
If your Python package was created successfully, `copier` will point you to a file
7787
(`my-python-project/next_steps.md`) that contains information on next steps.
7888

7989
In addition to the information in `my-python-project/project_setup.md`, the developer documentation
@@ -95,7 +105,7 @@ Follow the instructions from `my-python-project/README.dev.md` and make sure tha
95105
2. Verify that the information in `CITATION.cff` is correct.
96106
3. Make sure that `version` in [setup.cfg](setup.cfg) and `version` in [CITATION.cff](CITATION.cff) have been bumped to the to-be-released version of the template
97107
4. Run the unit tests with `pytest tests/`
98-
5. Go through the steps outlined above for [generating a new package from the command line](#using-cookiecutter-to-generate-a-new-package-from-the-command-line), and verify that the generated package works as it should.
108+
5. Go through the steps outlined above for [generating a new package from the command line](#using-copier-to-generate-a-new-package-from-the-command-line), and verify that the generated package works as it should.
99109

100110
### GitHub
101111

0 commit comments

Comments
 (0)