Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add pipx install instructions + explanation
  • Loading branch information
sjvrijn committed Aug 20, 2024
commit 4debab7de1f2942f4b4dbb5bebbfa51ab1a1fba4
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,26 @@ There are multiple scenarios to use this template:
[Scenario 2](#scenario-2-apply-to-pre-existing-code): Applying the template to some pre-existing code
[Scenario 3](#scenario-3-updating-a-template-made-package): Updating a package made with the template

In all three scenarios, you will need to install copier first:
In all three scenarios, you will need to install Copier first, which we
recommend doing with [`pipx`](https://github.com/pypa/pipx):
```shell
python3 -m pip install --user pipx
python3 -m pipx ensurepath
pipx install copier
```

> [!NOTE]
> Note that it is also possible to install Copier with regular `pip`, but that
> Copier will then be installed in your common environment and may cause
> conflicts with its dependencies, while `pipx` will install Copier in a
> separate and dedicated environment.

### Scenario 1: Create a new package


#### Step 1/2: Create the files and directory structure

Run `copier` with the template:
Run `copier copy` with the template:

```shell
# Notes:
Expand Down Expand Up @@ -155,7 +164,7 @@ containing your existing code rather than a new one:
copier copy https://github.com/nlesc/python-template.git path/to/existing/code
```

This works because if `path/to/destination` already exists, `copier` will
This works because if `path/to/destination` already exists, Copier will
update what is already there by either adding new files or updating
existing files. Copier will ask to overwrite any files that resulted in
conflicts. Especially if your files are already under version control, it is
Expand All @@ -171,14 +180,18 @@ created project using the `copier update` command. This has two effects:
2. You can change any of your previous answers to apply these changes
throughout your entire project.

> [!CAUTION]
> Do not manually update answers in `.copier-answers.yml`,
> as it will result in unexpected behavior.

```shell
cd path/to/project
copier update
```

If you don't want to change any of your answers, but only want to update your
project according to the latest template updates, you can provide the
`--skip-answered` option. This tells copier to reuse all of your previous
`--skip-answered` option. This tells Copier to reuse all of your previous
answers, and simply bring in all updates from the template into
your current project, such as updating which Python versions are supported.
You will still be asked to answer any new questions that have been added to
Expand Down