Skip to content

Commit c6cc0e0

Browse files
committed
Handle directory_name
1 parent 39d374c commit c6cc0e0

10 files changed

+36
-55
lines changed

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ Spend less time setting up and configuring your new Python packages and comply w
55
Use this [Copier](https://copier.readthedocs.io) template to generate an empty Python package. Features include:
66

77
- Boilerplate unit tests and documentation,
8-
- [Python static setup configuration]({{directory_name}}/pyproject.toml),
8+
- [Python static setup configuration](template/pyproject.toml),
99
- Open source software license,
10-
- Continuous integration with [GitHub action workflows]({{directory_name}}/.github/workflows) for building, testing, link checking and linting,
10+
- Continuous integration with [GitHub action workflows](template/.github/workflows) for building, testing, link checking and linting,
1111
- Code style checking with [ruff](https://beta.ruff.rs/),
12-
- [Editorconfig]({{directory_name}}/.editorconfig),
12+
- [Editorconfig](template/.editorconfig),
1313
- Usage and contribution documents:
14-
- [README.md]({{directory_name}}/README.md) for package users,
15-
- [README.dev.md]({{directory_name}}/README.dev.md) for package developer,
16-
- [project_setup.md]({{directory_name}}/project_setup.md) with extensive documentation about project setup,
17-
- [Change log]({{directory_name}}/CHANGELOG.md),
18-
- [Code of Conduct]({{directory_name}}/CODE_OF_CONDUCT.md),
19-
- [Contributing guidelines]({{directory_name}}/CONTRIBUTING.md),
14+
- [README.md](template/README.md) for package users,
15+
- [README.dev.md](template/README.dev.md) for package developer,
16+
- [project_setup.md](template/project_setup.md) with extensive documentation about project setup,
17+
- [Change log](template/CHANGELOG.md),
18+
- [Code of Conduct](template/CODE_OF_CONDUCT.md),
19+
- [Contributing guidelines](template/CONTRIBUTING.md),
2020
- Continuous code quality and code coverage reporting using [Sonarcloud](https://sonarcloud.io/),
21-
- Automatic creation of [issues]({{directory_name}}/.github/next_steps) with instructions how to pass all GitHub action workflows and integrate with services like Zenodo and Read the Docs,
22-
- Instructions how to make package [citable]({{directory_name}}/.github/next_steps/02_citation.md)
21+
- Automatic creation of [issues](template/.github/next_steps) with instructions how to pass all GitHub action workflows and integrate with services like Zenodo and Read the Docs,
22+
- Instructions how to make package [citable](template/.github/next_steps/02_citation.md)
2323
- FAIR software recommendation badge,
24-
- Optional [pre commit hook]({{directory_name}}/README.dev.md#running-linters-locally) to catch lint errors early
24+
- Optional [pre commit hook](template/README.dev.md#running-linters-locally) to catch lint errors early
2525

2626
## Badges
2727

@@ -61,8 +61,7 @@ copier copy https://github.com/nlesc/python-template.git path/to/destination
6161

6262
| Name | Default value | Explanation |
6363
| ------------------------- | ------------- | ----------- |
64-
| directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. To get an impression of what will be generated, see the directory tree [below](https://github.com/NLeSC/python-template#step-33-read-about-what-was-just-generated) |
65-
| package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. |
64+
| package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. This also will be used as the github repo name.|
6665
| package_short_description | Short description of package | The information that you enter here will end up in the README, documentation, license, and pyproject.toml, so it may be a good idea to prepare something in advance. |
6766
| keyword1 | keyword1 | A term that describes your package. |
6867
| keyword2 | keyword2 | Another term that describes your package. |
@@ -75,7 +74,7 @@ copier copy https://github.com/nlesc/python-template.git path/to/destination
7574
| code_of_conduct_email | yourname@esciencecenter.nl | Email address of the person who should be contacted in case of violations of the Code of Conduct. |
7675

7776
Once the project files have been generated, follow the steps outlined in
78-
[{{directory_name}}/next_steps.md]({{directory_name}}/next_steps.md).
77+
[template/next_steps.md](template/next_steps.md).
7978

8079
### Step 3/3: Read about what was just generated
8180

@@ -135,7 +134,7 @@ Good job! You have now generated the skeleton for your package:
135134
└── .zenodo.json
136135
```
137136

138-
For an explanation of what's there, read on in the [project_setup.md]({{directory_name}}/project_setup.md) file.
137+
For an explanation of what's there, read on in the [project_setup.md](template/project_setup.md) file.
139138
There are also instructions on how to [apply the template to an existing Python package](ADD_TO_EXISTING_PACKAGE.md).
140139

141140
## Examples

copier.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ package_name:
66
help: Enter the name of the Python package.
77
validator: >-
88
{% if not (package_name | regex_search('^[a-z][a-z0-9\_]+$')) %}
9-
package_name must start with a letter, followed one or more letters, digits or underscores all lowercase.
9+
package_name must start with a letter, followed one or more letters, digits or underscores all lowercase. Avoid using spaces or uppercase letters for the best experience across operating systems.
1010
{% endif %}
1111
package_short_description:
1212
type: str
1313
default: Short description of package
14-
# validator: >-
15-
# {% if '"' in package_short_description %}
16-
# package_short_description must not contain unescaped double quotes. Use \\" for double quotes.
17-
# {% endif %}
14+
validator: >-
15+
{% if (package_short_description | regex_replace ('"', '\\\\"')|regex_replace ("'", "\\\\'")%}
16+
package_short_description must not contain unescaped double or single quotes.
17+
{% endif %}
1818
keyword1:
1919
type: str
2020
default: keyword1
@@ -59,11 +59,11 @@ code_of_conduct_email:
5959
_subdirectory: template
6060

6161
repository:
62-
default: git@github.com:{{ github_organization }}/{{ directory_name }}
62+
default: git@github.com:{{ github_organization }}/{{ package_name }}
6363
when: false
6464

6565
repository_url:
66-
default: https://github.com/{{ github_organization }}/{{ directory_name }}
66+
default: https://github.com/{{ github_organization }}/{{ package_name }}
6767
when: false
6868

6969

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ dev =
5151

5252
[tool:pytest]
5353
testpaths = tests
54-
norecursedirs = .git .github hooks {{directory_name}}
54+
norecursedirs = .git .github hooks template

template/.github/next_steps/01_sonarcloud_integration.md.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ In order to configure Sonarcloud analysis [GitHub Action workflow]({{repository_
1010
1. login with your GitHub account
1111
1. add Sonarcloud organization or reuse existing one
1212
1. set up a repository
13-
1. go to [new code definition administration page](https://sonarcloud.io/project/new_code?id={{github_organization}}_{{directory_name}}) and select `Number of days` option
13+
1. go to [new code definition administration page](https://sonarcloud.io/project/new_code?id={{github_organization}}_{{package_name}}) and select `Number of days` option
1414
1. To be able to run the analysis:
1515
1. a token must be created at [Sonarcloud account](https://sonarcloud.io/account/security/)
16-
1. the created token must be added as `SONAR_TOKEN` to [secrets on GitHub](https://github.com/{{github_organization}}/{{directory_name}}/settings/secrets/actions)
16+
1. the created token must be added as `SONAR_TOKEN` to [secrets on GitHub](https://github.com/{{github_organization}}/{{package_name}}/settings/secrets/actions)

template/.github/next_steps/03_readthedocs.md.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ To host the documentation of this repository please perform the following instru
99

1010
1. go to [Read the Docs](https://readthedocs.org/dashboard/import/?)
1111
1. log in with your GitHub account
12-
1. find `{{ github_organization }}/{{ directory_name }}` in list and press `+` button.
12+
1. find `{{ github_organization }}/{{ package_name }}` in list and press `+` button.
1313
* If repository is not listed,
1414
1. go to [Read the Docs GitHub app](https://github.com/settings/connections/applications/fae83c942bc1d89609e2)
1515
2. make sure {{ github_organization }} has been granted access.
1616
3. reload repository list on Read the Docs import page
17-
1. wait for the first build to be completed at <https://readthedocs.org/projects/{{ directory_name }}/builds>
17+
1. wait for the first build to be completed at <https://readthedocs.org/projects/{{ package_name }}/builds>
1818
1. check that the link of the documentation badge in the [README.md]({{ repository_url }}) works
1919

2020
See [README.dev.md#]({{repository_url}}/blob/main/README.dev.md#generating-the-api-docs) how to build documentation site locally.

template/README.md.jinja

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
| fair-software.eu recommendations | |
66
| :-- | :-- |
77
| (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)]({{repository_url}}) |
8-
| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{github_organization}}/{{directory_name}})]({{repository_url}}) |
8+
| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{github_organization}}/{{package_name}})]({{repository_url}}) |
99
| (3/5) community registry | [![RSD](https://img.shields.io/badge/rsd-{{package_name}}-00a3e3.svg)](https://www.research-software.nl/software/{{package_name}}) [![workflow pypi badge](https://img.shields.io/pypi/v/{{package_name}}.svg?colorB=blue)](https://pypi.python.org/project/{{package_name}}/) |
1010
| (4/5) citation | [![DOI](https://zenodo.org/badge/DOI/<replace-with-created-DOI>.svg)](https://doi.org/<replace-with-created-DOI>) |
1111
| (5/5) checklist | [![workflow cii badge](https://bestpractices.coreinfrastructure.org/projects/<replace-with-created-project-identifier>/badge)](https://bestpractices.coreinfrastructure.org/projects/<replace-with-created-project-identifier>) |
1212
| howfairis | [![fair-software badge](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8B-yellow)](https://fair-software.eu) |
1313
| **Other best practices** | &nbsp; |
14-
| Static analysis | [![workflow scq badge](https://sonarcloud.io/api/project_badges/measure?project={{github_organization}}_{{directory_name}}&metric=alert_status)](https://sonarcloud.io/dashboard?id={{github_organization}}_{{directory_name}}) |
15-
| Coverage | [![workflow scc badge](https://sonarcloud.io/api/project_badges/measure?project={{github_organization}}_{{directory_name}}&metric=coverage)](https://sonarcloud.io/dashboard?id={{github_organization}}_{{directory_name}}) |
16-
| Documentation | [![Documentation Status](https://readthedocs.org/projects/{{directory_name}}/badge/?version=latest)](https://{{directory_name}}.readthedocs.io/en/latest/?badge=latest) |
14+
| Static analysis | [![workflow scq badge](https://sonarcloud.io/api/project_badges/measure?project={{github_organization}}_{{package_name}}&metric=alert_status)](https://sonarcloud.io/dashboard?id={{github_organization}}_{{package_name}}) |
15+
| Coverage | [![workflow scc badge](https://sonarcloud.io/api/project_badges/measure?project={{github_organization}}_{{package_name}}&metric=coverage)](https://sonarcloud.io/dashboard?id={{github_organization}}_{{package_name}}) |
16+
| Documentation | [![Documentation Status](https://readthedocs.org/projects/{{package_name}}/badge/?version=latest)](https://{{package_name}}.readthedocs.io/en/latest/?badge=latest) |
1717
| **GitHub Actions** | &nbsp; |
1818
| Build | [![build]({{repository_url}}/actions/workflows/build.yml/badge.svg)]({{repository_url}}/actions/workflows/build.yml) |
1919
| Citation data consistency | [![cffconvert]({{repository_url}}/actions/workflows/cffconvert.yml/badge.svg)]({{repository_url}}/actions/workflows/cffconvert.yml) |
@@ -32,7 +32,7 @@ To install {{ package_name }} from GitHub repository, do:
3232

3333
```console
3434
git clone {{ repository }}.git
35-
cd {{ directory_name }}
35+
cd {{ package_name }}
3636
python -m pip install .
3737
```
3838

template/next_steps.md.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Alternatively, you can also use a personal access token, see
1313
[Creating a personal access token](https://docs.github.com/en/github-ae@latest/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). If you choose this option, below you will have to replace
1414
`git@github.com:` by `https://github.com/`.
1515

16+
Inside of the generated directory, run the following commands:
1617
```shell
17-
cd {{ directory_name }}
1818
git init
1919
git add --all
2020
git commit -m "first commit"
@@ -26,7 +26,7 @@ git remote add origin {{ repository }}
2626

2727
Go to
2828
[https://github.com/organizations/{{github_organization}}/repositories/new](https://github.com/organizations/{{github_organization}}/repositories/new)
29-
and create a new repository named `{{ directory_name }}` as an empty repository, then push your commits to GitHub:
29+
and create a new repository named `{{ package_name }}` as an empty repository, then push your commits to GitHub:
3030

3131
```shell
3232
git push --set-upstream origin main

template/project_setup.md.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ help you decide which tool to use for packaging.
7676
## Package version number
7777

7878
- We recommend using [semantic versioning](https://guide.esciencecenter.nl/#/best_practices/releases?id=semantic-versioning).
79-
- For convenience, the package version is stored in a single place: `{{ directory_name }}/pyproject.toml` under the `tool.bumpversion` header.
79+
- For convenience, the package version is stored in a single place: `pyproject.toml` under the `tool.bumpversion` header.
8080
- Don't forget to update the version number before [making a release](https://guide.esciencecenter.nl/#/best_practices/releases)!
8181

8282
## Logging

template/sonar-project.properties.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sonar.organization={{ github_organization }}
2-
sonar.projectKey={{ github_organization }}_{{ directory_name }}
2+
sonar.projectKey={{ github_organization }}_{{ package_name }}
33
sonar.host.url=https://sonarcloud.io
44
sonar.sources=src/{{ package_name }}/
55
sonar.tests=tests/

tests/test_values.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,3 @@ def test_single_quotes_in_name_and_description(copie):
1616
project = copie.copy(extra_answers=ctx)
1717

1818
assert project.exit_code == 0
19-
20-
21-
def test_dash_in_directory_name(copie):
22-
ctx = {
23-
"directory_name": "my-python-project"
24-
}
25-
project = copie.copy(extra_answers=ctx)
26-
27-
assert project.exit_code == 0
28-
29-
30-
def test_space_in_directory_name(copie):
31-
ctx = {
32-
"directory_name": "my python project"
33-
}
34-
project = copie.copy(extra_answers=ctx)
35-
36-
assert project.exit_code == 0

0 commit comments

Comments
 (0)