diff --git a/{{cookiecutter.directory_name}}/docs/_templates/.gitignore b/.copier-answers.yml similarity index 100% rename from {{cookiecutter.directory_name}}/docs/_templates/.gitignore rename to .copier-answers.yml diff --git a/.github/ISSUE_TEMPLATE/01_bug_report.md b/.github/ISSUE_TEMPLATE/01_bug_report.md new file mode 100644 index 00000000..1428e3ec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/01_bug_report.md @@ -0,0 +1,51 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +## Checklist before submitting a bug report + +- [ ] I have checked the [existing issues](https://github.com/NLeSC/python-template/issues) and couldn't find an issue about this bug. + +## Bug details + +**Describe the bug** + +A clear and concise description of what the bug is. + +**To Reproduce** + +Steps to reproduce the behavior: +1. install copier using '...' +2. run `copier copy ...` +3. Select Pre-commit feature +4. ... + +**Error Message** + +If applicable, add the error message. + +**Expected behavior** + +A clear and concise description of what you expected to happen. + +**Screenshots** + +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + +- Template profile + - [ ] recommended + - [ ] minimum + - [ ] let me choose +- OS: +- version: + +**Additional context** + +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/10_generated_package.md b/.github/ISSUE_TEMPLATE/10_generated_package.md index 3fdb2a41..6ed2cf37 100644 --- a/.github/ISSUE_TEMPLATE/10_generated_package.md +++ b/.github/ISSUE_TEMPLATE/10_generated_package.md @@ -6,6 +6,12 @@ labels: generated-package assignees: '' --- + +## Checklist before submitting an issue + +- [ ] I have checked the [existing issues](https://github.com/NLeSC/python-template/issues) and couldn't find an issue about this bug. + +## Issue details diff --git a/.github/ISSUE_TEMPLATE/20_template.md b/.github/ISSUE_TEMPLATE/20_template.md index c25688bf..7937bcc4 100644 --- a/.github/ISSUE_TEMPLATE/20_template.md +++ b/.github/ISSUE_TEMPLATE/20_template.md @@ -6,6 +6,12 @@ labels: template assignees: '' --- + +## Checklist before submitting an issue + +- [ ] I have checked the [existing issues](https://github.com/NLeSC/python-template/issues) and couldn't find an issue about this bug. + +## Issue details diff --git a/.github/ISSUE_TEMPLATE/30_blank.md b/.github/ISSUE_TEMPLATE/30_blank.md index 11b08d93..fde810e3 100644 --- a/.github/ISSUE_TEMPLATE/30_blank.md +++ b/.github/ISSUE_TEMPLATE/30_blank.md @@ -6,3 +6,12 @@ labels: '' assignees: '' --- + +## Checklist before submitting an issue + +- [ ] I have checked the [existing issues](https://github.com/NLeSC/python-template/issues) and couldn't find an issue about this bug. + +## Issue details + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 72624dc3..8649a5e4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,32 +1,69 @@ -**Description** - +## Checklist before requesting a review + - [ ] I have read the [contribution guidelines](https://github.com/NLeSC/python-template/blob/main/CONTRIBUTING.md) -- [ ] This update is in line with what is recommended in the [Python chapter of the Guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python) +- [ ] My code follows the style guidelines of this project +- [ ] I have performed a self-review of my code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] My changes generate no new warnings +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes - [ ] All user facing changes have been added to CHANGELOG.md + + +## Type of change + +Please delete options that are not relevant. + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update + +## List of related issues or pull requests** - + +Refs: +- #ISSUE_NUMBER_1 +- #ISSUE_NUMBER_2 - +## Describe the changes made in this pull request + +Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. **Instructions to review the pull request** - -Create a `python-template-test` repo on GitHub (will be overwritten if existing) + + +Install the requirements + ``` cd $(mktemp -d --tmpdir py-tmpl-XXXXXX) -cookiecutter -c https://github.com//python-template -# Fill with python-template-test info -cd python-template-test +pip install pipx +pipx install copier +``` + +Create a new package using the template + +``` +copier copy --vcs-ref https://github.com/nlesc/python-template test_package +``` + +Create a local git repo to push to GitHub to trigger CI actions +``` git init git add --all git commit -m "First commit" -git remote add origin https://github.com//python-template-test +git remote add origin git@github.com:/python-template-test.git git push -u origin main -f +``` + +``` +# Create a local environment to test your generated package locally python -m venv env source env/bin/activate python -m pip install --upgrade pip setuptools python -m pip install '.[dev,publishing]' ``` + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..8a6c1559 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: ".github/workflows" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7fde3acd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: build + +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + + build: + name: Run pip install + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + python-version: ['3.10', '3.11', '3.12'] + steps: + - uses: actions/checkout@v5 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Python info + shell: bash -e {0} + run: | + which python + python --version + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + python -m pip install .[dev] diff --git a/.github/workflows/cffconvert.yml b/.github/workflows/cffconvert.yml index 71443637..9c59667e 100644 --- a/.github/workflows/cffconvert.yml +++ b/.github/workflows/cffconvert.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out a copy of the repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Check whether the citation metadata from CITATION.cff is valid uses: citation-file-format/cffconvert-github-action@2.0.0 diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml new file mode 100644 index 00000000..52c945df --- /dev/null +++ b/.github/workflows/link-check.yml @@ -0,0 +1,32 @@ +name: link-check + +on: + workflow_dispatch: + schedule: + - cron: '0 0 1 * *' # first day of every month at midnight + +permissions: + contents: read + issues: write + +jobs: + linkChecker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v2 + + - name: Set Issue Title + id: set_title + run: echo "ISSUE_TITLE=Link Checker Report - $(date '+%Y-%m-%d')" >> $GITHUB_ENV + + - name: Create Issue From File + if: env.lychee_exit_code != 0 + uses: peter-evans/create-issue-from-file@v5 + with: + title: ${{ env.ISSUE_TITLE }} + content-filepath: ./lychee/out.md + labels: report, automated issue diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml deleted file mode 100644 index e27e10b3..00000000 --- a/.github/workflows/markdown-link-check.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: markdown-link-check - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - - markdown-link-check: - name: Check markdown links - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gaurav-nelson/github-action-markdown-link-check@v1 - with: - use-quiet-mode: 'yes' - config-file: '.mlc-config.json' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f709f3d0..c261a078 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,12 +13,12 @@ jobs: name: Run template tests runs-on: ${{ matrix.os }} strategy: - fail-fast: false + fail-fast: true matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: diff --git a/.gitignore b/.gitignore index ec774d30..469e6bfd 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ env env3 venv venv3 +.venv +.venv3 + +.swp diff --git a/.mlc-config.json b/.mlc-config.json deleted file mode 100644 index 95443f7b..00000000 --- a/.mlc-config.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "_comment": "Markdown Link Checker configuration, see https://github.com/gaurav-nelson/github-action-markdown-link-check and https://github.com/tcort/markdown-link-check", - "ignorePatterns": [ - { - "pattern": "^http://localhost" - }, - { - "pattern": "\\{\\{" - }, - { - "pattern": "^https://doi.org/" - }, - { - "pattern": "^https://bestpractices.coreinfrastructure.org/projects/" - }, - { - "pattern": "^.github/workflows/sonarcloud.yml$" - }, - { - "pattern": "^https://readthedocs.org/dashboard/import.*" - } - ], - "replacementPatterns": [ - ], - "retryOn429": true, - "timeout": "20s" -} diff --git a/ADD_TO_EXISTING_PACKAGE.md b/ADD_TO_EXISTING_PACKAGE.md deleted file mode 100644 index 140c28ea..00000000 --- a/ADD_TO_EXISTING_PACKAGE.md +++ /dev/null @@ -1,29 +0,0 @@ -# Add your existing code to directory generated by the NLeSC Python template - -The following steps requires that your existing code is in a GitHub repository. - -1. Follow the [instructions to create a new package](https://github.com/NLeSC/python-template#how-to-use) with the Python template, while answering the questions like you would for the existing package. - -2. Create a Git structure for the new directory: (replace `` with directory name you used during cookiecutter questionnaire) -```shell -$ cd -$ git init -$ git add --all -$ git commit -m "Added code generated by cookiecutter" -$ git branch -M main -``` - -3. Import the existing repository from GitHub (Replace `` with your GitHub organization name , `` with your GitHub repository name and `` with your default branch for example `main` or `master`): -```shell -$ git remote add -f existing_code https://github.com// -$ git fetch existing_code -$ git merge existing_code/ --allow-unrelated-histories -``` - -4. The previous step will likely result in several merge conflicts. Solve the conflicts by editing the files. -5. Once all conflicts have been resolved then add all the files to GitHub: -```shell -$ git add --all -$ git commit -m "Merged existing code with code generated by cookiecutter" -$ git push -``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 8978bd94..19e06afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,73 @@ # Change Log -## Unreleased +## [Unreleased] + +### Added + +### Changed + +### Removed + +## 0.6.1 + +### Added + +* Add .gitignore and .editorconfig to the list of files that are not updated if they exist [#655](https://github.com/NLeSC/python-template/pull/655) + +### Changed + +* copyright owner is asked in all profiles [#629](https://github.com/NLeSC/python-template/pull/629) +* license files includes year and copyright owner information [#629](https://github.com/NLeSC/python-template/pull/629) +* combine all the next step jobs in a single workflow [#657](https://github.com/NLeSC/python-template/pull/657) +* fix CITATION.cff validation issues which also helps cffconvert workflow to pass [#657](https://github.com/NLeSC/python-template/pull/657) + +### Removed + +* Remove pyproject.toml and CITATION.cff from the list of files that are not updated if they exist [#655](https://github.com/NLeSC/python-template/pull/655) + +## [0.6.0] + +### Added + +* Keep project_setup.md for all the profiles and remove from the menu [#576](https://github.com/NLeSC/python-template/pull/576) +* Make contributing guidelines optional [#465](https://github.com/NLeSC/python-template/pull/465) +* Make linting optional [#568](https://github.com/NLeSC/python-template/pull/568) +* Make editorconfig optional [#571](https://github.com/NLeSC/python-template/pull/571) +* Make contributing guidelines optional [#465](https://github.com/NLeSC/python-template/pull/465) +* Make developer documentation optional [#467](https://github.com/NLeSC/python-template/pull/541) +* Make Code of Conduct optional [#464](https://github.com/NLeSC/python-template/pull/530) +* New YAML files for copier questions [#529](https://github.com/NLeSC/python-template/pull/529) +* Make zenodo next step instructions optional [#520](https://github.com/NLeSC/python-template/pull/520) +* Make SonarCloud optional [#515](https://github.com/NLeSC/python-template/pull/515) +* Make citation optional [#471](https://github.com/NLeSC/python-template/pull/471) +* Make online documentation optional [#476](https://github.com/NLeSC/python-template/pull/476) +* Make local documentation optional [#593](https://github.com/NLeSC/python-template/pull/593) +* Make local test optional [#594](https://github.com/NLeSC/python-template/pull/594) + +### Changed + +* Update the user documentation (README.md) of the template [#575](https://github.com/NLeSC/python-template/pull/623) +* Updated .gitignore [#622](https://github.com/NLeSC/python-template/pull/622) +* add extra info for sub-menus [#628](https://github.com/NLeSC/python-template/pull/628) +* skip merging CHANGELOG.md and CODE_OF_CONDUCT.md if they exist [#628](https://github.com/NLeSC/python-template/pull/628) +* added value field to license options [#617](https://github.com/NLeSC/python-template/pull/617) +* fix filename typo of githooks [#611](https://github.com/NLeSC/python-template/pull/609) +* next_steps.md is shown as a copier message [#609](https://github.com/NLeSC/python-template/pull/609) +* Change the default profile to 'recommended' [#598](https://github.com/NLeSC/python-template/pull/598) +* Updated the user documentation (README.md) of the template [#569](https://github.com/NLeSC/python-template/pull/569) +* Droped Python 3.8 and 3.9 support [#551](https://github.com/NLeSC/python-template/pull/551) +* Fix broken link checker [#546](https://github.com/NLeSC/python-template/pull/546) +* pre-commit script is optional ([#457](https://github.com/NLeSC/python-template/issues/457)) +* CHANGELOG.md is now optional ([#462](https://github.com/NLeSC/python-template/issues/462)) +* Restored default line-length of 79 characters, as recommended by [PEP-8](https://peps.python.org/pep-0008/#maximum-line-length) [#389](https://github.com/NLeSC/python-template/pull/389) + +### Removed + +* Remove the configuration of isort ([#591](https://github.com/NLeSC/python-template/pull/591)), which is no longer used since [#347](https://github.com/NLeSC/python-template/issues/347). + +## [0.5.0] + +Released on August 15, 2024 ### Added @@ -13,6 +80,9 @@ ### Changed +* Made copier configuration more modular [#529](https://github.com/NLeSC/python-template/pull/529) +* pre-commit script is optional ([#457](https://github.com/NLeSC/python-template/issues/457)) +* CHANGELOG.md is now optional ([#462](https://github.com/NLeSC/python-template/issues/462)) * Moved to src/ based layout for generated packages * Moved from setup.cfg/.py to pyproject.toml [#351](https://github.com/NLeSC/python-template/issues/351) * Moved from prospector to ruff [#336](https://github.com/NLeSC/python-template/issues/336) @@ -38,7 +108,9 @@ * Statements in project_setup.md already mentioned in README.dev.md * .zenodo.json is no longer necessary, CITATION.cff also works with Zenodo. -## 0.4.0 +## [0.4.0] + +Released on May 3, 2021 ### Added @@ -68,7 +140,9 @@ * Automatic publish to PyPi after GitHub release [#196](https://github.com/NLeSC/python-template/issues/196) -## 0.3.0 +## [0.3.0] + +Released on Apr 22, 2021 ### Added @@ -99,14 +173,14 @@ * Updated Code of Conduct for generated package * Improved the documentation for the generated package and template itself -## Removed +### Removed + * Dropped appveyor [#160](https://github.com/NLeSC/python-template/issues/160) * Dropped everything Conda related * Drop Python 3.5 support * Removed unit tests doing the linting - -## 0.2.0 +## [0.2.0] Released on July 17, 2019 @@ -131,36 +205,43 @@ Released on July 17, 2019 * Fix example tests that failed to run (#28) * Remove quotes from project name and project description (#27) * Update prospector configuration (#26) - - Make prospector less strict - - Have prospector ignore the docs directory + * Make prospector less strict + * Have prospector ignore the docs directory * Add `install_requires` to `setup.py` (#21) * Improved .gitignore (#22) * More detailed documentation about - - Project setup - - Setup instructions - - NOTICE file + * Project setup + * Setup instructions + * NOTICE file ### Removed * Python 2 support -## 0.1.0 +## [0.1.0] Released on July 12, 2018. ### Added * First version of the Python project template that follows the Netherlands eScience Center software development guide, containing: - - Tests, - - Documentation, - - Code style checking - - Editorconfig - - Default Travis configuration - - Change log - - Code of Conduct - - Contributing guidelines - - License - - Manifest.in - - README - - Requirements.txt - - Setup configuration + * Tests, + * Documentation, + * Code style checking + * Editorconfig + * Default Travis configuration + * Change log + * Code of Conduct + * Contributing guidelines + * License + * Manifest.in + * README + * Requirements.txt + * Setup configuration + +[Unreleased]: https://github.com/NLeSC/python-template//compare/0.5.0...HEAD +[0.5.0]: https://github.com/NLeSC/python-template/releases/tag/0.5.0 +[0.4.0]: https://github.com/NLeSC/python-template/releases/tag/0.4.0 +[0.3.0]: https://github.com/NLeSC/python-template/releases/tag/0.3.0 +[0.2.0]: https://github.com/NLeSC/python-template/releases/tag/0.2.0 +[0.1.0]: https://github.com/NLeSC/python-template/releases/tag/0.1.0 diff --git a/CITATION.cff b/CITATION.cff index 045e0e43..098fc45d 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -68,15 +68,31 @@ authors: family-names: Tjong Kim Sang given-names: Erik orcid: "https://orcid.org/0000-0002-8431-081X" + - given-names: Abel + family-names: Soares Siqueira + email: abel.s.siqueira@gmail.com + affiliation: Netherlands eScience Center + orcid: "https://orcid.org/0000-0003-4451-281X" + - given-names: Olga + family-names: Lyashevska + email: o.lyashevska@esciencecenter.nl + affiliation: Netherlands eScience Center + orcid: 'https://orcid.org/0000-0002-8686-8550' + - given-names: Sander + name-particle: van + family-names: Rijn + email: s.vanrijn@esciencecenter.nl + affiliation: Netherlands eScience Center + orcid: 'https://orcid.org/0000-0001-6159-041X' cff-version: "1.2.0" date-released: 2018-07-17 doi: 10.5281/zenodo.1310751 keywords: - - cookiecutter + - copier - template - Python license: Apache-2.0 message: "If you use this software, please cite it using these metadata." repository-code: "https://github.com/NLeSC/python-template" title: "Netherlands eScience Center Python Template" -version: "0.4.0" +version: "0.6.1" diff --git a/NOTICE b/NOTICE index c1991889..b17007cf 100644 --- a/NOTICE +++ b/NOTICE @@ -1,2 +1,2 @@ -NLeSC Cookiecutter template for Python +NLeSC Copier template for Python Copyright 2021, Netherlands eScience Center diff --git a/README.dev.md b/README.dev.md index 1039a9a9..c269eee8 100644 --- a/README.dev.md +++ b/README.dev.md @@ -4,15 +4,17 @@ If you're looking for user documentation, go [here](README.md). ## Development install -### Install `cookiecutter` in user space +### Install `copier` in user space -We recommend installing `cookiecutter` in user space as per `cookiecutter`'s instructions. This way, you don't have to -install `cookiecutter` for every new project. +We recommend installing `copier` in user space. This way, you don't have to +install `copier` for every new project. ```shell -python -m pip install --user --upgrade cookiecutter +python -m pip install --user --upgrade copier ``` + + ### Get your own copy of the repository 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 cd python-template ``` +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: + +```shell +git fetch origin +git switch -c dev origin/dev +``` + ### Create a virtual environment Next, make a virtual environment, activate it, and install the development dependencies in it. This will enable you to @@ -53,7 +62,7 @@ pytest pytest tests/ ``` -## Using `cookiecutter` to generate a new package from the command line +## Using `copier` to generate a new package from the command line While making changes to the template, you'll regularly want to verify that the packages generated with the template still work. Any easy way to do this is to generate new packages in a temporary directory (which will get removed @@ -61,10 +70,10 @@ everytime you reboot), for example like so: ```shell # change directory to a new temporary directory -cd $(mktemp -d --tmpdir cookiecutter-generated.XXXXXX) +cd $(mktemp -d --tmpdir copier-generated.XXXXXX) -# run cookiecutter with the template to generate a new package -cookiecutter +# run copier with the template to generate a new package +copier copy --vcs-ref HEAD my-python-project # when it asks you for the GitHub organization, put in your own name; # for the other questions, just accept the default @@ -72,8 +81,9 @@ cookiecutter # 'ls' should return just the one directory called 'my-python-project' ls ``` +Notice, that the `--vcs-ref HEAD` flag is used to make sure that the current checked out version of the local template is used. -If your Python package was created successfully, `cookiecutter` will point you to a file +If your Python package was created successfully, `copier` will point you to a file (`my-python-project/next_steps.md`) that contains information on next steps. 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 2. Verify that the information in `CITATION.cff` is correct. 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 4. Run the unit tests with `pytest tests/` -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. +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. ### GitHub diff --git a/README.md b/README.md index e23cebc9..be009ee2 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,47 @@ # Netherlands eScience Center Python Template -Spend less time setting up and configuring your new Python packages and comply with the -[Netherlands eScience Center Software Development Guide](https://guide.esciencecenter.nl/) -from the start. +Python Template logo, created using ChatGPT 4o on 10 September 2024 using prompt "generate a logo of a copier that looks like a snake-scientist" -Use this [Cookiecutter](https://cookiecutter.readthedocs.io) template to generate -an empty Python package. Features include: +Spend less time setting up and configuring your new Python packages by using this template. This [Copier](https://copier.readthedocs.io) template includes best practices for research software so your new package will include these practices from the start. + +You can choose from various user profiles, each offering a range of features to suit your needs. + +## User profiles + +The template profiles for a Python package offer varying levels of customization to cater to different user needs. Below are the profiles the template offers. + +### Minimum + +This profile offers the essential features to begin developing a Python package, making it ideal for first-time research software developers. Additional features can be added as needed. + +### Recommended + +This option provides a pre-selected set of features for research software, which users can fully customize. + +### Let me choose + +This fully customizable profile enables you to selectively include or exclude features in your Python package. + +## Features - Boilerplate unit tests and documentation, -- [Python static setup configuration]({{cookiecutter.directory_name}}/pyproject.toml), +- [Python static setup configuration](template/pyproject.toml.jinja), - Open source software license, -- Continuous integration with [GitHub action workflows]({{cookiecutter.directory_name}}/.github/workflows) for building, testing, link checking and linting, +- Continuous integration with [GitHub action workflows](template/.github/workflows) for building, testing, link checking and linting, - Code style checking with [ruff](https://beta.ruff.rs/), -- [Editorconfig]({{cookiecutter.directory_name}}/.editorconfig), +- [Editorconfig](template/.editorconfig), - Usage and contribution documents: - - [README.md]({{cookiecutter.directory_name}}/README.md) for package users, - - [README.dev.md]({{cookiecutter.directory_name}}/README.dev.md) for package developer, - - [project_setup.md]({{cookiecutter.directory_name}}/project_setup.md) with extensive documentation about project setup, - - [Change log]({{cookiecutter.directory_name}}/CHANGELOG.md), - - [Code of Conduct]({{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md), - - [Contributing guidelines]({{cookiecutter.directory_name}}/CONTRIBUTING.md), + - [README.md](template/README.md.jinja) for package users, + - [README.dev.md](template/README.dev.md.jinja) for package developer, + - [project_setup.md](template/project_setup.md.jinja) with extensive documentation about project setup, + - [Changelog](template/%7B%25%20if%20AddChangeLog%20%25%7DCHANGELOG.md%7B%25%20endif%20%25%7D), + - [Code of Conduct](template/CODE_OF_CONDUCT.md.jinja), + - [Contributing guidelines](template/CONTRIBUTING.md.jinja), - Continuous code quality and code coverage reporting using [Sonarcloud](https://sonarcloud.io/), -- Automatic creation of [issues]({{cookiecutter.directory_name}}/.github/next_steps) with instructions how to pass all GitHub action workflows and integrate with services like Zenodo and Read the Docs, -- Instructions how to make package [citable]({{cookiecutter.directory_name}}/.github/next_steps/02_citation.md) +- 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, +- Instructions how to make package [citable](.github/next_steps/%7B%25%20if%20AddCitation%20%25%7D02_citation.md%7B%25%20endif%20%25%7D.jinja) - FAIR software recommendation badge, -- Optional [pre commit hook]({{cookiecutter.directory_name}}/README.dev.md#running-linters-locally) to catch lint errors early +- Optional [pre commit hook](template/README.dev.md.jinja#running-linters-locally) to catch lint errors early ## Badges @@ -40,106 +57,91 @@ an empty Python package. Features include: |   |   | | **GitHub Actions** |   | | Citation metadata consistency | [![cffconvert](https://github.com/nlesc/python-template/actions/workflows/cffconvert.yml/badge.svg)](https://github.com/nlesc/python-template/actions/workflows/cffconvert.yml) | -| MarkDown link checker | [![markdown-link-check](https://github.com/nlesc/python-template/actions/workflows/markdown-link-check.yml/badge.svg)](https://github.com/nlesc/python-template/actions/workflows/markdown-link-check.yml) | +| Link checker | [![link-check](https://github.com/nlesc/python-template/actions/workflows/link-check.yml/badge.svg)](https://github.com/nlesc/python-template/actions/workflows/link-check.yml) | | Tests | [![tests](https://github.com/nlesc/python-template/actions/workflows/tests.yml/badge.svg)](https://github.com/nlesc/python-template/actions/workflows/tests.yml) | ## How to use -### Step 1/3: Install `cookiecutter` +There are multiple scenarios to use this template: -We recommend installing `cookiecutter` in user space as per `cookiecutter`'s instructions. This way, you don't have to -install `cookiecutter` for every new project. +- [Scenario 1](#scenario-1-create-a-new-package): Generating a new package using 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, which we +recommend doing with [`pipx`](https://github.com/pypa/pipx): ```shell -python -m pip install --user --upgrade cookiecutter +python3 -m pip install --user pipx +python3 -m pipx ensurepath +pipx install copier ``` -### Step 2/3: Generate the files and directory structure +> [!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 -Run `cookiecutter` with the template: +Run `copier copy` with the template: ```shell -# Notes: -# 1. See table below for explanation of each question -# 2. The files will be generated in a new directory -cookiecutter https://github.com/nlesc/python-template.git +copier copy https://github.com/nlesc/python-template.git path/to/destination ``` -| Name | Default value | Explanation | -| ------------------------- | ------------- | ----------- | -| 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) | -| package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. | -| 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. | -| keyword1 | keyword1 | A term that describes your package. | -| keyword2 | keyword2 | Another term that describes your package. | -| version | 0.1.0 |   | -| github_organization | <my-github-organization> | GitHub organization that will contain this project's repository. This can also be your GitHub user name. | -| license | Apache Software License 2.0 | The software license under which the code is made available. | -| full_name | Jane Smith | Your full name, e.g. _Jane Smith_. | -| email | yourname@esciencecenter.nl | Your (work) email address. | -| copyright_holder | Netherlands eScience Center | Name(s) of the organization(s) or person(s) who hold the copyright of the software. | -| 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. | - -Once the project files have been generated, follow the steps outlined in -[{{cookiecutter.directory_name}}/next_steps.md]({{cookiecutter.directory_name}}/next_steps.md). - -### Step 3/3: Read about what was just generated - -Good job! You have now generated the skeleton for your package: - -```text -my-python-project/ -├── .editorconfig -├── .githooks -│ └── pre-commit -├── .github -│ ├── next_steps -│ │ ├── 01_sonarcloud_integration.md -│ │ ├── 02_citation.md -│ │ ├── 03_readthedocs.md -│ │ ├── 04_zenodo_integration.md -│ │ └── 05_linting.md -│ └── workflows -│ ├── build.yml -│ ├── cffconvert.yml -│ ├── documentation.yml -│ ├── markdown-link-check.yml -│ ├── next_steps.yml -│ └── sonarcloud.yml -├── .gitignore -├── .mlc-config.json -├── .readthedocs.yaml -├── CHANGELOG.md -├── CITATION.cff -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md -├── LICENSE -├── MANIFEST.in -├── NOTICE -├── README.dev.md -├── README.md -├── docs -│ ├── Makefile -│ ├── _templates -│ │ └── .gitignore -│ ├── conf.py -│ ├── index.rst -│ └── make.bat -├── next_steps.md -├── project_setup.md -├── pyproject.toml -├── sonar-project.properties -├── src -│ └── my_python_package -│ ├── __init__.py -│ └── my_module.py -└── tests - ├── __init__.py - └── test_my_module.py +> [!NOTE] +> 1. Make sure that `path/to/destination` is an empty directory +> 1. Based on the profile and selected features, the package will be generated in the specified destination directory + +For an explanation of what's there, read on in the `project_setup.md` file. + +### Scenario 2: Apply to pre-existing code + +To apply the template to pre-existing code, you can use the same `copier copy` +command as when creating a new package, except that you point to the folder +containing your existing code rather than a new one: + +```shell +copier copy https://github.com/nlesc/python-template.git path/to/existing/code ``` -For an explanation of what's there, read on in the [project_setup.md]({{cookiecutter.directory_name}}/project_setup.md) file. -There are also instructions on how to [apply the template to an existing Python package](ADD_TO_EXISTING_PACKAGE.md). +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 +recommended to answer 'yes' for all files, you will still be able to review +the changes suggested by the template. + +### Scenario 3. Updating a template-made package + +Copier provides the functionality for re-applying the template to a previously +created project using the `copier update` command. This has two effects: + +1. Your project will be updated according to the latest version of the template +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 +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 +the template since you last applied it. + +```shell +copier update --skip-answered +``` ## Examples diff --git a/cookiecutter.json b/cookiecutter.json deleted file mode 100644 index 60d0b3f3..00000000 --- a/cookiecutter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "directory_name": "my-python-project", - "package_name": "my_python_package", - "package_short_description": "Short description of package", - "keyword1": "keyword1", - "keyword2": "keyword2", - "version": "0.1.0", - "github_organization": "", - "license": ["Apache Software License 2.0", "MIT license", "BSD license", "ISC license", "GNU General Public License v3 or later", "GNU Lesser General Public License v3 or later", "Not open source"], - "full_name": "Jane Smith", - "email": "yourname@esciencecenter.nl", - "copyright_holder": "Netherlands eScience Center", - "code_of_conduct_email": "{{ cookiecutter.email }}" -} diff --git a/copier.yml b/copier.yml new file mode 100644 index 00000000..b9ef5ab7 --- /dev/null +++ b/copier.yml @@ -0,0 +1,39 @@ +--- +# General settings for copier +!include copier/settings.yml + +--- +# profiles +!include copier/profiles.yml + +--- +# essential questions about the package details +!include copier/questions/essential.yml + +--- +# additional questions about the package details +!include copier/questions/package_details.yml + +--- +# code quality features +!include copier/questions/features_code_quality.yml + +--- +# publish and release features +!include copier/questions/features_publish_release.yml + +--- +# publish and release features +!include copier/questions/features_documentation.yml + +--- +# community features +!include copier/questions/features_community.yml + +--- +# global flags +!include copier/global_flags.yml + +--- +# User messages +!include copier/messages.yml diff --git a/copier/global_flags.yml b/copier/global_flags.yml new file mode 100644 index 00000000..11702aeb --- /dev/null +++ b/copier/global_flags.yml @@ -0,0 +1,16 @@ +--- +# Computed values that depend on multiple values + +HasWorkflows: + type: bool + default: "{{ + AddGitHubActionBuild + or AddGitHubActionDocumentation + or AddLinkCheck + or AddCFFConvert + or AddCitation + or AddOnlineDocumentation + or AddSonarCloud + or AddZenodo + or AddLinting }}" + when: false diff --git a/copier/messages.yml b/copier/messages.yml new file mode 100644 index 00000000..446af77b --- /dev/null +++ b/copier/messages.yml @@ -0,0 +1,53 @@ +# user messages +_message_before_copy: | + Thanks for generating a project using our template. + + You'll be asked a series of questions whose answers will be used to + generate a tailored project for you. + + For each question there is a placeholder. Make sure you provide an + input to each of them. + +_message_after_copy: | + Your project "{{ package_name }}" has been successfully created in {{ _copier_conf.dst_path }} folder! + + {% if template_profile != 'minimum' -%} + + Next steps: + + - Below are the commands to put your Python package under using git: + + cd {{ _copier_conf.dst_path }} + git init + git add --all + git commit -m "first commit" + git branch -M main + git remote add origin {{ repository }}.git + + - Push the initial commit to a new repo on GitHub + + Go to https://github.com/organizations/{{github_organization}}/repositories/new + and create a new repository named `{{ package_name }}` as an empty repository, then push your commits to GitHub: + + git push --set-upstream origin main + {% if AddDevDoc %} + - Project development documentation + + The README.dev.md contains developer documentation + {% endif %} + - Project layout explained + + For an explanation of what files are there, and what each of these do, please refer to {{ _copier_conf.dst_path }}/project_setup.md + + {%- endif-%} + +_message_before_update: | + Thanks for updating your project using our template. + + You'll be asked a series of questions whose answers are pre-populated + with previously entered values. Feel free to change them as needed. + +_message_after_update: | + Your project "{{ package_name }}" has been updated successfully! + In case there are any conflicts, please resolve them. Then, + you're done. diff --git a/copier/profiles.yml b/copier/profiles.yml new file mode 100644 index 00000000..30f1d472 --- /dev/null +++ b/copier/profiles.yml @@ -0,0 +1,10 @@ +--- +# profile selection +template_profile: + type: str + default: "recommended" + help: Select a profile + choices: + Recommended (our defaults for research software): "recommended" + Minimum (bare minimum, no extra features): "minimum" + Let me choose (decide each feature yourself): "ask" diff --git a/copier/questions/essential.yml b/copier/questions/essential.yml new file mode 100644 index 00000000..d300c667 --- /dev/null +++ b/copier/questions/essential.yml @@ -0,0 +1,53 @@ +--- +# Essential questions +package_name: + type: str + placeholder: your_python_package + help: Enter the name of the Python package + validator: >- + {% if not (package_name | regex_search('^[a-z][a-z0-9\_]+$')) %} + Package name must start with a letter, followed one or more letters, digits or underscores all lowercase + {% endif %} +version: + type: str + default: 0.1.0 + help: Enter the version of the Python package + validator: >- + {% if not (version | regex_search('^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')) %} + Package version should use Semantic Versioning 2.0.0 (MAJOR.MINOR.PATCH) + {% endif %} +full_name: + type: str + placeholder: Jane Smith + help: Enter your full name + validator: >- + {% if not full_name %} + Full name cannot be empty! + {% endif %} +license: + type: str + default: "Apachev2" + help: "Select a license (see: https://choosealicense.com)" + choices: + Apache License, Version 2.0: + value: Apachev2 + MIT license: + value: MIT + BSD license (3-clause): + value: BSD + ISC license: + value: ISC + GNU General Public License v3 or later: + value: GNUv3 + GNU Lesser General Public License v3 or later: + value: GNULesserv3 + Other (add your own license): + value: Other +copyright_holder: + type: str + default: "{{ full_name }}" + help: "Who is the copyright holder (default: full name)?" + validator: >- + {% if not copyright_holder %} + This field cannot be empty as it will be used in content of the generated files. + {% endif %} diff --git a/copier/questions/features_code_quality.yml b/copier/questions/features_code_quality.yml new file mode 100644 index 00000000..82a0afc7 --- /dev/null +++ b/copier/questions/features_code_quality.yml @@ -0,0 +1,89 @@ +--- +# Questions for code quality features + +# the main menu +SelectCodeQualityFeatures: + when: "{{ template_profile != 'minimum' }}" + type: yaml + default: |- + {% if template_profile == 'recommended' %} + [AddLocalTests_flag, SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, AddEditorConfig_flag] + {%- else -%} + [] + {%- endif %} + help: Select code quality features + multiselect: true + choices: + Unit tests (using pytest): + value: AddLocalTests_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + GitHub Actions (select in the next step): + value: SelectGitHubActions_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Linting: + value: AddLinting_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Pre-commit: + value: AddPreCommit_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Code analysis (using SonarCloud): + value: AddSonarCloud_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Editorconfig: + value: AddEditorConfig_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + + +# Sub-menus +SelectGitHubActions: + when: "{{ 'SelectGitHubActions_flag' in SelectCodeQualityFeatures }}" + type: yaml + default: |- + {% if template_profile == 'recommended' %} + [AddGitHubActionBuild_flag] + {%- else -%} + [] + {%- endif %} + help: Select GitHub Action workflows + multiselect: true + choices: + Build: + value: AddGitHubActionBuild_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Link checker (reports broken URLs): + value: AddLinkCheck_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + + +# computed features +AddLocalTests: + type: bool + default: "{{ + 'AddLocalTests_flag' in SelectCodeQualityFeatures + or 'AddGitHubActionBuild_flag' in SelectGitHubActions + or 'AddSonarCloud_flag' in SelectCodeQualityFeatures }}" + when: false +AddGitHubActionBuild: + type: bool + default: "{{ 'AddGitHubActionBuild_flag' in SelectGitHubActions }}" + when: false +AddLinkCheck: + type: bool + default: "{{ 'AddLinkCheck_flag' in SelectGitHubActions }}" + when: false +AddPreCommit: + type: bool + default: "{{ 'AddPreCommit_flag' in SelectCodeQualityFeatures }}" + when: false +AddSonarCloud: + type: bool + default: "{{ 'AddSonarCloud_flag' in SelectCodeQualityFeatures }}" + when: false +AddLinting: + type: bool + default: "{{ 'AddLinting_flag' in SelectCodeQualityFeatures }}" + when: false +AddEditorConfig: + type: bool + default: "{{ 'AddEditorConfig_flag' in SelectCodeQualityFeatures }}" + when: false diff --git a/copier/questions/features_community.yml b/copier/questions/features_community.yml new file mode 100644 index 00000000..36e6fb25 --- /dev/null +++ b/copier/questions/features_community.yml @@ -0,0 +1,42 @@ +--- +# Questions for community features + +# the main menu +SelectCommunityFeatures: + when: "{{ template_profile != 'minimum' }}" + type: yaml + default: |- + {% if template_profile == 'recommended' %} + [AddCodeConduct_flag, AddContributing_flag] + {%- else -%} + [] + {%- endif %} + help: Select community features + multiselect: true + choices: + Code of conduct: + value: AddCodeConduct_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Contributing guidelines: + value: AddContributing_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + +code_of_conduct_email: + when: "{{ 'AddCodeConduct_flag' in SelectCommunityFeatures }}" + type: str + default: "{{ email }}" + help: What is the email address to report code of conduct violations? + validator: >- + {% if not (code_of_conduct_email | regex_search('([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')) %} + Please enter a valid email address + {% endif %} + +# computed features +AddCodeConduct: + type: bool + default: "{{ 'AddCodeConduct_flag' in SelectCommunityFeatures }}" + when: false +AddContributing: + type: bool + default: "{{ 'AddContributing_flag' in SelectCommunityFeatures }}" + when: false diff --git a/copier/questions/features_documentation.yml b/copier/questions/features_documentation.yml new file mode 100644 index 00000000..cc4098d3 --- /dev/null +++ b/copier/questions/features_documentation.yml @@ -0,0 +1,46 @@ +--- +# Questions for documentation features + +# the main menu +SelectDocumentationFeatures: + when: "{{ template_profile != 'minimum' }}" + type: yaml + default: |- + {% if template_profile == 'recommended' %} + [AddLocalDocumentation_flag, AddOnlineDocumentation_flag, AddDevDoc_flag, AddGitHubActionDocumentation_flag] + {%- else -%} + [] + {%- endif %} + help: Select documentation features + multiselect: true + choices: + Local documentation (using sphinx): + value: AddLocalDocumentation_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Online documentation (using Read the Docs): + value: AddOnlineDocumentation_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Developer documentation: + value: AddDevDoc_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + GitHub Action to build documentation: + value: AddGitHubActionDocumentation_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + +# computed features +AddLocalDocumentation: + type: bool + default: "{{ 'AddLocalDocumentation_flag' in SelectDocumentationFeatures or 'AddOnlineDocumentation_flag' in SelectDocumentationFeatures or 'AddGitHubActionDocumentation_flag' in SelectDocumentationFeatures }}" + when: false +AddOnlineDocumentation: + type: bool + default: "{{ 'AddOnlineDocumentation_flag' in SelectDocumentationFeatures }}" + when: false +AddDevDoc: + type: bool + default: "{{ 'AddDevDoc_flag' in SelectDocumentationFeatures }}" + when: false +AddGitHubActionDocumentation: + type: bool + default: "{{ 'AddGitHubActionDocumentation_flag' in SelectDocumentationFeatures }}" + when: false diff --git a/copier/questions/features_publish_release.yml b/copier/questions/features_publish_release.yml new file mode 100644 index 00000000..953ff204 --- /dev/null +++ b/copier/questions/features_publish_release.yml @@ -0,0 +1,65 @@ +--- +# Questions for publishing and releasing features + +# the main menu +SelectPublishReleaseFeatures: + when: "{{ template_profile != 'minimum' }}" + type: yaml + default: |- + {% if template_profile == 'recommended' %} + [SelectCitation_flag, AddZenodo_flag] + {%- else -%} + [] + {%- endif %} + help: Select publish and release features + multiselect: true + choices: + Citation (select in the next step): + value: SelectCitation_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Changelog: + value: AddChangeLog_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + Zenodo integration instructions: + value: AddZenodo_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + +# Sub-menus +# split AddCitation --> enable_citation_file and enable_cffconvert +SelectCitation: + when: "{{ 'SelectCitation_flag' in SelectPublishReleaseFeatures }}" + type: yaml + default: |- + {% if template_profile == 'recommended' %} + [AddCitationFile_flag, AddCFFConvert_flag] + {%- else -%} + [] + {%- endif %} + help: Select citation features + multiselect: true + choices: + CITATION.cff file: + value: AddCitationFile_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + cffconvert GitHub Action (to validate CITATION.cff files): + value: AddCFFConvert_flag + # validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}" + + +# computed features +AddCitation: + type: bool + default: "{{ 'AddCitationFile_flag' in SelectCitation }}" + when: false +AddCFFConvert: + type: bool + default: "{{ 'AddCFFConvert_flag' in SelectCitation }}" + when: false +AddChangeLog: + type: bool + default: "{{ 'AddChangeLog_flag' in SelectPublishReleaseFeatures }}" + when: false +AddZenodo: + type: bool + default: "{{ 'AddZenodo_flag' in SelectPublishReleaseFeatures }}" + when: false diff --git a/copier/questions/package_details.yml b/copier/questions/package_details.yml new file mode 100644 index 00000000..a163d554 --- /dev/null +++ b/copier/questions/package_details.yml @@ -0,0 +1,46 @@ +--- +# package details +# AddPackageDetails: +# type: bool +# default: yes +# help: |- +# If you are planning to publish the package it is recommended to provide more details. +# Do you want to provide extra details for the package? +# when: false +package_short_description: + type: str + placeholder: Short description + help: Short description of package + validator: >- + {% if not package_short_description %} + Package description cannot be empty + {% endif %} +keywords: + type: str + placeholder: keyword1,second keyword,third keyword + help: Add keywords to make your package findable on PyPI (comma-separated) +github_organization: + type: str + placeholder: "your_github_username or your_github_organization" + help: Enter the name of your GitHub username or organization + validator: >- + {% if not (github_organization | regex_search('^\\S*$')) %} + Username or organization cannot include spaces + {% endif %} +email: + type: str + placeholder: yourname@universe.com + help: What is your email address? + validator: >- + {% if not (email | regex_search('([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')) %} + Please enter a valid email address + {% endif %} + + +# computed fields +repository: + default: git@github.com:{{ github_organization }}/{{ package_name }} + when: false +repository_url: + default: https://github.com/{{ github_organization }}/{{ package_name }} + when: false diff --git a/copier/settings.yml b/copier/settings.yml new file mode 100644 index 00000000..2593015b --- /dev/null +++ b/copier/settings.yml @@ -0,0 +1,10 @@ +# internal fields +_subdirectory: template + +# Settings like `_skip_if_exists` are merged +_skip_if_exists: + - LICENSE + - CHANGELOG.md + - CODE_OF_CONDUCT.md + - .gitignore + - .editorconfig diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py deleted file mode 100644 index f7ceaa80..00000000 --- a/hooks/post_gen_project.py +++ /dev/null @@ -1 +0,0 @@ -print("\nProject was successfully generated. For next steps, refer to file {{ cookiecutter.directory_name }}/next_steps.md.\n") diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py deleted file mode 100644 index 665cbe50..00000000 --- a/hooks/pre_gen_project.py +++ /dev/null @@ -1,11 +0,0 @@ -# Note: cookiecutter first makes the main level directory using -# directory_name from cookiecutter.json before running this hook - -{{ cookiecutter.update({ - "package_name": cookiecutter.package_name.lower().replace(" ", "_").replace("-", "_"), - "directory_name": cookiecutter.directory_name.lower().replace(" ", "-"), - "full_name": cookiecutter.full_name.replace('\"', '\\\"'), - "repository": "git@github.com:" + cookiecutter.github_organization + "/" + cookiecutter.directory_name.lower().replace(" ", "-"), - "repository_url": "https://github.com/" + cookiecutter.github_organization + "/" + cookiecutter.directory_name.lower().replace(" ", "-"), - "package_short_description": cookiecutter.package_short_description.replace('\"', '\\\"') -}) }} diff --git a/logo.png b/logo.png new file mode 100644 index 00000000..244634c6 Binary files /dev/null and b/logo.png differ diff --git a/profiles.md b/profiles.md new file mode 100644 index 00000000..a8582322 --- /dev/null +++ b/profiles.md @@ -0,0 +1,54 @@ +# Template Profiles +- package_name: +- version: +- template_profile: + - minumum --> DONE + - recommeded --> all questions - excluded with the defaults + - optional --> all questions with answers off + +- github_organization: +- full_name: +- email: +- copyright_holder: +- licence (exist) + +- community: + - code of conduct --> if TRUE ask for email + - contributing guidelines + +- documentation + - developer documentation + - online documentation (read the docs) + - project_setup.md + +- code quality: + - sonarcloud #515 + - ruff and lint workflow + - github action to build (exist) #451 + - pre-commit + - .editorconfig + +- publishing and release + - zenodo #520 + - keywords + - changelog.md + - cffconvert workflow and citation file + +- markdown link checker workflow + +## Minimum + +- src/ +- docs/ +- test/ +- pyproject.toml +- README.md +- .gitignore +- MANIFEST.in +- LICENCE + +## Questions to exclude from recommended +- Link checker +- pre-commit +- changelog.md +- project_setup.md diff --git a/setup.cfg b/setup.cfg index 5aef0661..f82fc793 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,28 +12,26 @@ classifiers = License :: OSI Approved :: Apache Software License Natural Language :: English Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 -description = Cookiecutter template to initialize Python projects in accordance with Netherlands eScience Center best practices +description = Copier template to initialize Python projects in accordance with Netherlands eScience Center best practices long_description = file: README.md long_description_content_type = text/markdown name = Netherlands eScience Center Python Template project_urls = Bug Tracker = https://github.com/NLeSC/python-template/issues url = https://github.com/NLeSC/python-template -version = 0.4.0 +version = 0.6.1 [options] zip_safe = False include_package_data = True -python_requires = >=3.8 +python_requires = >=3.10 packages = install_requires = - cookiecutter==1.7.2 + copier==9.2.0 [options.data_files] # This section requires setuptools>=40.6.0 @@ -45,9 +43,9 @@ install_requires = dev = coverage [toml] pytest - pytest-cookies + pytest-copie>=0.2.1 [tool:pytest] testpaths = tests -norecursedirs = .git .github hooks {{cookiecutter.directory_name}} +norecursedirs = .git .github hooks template diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 00000000..dd8a4fa2 --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,69 @@ +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class +__pycache__ + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# jupyter notebook +.ipynb_checkpoints + +# Unit test / coverage reports +htmlcov/ +.coverage +.coverage.* +coverage.xml +.cache +.pytest_cache +.tox/ + +# Sphinx documentation +docs/_build + +# ide +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ +.spyderproject +.spyproject + +# Mac +.DS_Store + +# virtual environments +env +.env +env3 +.env3 +venv +.venv +venv3 +.venv3 +ENV/ +env.bak/ +venv.bak/ + +# vim +*.swp +*.swo +*.orig diff --git a/template/MANIFEST.in.jinja b/template/MANIFEST.in.jinja new file mode 100644 index 00000000..67ee1713 --- /dev/null +++ b/template/MANIFEST.in.jinja @@ -0,0 +1,4 @@ +{% if AddCitation -%}include CITATION.cff{%- endif %} +include LICENSE +include NOTICE +include README.md diff --git a/template/README.md.jinja b/template/README.md.jinja new file mode 100644 index 00000000..8523375a --- /dev/null +++ b/template/README.md.jinja @@ -0,0 +1,62 @@ +## Badges + +(Customize these badges with your own links, and check https://shields.io/ or https://badgen.net/ to see which other badges are available.) + +| fair-software.eu recommendations | | +| :-- | :-- | +| (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)]({{repository_url}}) | +| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{github_organization}}/{{package_name}})]({{repository_url}}) | +| (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}}/) | +| (4/5) citation | {% if AddZenodo -%} [![DOI](https://zenodo.org/badge/DOI/.svg)](https://doi.org/){%- endif -%} | +| (5/5) checklist | [![workflow cii badge](https://bestpractices.coreinfrastructure.org/projects//badge)](https://bestpractices.coreinfrastructure.org/projects/) | +| 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) | +| **Other best practices** |   | +{% if AddSonarCloud -%} +| 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}}) | +| 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}}) | +{%- endif -%} +{% if AddOnlineDocumentation -%} +| Documentation | [![Documentation Status](https://readthedocs.org/projects/{{package_name}}/badge/?version=latest)](https://{{package_name}}.readthedocs.io/en/latest/?badge=latest) | +{%- endif -%} +| **GitHub Actions** |   | +| Build | [![build]({{repository_url}}/actions/workflows/build.yml/badge.svg)]({{repository_url}}/actions/workflows/build.yml) | +{% if AddCitation -%} +| Citation data consistency | [![cffconvert]({{repository_url}}/actions/workflows/cffconvert.yml/badge.svg)]({{repository_url}}/actions/workflows/cffconvert.yml) | +{%- endif -%} +{% if AddSonarCloud -%} +| SonarCloud | [![sonarcloud]({{repository_url}}/actions/workflows/sonarcloud.yml/badge.svg)]({{repository_url}}/actions/workflows/sonarcloud.yml) | +{%- endif -%} +{% if AddLinkCheck -%} +| Link checker | [![link-check]({{repository_url}}/actions/workflows/link-check.yml/badge.svg)]({{repository_url}}/actions/workflows/link-check.yml) | +{%- endif -%} + +## How to use {{ package_name }} + +{{ package_short_description|replace('\"', '\\\"') }} + +The project setup is documented in [project_setup.md](project_setup.md). Feel free to remove this document (and/or the link to this document) if you don't need it. + +## Installation + +To install {{ package_name }} from GitHub repository, do: + +```console +git clone {{ repository }}.git +cd {{ package_name }} +python -m pip install . +``` + +## Documentation + +Include a link to your project's full documentation here. + +{% if AddContributing -%} +## Contributing + +If you want to contribute to the development of {{ package_name }}, +have a look at the [contribution guidelines](CONTRIBUTING.md). +{%- endif %} + +## Credits + +This package was created with [Copier](https://github.com/copier-org/copier) and the [NLeSC/python-template](https://github.com/NLeSC/python-template). diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/template/project_setup.md.jinja similarity index 91% rename from {{cookiecutter.directory_name}}/project_setup.md rename to template/project_setup.md.jinja index 3d1b196e..3fee6c75 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/template/project_setup.md.jinja @@ -11,8 +11,6 @@ checklist](https://guide.esciencecenter.nl/#/best_practices/checklist). This repository is set up with Python versions: -- 3.8 -- 3.9 - 3.10 - 3.11 - 3.12 @@ -37,6 +35,7 @@ You can distribute your code using PyPI. [The guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=building-and-packaging-code) can help you decide which tool to use for packaging. +{% if AddLocalTests -%} ## Testing and code coverage - Tests should be put in the `tests` folder. @@ -49,7 +48,9 @@ help you decide which tool to use for packaging. - The project uses [GitHub action workflows](https://docs.github.com/en/actions) to automatically run tests on GitHub infrastructure against multiple Python versions - Workflows can be found in [`.github/workflows`](.github/workflows/) - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=testing) +{%- endif %} +{% if AddLocalDocumentation -%} ## Documentation - Documentation should be put in the [`docs/`](docs/) directory. The contents have been generated using `sphinx-quickstart` (Sphinx version 1.6.5). @@ -59,24 +60,27 @@ help you decide which tool to use for packaging. - The documentation is set up with the ReadTheDocs Sphinx theme. - Check out its [configuration options](https://sphinx-rtd-theme.readthedocs.io/en/latest/). - [AutoAPI](https://sphinx-autoapi.readthedocs.io/) is used to generate documentation for the package Python objects. -- `.readthedocs.yaml` is the ReadTheDocs configuration file. When ReadTheDocs is building the documentation this package and its development dependencies are installed so the API reference can be rendered. +{% if AddOnlineDocumentation %}- `.readthedocs.yaml` is the ReadTheDocs configuration file. When ReadTheDocs is building the documentation this package and its development dependencies are installed so the API reference can be rendered.{% endif -%} - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=writingdocumentation) +{%- endif %} ## Coding style conventions and code quality - [Relevant section in the NLeSC guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=coding-style-conventions) and [README.dev.md](README.dev.md). +{% if AddSonarCloud -%} ## Continuous code quality [Sonarcloud](https://sonarcloud.io/) is used to perform quality analysis and code coverage report - `sonar-project.properties` is the SonarCloud [configuration](https://docs.sonarqube.org/latest/analysis/analysis-parameters/) file - `.github/workflows/sonarcloud.yml` is the GitHub action workflow which performs the SonarCloud analysis +{%- endif %} ## Package version number - We recommend using [semantic versioning](https://guide.esciencecenter.nl/#/best_practices/releases?id=semantic-versioning). -- For convenience, the package version is stored in a single place: `{{ cookiecutter.directory_name }}/pyproject.toml` under the `tool.bumpversion` header. +- For convenience, the package version is stored in a single place: `pyproject.toml` under the `tool.bumpversion` header. - Don't forget to update the version number before [making a release](https://guide.esciencecenter.nl/#/best_practices/releases)! ## Logging @@ -85,26 +89,34 @@ help you decide which tool to use for packaging. - The project is set up with a logging example. - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=logging) +{% if AddChangeLog -%} ## CHANGELOG.md - Document changes to your software package - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/releases?id=changelogmd) +{%- endif %} +{% if AddCitation -%} ## CITATION.cff - To allow others to cite your software, add a `CITATION.cff` file - It only makes sense to do this once there is something to cite (e.g., a software release with a DOI). - Follow the [making software citable](https://guide.esciencecenter.nl/#/citable_software/making_software_citable) section in the guide. +{%- endif %} +{% if AddCodeConduct -%} ## CODE_OF_CONDUCT.md - Information about how to behave professionally - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/documentation?id=code-of-conduct) +{%- endif %} +{% if AddContributing -%} ## CONTRIBUTING.md - Information about how to contribute to this software package - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/documentation?id=contribution-guidelines) +{%- endif %} ## MANIFEST.in diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/template/pyproject.toml.jinja similarity index 61% rename from {{cookiecutter.directory_name}}/pyproject.toml rename to template/pyproject.toml.jinja index 67ec3ecd..72076ab7 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/template/pyproject.toml.jinja @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta" [project] authors = [ - { name = "{{ cookiecutter.full_name }}", email = "{{ cookiecutter.email }}" } + { name = "{{ full_name|replace('\"', '\\\"') }}", email = "{{ email }}" } ] classifiers = [ "Development Status :: 2 - Pre-Alpha", @@ -21,47 +21,52 @@ classifiers = [ 'ISC license': 'License :: OSI Approved :: ISC License (ISCL)', 'GNU General Public License v3 or later': 'License :: OSI Approved :: GNU General Public License', 'Not open source': 'License :: Other/Proprietary License' - }[cookiecutter.license] }}", + }[license] }}", "Natural Language :: English", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ] dependencies = [] -description = "{{ cookiecutter.package_short_description }}" +description = "{{ package_short_description|replace('\"', '\\\"') }}" keywords = [ - "{{ cookiecutter.keyword1 }}", - "{{ cookiecutter.keyword2 }}", +{%- for item in keywords.split(',') -%} +"{{ item }}"{{ "," if not loop.last }} +{%- endfor -%} ] license = {file = "LICENSE"} -name = "{{ cookiecutter.package_name }}" +name = "{{ package_name }}" readme = {file = "README.md", content-type = "text/markdown"} requires-python = ">=3.8" -version = "{{ cookiecutter.version }}" +version = "{{ version }}" [project.optional-dependencies] dev = [ "build", # build is not only used in publishing (below), but also in the template's test suite "bump-my-version", + {%- if AddLocalTests %} "coverage [toml]", "pytest", "pytest-cov", + {%- endif %} "ruff", + {%- if AddLocalDocumentation %} "sphinx", "sphinx_rtd_theme", "sphinx-autoapi", + {%- endif %} "tox", "myst_parser", ] +{%- if AddLocalDocumentation %} docs = [ "sphinx", "sphinx_rtd_theme", "sphinx-autoapi", "myst_parser", ] +{%- endif %} publishing = [ "build", "twine", @@ -69,31 +74,44 @@ publishing = [ ] [project.urls] -Repository = "{{ cookiecutter.repository_url }}" -Issues = "{{ cookiecutter.repository_url }}/issues" -Changelog = "{{ cookiecutter.repository_url }}/CHANGELOG.md" - +Repository = "{{ repository_url }}" +Issues = "{{ repository_url }}/issues" +{% if AddChangeLog -%} +Changelog = "{{ repository_url }}/CHANGELOG.md" +{% endif -%} +{% if AddOnlineDocumentation -%} +ReadTheDocs = "https://{{ package_name }}.readthedocs.io" +{% endif %} +{% if AddLocalTests -%} [tool.pytest.ini_options] testpaths = ["tests"] +{% endif %} +{% if AddLocalTests -%} [tool.coverage.run] branch = true -source = ["src/{{ cookiecutter.package_name }}"] +source = ["src/{{ package_name }}"] command_line = "-m pytest" +{%- endif %} [tool.tox] legacy_tox_ini = """ [tox] envlist = py38,py39,py310,py311,py312 skip_missing_interpreters = true +{% if AddLocalTests -%} [testenv] commands = pytest extras = dev +{%- endif %} """ [tool.ruff] -line-length = 120 +line-length = 79 output-format = "concise" +{%- if AddLocalDocumentation %} +extend-exclude = ["docs"] +{%- endif %} [tool.ruff.lint] # Allow unused variables when underscore-prefixed. @@ -102,8 +120,6 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" # Enable Pyflakes `E` and `F` codes by default. select = ["ALL"] ignore = [ - "ANN101", # Missing type annotation for `self` in method - "ANN102", # Missing type annotation for `cls` in classmethod "ANN204", # Missing return type annotation for special (dunder) method "FBT", # Using boolean function arguments "TD", # TODOs @@ -118,52 +134,34 @@ ignore = [ ] pydocstyle.convention = "google" -# Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = ["ALL"] -unfixable = ["F401"] # unused imports (should not disappear while editing) -extend-safe-fixes = [ - "D415", # First line should end with a period, question mark, or exclamation point - "D300", # Use triple double quotes `"""` - "D200", # One-line docstring should fit on one line - "TCH", # Format type checking only imports - "ISC001", # Implicitly concatenated strings on a single line - "EM", # Exception message variables - "RUF013", # Implicit Optional - "B006", # Mutable default argument -] - [tool.ruff.lint.per-file-ignores] -"tests/*" = [ - "S101", # Use of `assert` detected - "PT011", # pytest-raises-too-broad - "ANN001", # Missing function argument type - "ANN201", # Missing return type - "D103", # Missing function docstring - "ANN401", # Function arguments annotated with too generic `Any` type - "SLF001", # Private member access -] -"docs/conf.py" = [ - "INP001", # Add __init__.py to implicit namespace package - "ERA001", # Commented-out code - "A001", # Shadowing Python builtin name, specifically `copyright` +# Tests can ignore a few extra rules +"tests/**.py" = [ + "ANN201", # Missing return type annotation for public function + "PT011", # Missing `match` parameter in `pytest.raises()` + "S101", # Use of assert is detected ] [tool.ruff.lint.isort] -known-first-party = ["{{ cookiecutter.package_name }}"] +known-first-party = ["{{ package_name }}"] force-single-line = true no-lines-before = ["future","standard-library","third-party","first-party","local-folder"] [tool.bumpversion] -current_version = "{{ cookiecutter.version }}" +current_version = "{{ version }}" [[tool.bumpversion.files]] -filename = "src/{{ cookiecutter.package_name }}/__init__.py" +filename = "src/{{ package_name }}/__init__.py" [[tool.bumpversion.files]] filename = "pyproject.toml" +{% if AddCitation -%} [[tool.bumpversion.files]] filename = "CITATION.cff" +{%- endif %} +{% if AddLocalDocumentation -%} [[tool.bumpversion.files]] filename = "docs/conf.py" +{%- endif %} diff --git a/template/src/{{package_name}}/__init__.py.jinja b/template/src/{{package_name}}/__init__.py.jinja new file mode 100644 index 00000000..c2e457c9 --- /dev/null +++ b/template/src/{{package_name}}/__init__.py.jinja @@ -0,0 +1,9 @@ +"""Documentation about {{ package_name }}.""" + +import logging + +logging.getLogger(__name__).addHandler(logging.NullHandler()) + +__author__ = "{{ full_name|replace('\"', '\\\"') }}" +__email__ = "{{ email }}" +__version__ = "{{ version }}" diff --git a/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/my_module.py b/template/src/{{package_name}}/my_module.py.jinja similarity index 63% rename from {{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/my_module.py rename to template/src/{{package_name}}/my_module.py.jinja index 1d4476d5..7248f258 100644 --- a/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/my_module.py +++ b/template/src/{{package_name}}/my_module.py.jinja @@ -1,4 +1,4 @@ -"""Documentation about the {{ cookiecutter.package_name }} module.""" +"""Documentation about the {{ package_name }} module.""" # FIXME: put actual code here @@ -19,11 +19,12 @@ def hello(name: str) -> str: Example: This function can be called with `Jane Smith` as argument using - >>> from {{ cookiecutter.package_name }}.my_module import hello + >>> from {{ package_name }}.my_module import hello >>> hello('Jane Smith') 'Hello Jane Smith!' """ - if name == 'nobody': - raise ValueError('Can not say hello to nobody') - return f'Hello {name}!' + if name == "nobody": + msg = "Can not say hello to nobody" + raise ValueError(msg) + return f"Hello {name}!" diff --git a/{{cookiecutter.directory_name}}/CHANGELOG.md b/template/{% if AddChangeLog %}CHANGELOG.md{% endif %} similarity index 100% rename from {{cookiecutter.directory_name}}/CHANGELOG.md rename to template/{% if AddChangeLog %}CHANGELOG.md{% endif %} diff --git a/template/{% if AddCitation %}CITATION.cff{% endif %}.jinja b/template/{% if AddCitation %}CITATION.cff{% endif %}.jinja new file mode 100644 index 00000000..699d11fe --- /dev/null +++ b/template/{% if AddCitation %}CITATION.cff{% endif %}.jinja @@ -0,0 +1,16 @@ +# YAML 1.2 +--- +cff-version: "1.2.0" +title: "{{ package_name }}" +authors: + - family-names: {{ full_name.replace('\"', '\\\"').split(' ')[-1] }} + given-names: {{ full_name.replace('\"', '\\\"').split(' ')[0] }} + orcid: "https://orcid.org/0000-0000-0000-0000" +date-released: {{ '%Y-%m-%d' | strftime }} +version: "{{ version }}" +repository-code: "{{ repository_url }}" +keywords: +{%- for item in keywords.split(',') %} + - "{{ item }}" +{%- endfor %} +message: "If you use this software, please cite it using these metadata." diff --git a/{{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md b/template/{% if AddCodeConduct %}CODE_OF_CONDUCT.md{% endif %}.jinja similarity index 97% rename from {{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md rename to template/{% if AddCodeConduct %}CODE_OF_CONDUCT.md{% endif %}.jinja index 500a1c9e..ed591351 100644 --- a/{{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md +++ b/template/{% if AddCodeConduct %}CODE_OF_CONDUCT.md{% endif %}.jinja @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at {{ cookiecutter.code_of_conduct_email }}. All +reported by contacting the project team at {{ code_of_conduct_email }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/{{cookiecutter.directory_name}}/CONTRIBUTING.md b/template/{% if AddContributing %}CONTRIBUTING.md{% endif %}.jinja similarity index 74% rename from {{cookiecutter.directory_name}}/CONTRIBUTING.md rename to template/{% if AddContributing %}CONTRIBUTING.md{% endif %}.jinja index c3ec5d42..a3a845f2 100644 --- a/{{cookiecutter.directory_name}}/CONTRIBUTING.md +++ b/template/{% if AddContributing %}CONTRIBUTING.md{% endif %}.jinja @@ -1,6 +1,6 @@ # Contributing guidelines -We welcome any kind of contribution to our software, from simple comment or question to a full fledged [pull request](https://help.github.com/articles/about-pull-requests/). Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md). +We welcome any kind of contribution to our software, from simple comment or question to a full fledged [pull request](https://help.github.com/articles/about-pull-requests/). {% if AddCodeConduct -%}Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md).{%- endif %} A contribution can be one of the following cases: @@ -13,13 +13,13 @@ The sections below outline the steps in each case. ## You have a question -1. use the search functionality [here]({{cookiecutter.repository_url}}/issues) to see if someone already filed the same issue; +1. use the search functionality [here]({{repository_url}}/issues) to see if someone already filed the same issue; 2. if your issue search did not yield any relevant results, make a new issue; 3. apply the "Question" label; apply other labels when relevant. ## You think you may have found a bug -1. use the search functionality [here]({{cookiecutter.repository_url}}/issues) to see if someone already filed the same issue; +1. use the search functionality [here]({{repository_url}}/issues) to see if someone already filed the same issue; 1. if your issue search did not yield any relevant results, make a new issue, making sure to provide enough information to the rest of the community to understand the cause and context of the problem. Depending on the issue, you may want to include: - the [SHA hashcode](https://help.github.com/articles/autolinked-references-and-urls/#commit-shas) of the commit that is causing your problem; - some identifying information (name and version number) for dependencies you're using; @@ -31,12 +31,18 @@ The sections below outline the steps in each case. 1. (**important**) announce your plan to the rest of the community *before you start working*. This announcement should be in the form of a (new) issue; 1. (**important**) wait until some kind of consensus is reached about your idea being a good idea; 1. if needed, fork the repository to your own Github profile and create your own feature branch off of the latest main commit. While working on your feature branch, make sure to stay up to date with the main branch by pulling in changes, possibly from the 'upstream' repository (follow the instructions [here](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and [here](https://help.github.com/articles/syncing-a-fork/)); +{% if AddDevDoc -%} 1. install dependencies (see the [development documentation](README.dev.md#development_install)); +{%- endif %} +{% if AddLocalTests -%} 1. make sure the existing tests still work by running ``pytest``; 1. add your own tests (if necessary); +{%- endif %} 1. update or expand the documentation; +{% if AddChangeLog -%} 1. update the `CHANGELOG.md` file with your change; -1. [push](http://rogerdudler.github.io/git-guide/) your feature branch to (your fork of) the {{ cookiecutter.package_name }} repository on GitHub; +{%- endif %} +1. [push](http://rogerdudler.github.io/git-guide/) your feature branch to (your fork of) the {{ package_name }} repository on GitHub; 1. create the pull request, e.g. following the instructions [here](https://help.github.com/articles/creating-a-pull-request/). In case you feel like you've made a valuable contribution, but you don't know how to write or run tests for it, or how to generate the documentation: don't let this discourage you from making the pull request; we can help you! Just go ahead and submit the pull request, but keep in mind that you might be asked to append additional commits to your pull request. @@ -45,24 +51,28 @@ In case you feel like you've made a valuable contribution, but you don't know ho To create a release you need write permission on the repository. -1. Check the author list in [`CITATION.cff`](CITATION.cff) -1. Bump the version using `bump-my-version bump `. For example, `bump-my-version bump major` will increase major version numbers everywhere it's needed (code, meta, etc.) in the repo. Alternatively the version can be manually changed in {{ cookiecutter.package_name }}/__init__.py, pyproject.toml, CITATION.cff and docs/conf.py (and other places it was possibly added). +{% if AddCitation -%}1. Check the author list in [`CITATION.cff`](CITATION.cff){%- endif %} +1. Bump the version using `bump-my-version bump `. For example, `bump-my-version bump major` will increase major version numbers everywhere it's needed (code, meta, etc.) in the repo. Alternatively the version can be manually changed in {{ package_name }}/__init__.py, pyproject.toml, {% if AddCitation %}CITATION.cff{%- endif -%} and docs/conf.py (and other places it was possibly added). +{% if AddChangeLog -%} 1. Update the `CHANGELOG.md` to include changes made -1. Go to the [GitHub release page]({{ cookiecutter.repository_url }}/releases) +{%- endif %} +1. Go to the [GitHub release page]({{ repository_url }}/releases) 1. Press draft a new release button 1. Fill version, title and description field 1. Press the Publish Release button -Also a Zenodo entry will be made for the release with its own DOI. \ No newline at end of file +{% if AddZenodo -%} +Also a Zenodo entry will be made for the release with its own DOI. +{%- endif %} diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja similarity index 79% rename from {{cookiecutter.directory_name}}/README.dev.md rename to template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja index b839f920..a12eafcb 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja @@ -1,4 +1,4 @@ -# `{{ cookiecutter.package_name }}` developer documentation +# `{{ package_name }}` developer documentation If you're looking for user documentation, go [here](README.md). @@ -15,7 +15,7 @@ source env/bin/activate python -m pip install --upgrade pip setuptools # (from the project root directory) -# install {{ cookiecutter.package_name }} as an editable package +# install {{ package_name }} as an editable package python -m pip install --no-cache-dir --editable . # install development dependencies python -m pip install --no-cache-dir --editable .[dev] @@ -35,7 +35,7 @@ The first way requires an activated virtual environment with the development too pytest -v ``` -The second is to use `tox`, which can be installed separately (e.g. with `pip install tox`), i.e. not necessarily inside the virtual environment you use for installing `{{ cookiecutter.package_name }}`, but then builds the necessary virtual environments itself by simply running: +The second is to use `tox`, which can be installed separately (e.g. with `pip install tox`), i.e. not necessarily inside the virtual environment you use for installing `{{ package_name }}`, but then builds the necessary virtual environments itself by simply running: ```shell tox @@ -62,26 +62,30 @@ coverage report `coverage` can also generate output in HTML and other formats; see `coverage help` for more information. +{%- if AddLinting -%} ## Running linters locally -For linting and sorting imports we will use [ruff](https://beta.ruff.rs/docs/). Running the linters requires an +For linting and sorting imports we will use [ruff](https://beta.ruff.rs/docs/). Running the linters requires an activated virtual environment with the development tools installed. ```shell # linter -ruff . +ruff check . # linter with automatic fixing -ruff . --fix +ruff check . --fix ``` To fix readability of your code style you can use [yapf](https://github.com/google/yapf). +{%- endif -%} +{%- if AddPreCommit -%} You can enable automatic linting with `ruff` on commit by enabling the git hook from `.githooks/pre-commit`, like so: ```shell git config --local core.hooksPath .githooks ``` +{%- endif -%} ## Generating the API docs @@ -133,10 +137,10 @@ This section describes how to make a release in 3 parts: ### (1/3) Preparation -1. Update the (don't forget to update links at bottom of page) -2. Verify that the information in [`CITATION.cff`](CITATION.cff) is correct. -3. Make sure the [version has been updated](#versioning). -4. Run the unit tests with `pytest -v` +{% if AddChangeLog -%}1. Update the (don't forget to update links at bottom of page).{%- endif %} +{% if AddCitation -%}1. Verify that the information in [`CITATION.cff`](CITATION.cff) is correct.{%- endif %} +1. Make sure the [version has been updated](#versioning). +1. Run the unit tests with `pytest -v` ### (2/3) PyPI @@ -145,8 +149,8 @@ In a new terminal: ```shell # OPTIONAL: prepare a new directory with fresh git clone to ensure the release # has the state of origin/main branch -cd $(mktemp -d {{ cookiecutter.package_name }}.XXXXXX) -git clone {{ cookiecutter.repository }} . +cd $(mktemp -d {{ package_name }}.XXXXXX) +git clone {{ repository }} . # make sure to have a recent version of pip and the publishing dependencies python -m pip install --upgrade pip @@ -160,13 +164,13 @@ python -m twine upload --repository testpypi dist/* ``` Visit -[https://test.pypi.org/project/{{cookiecutter.package_name}}](https://test.pypi.org/project/{{cookiecutter.package_name}}) +[https://test.pypi.org/project/{{package_name}}](https://test.pypi.org/project/{{package_name}}) and verify that your package was uploaded successfully. Keep the terminal open, we'll need it later. In a new terminal, without an activated virtual environment or an env directory: ```shell -cd $(mktemp -d {{ cookiecutter.package_name }}-test.XXXXXX) +cd $(mktemp -d {{ package_name }}-test.XXXXXX) # prepare a clean virtual environment and activate it python -m venv env @@ -178,7 +182,7 @@ python -m pip install --upgrade pip # install from test pypi instance: python -m pip -v install --no-cache-dir \ --index-url https://test.pypi.org/simple/ \ ---extra-index-url https://pypi.org/simple {{ cookiecutter.package_name }} +--extra-index-url https://pypi.org/simple {{ package_name }} ``` Check that the package works as it should when installed from pypitest. @@ -193,4 +197,7 @@ python -m twine upload dist/* ### (3/3) GitHub -Don't forget to also make a [release on GitHub]({{cookiecutter.repository_url}}/releases/new). If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it. +Don't forget to also make a [release on GitHub]({{repository_url}}/releases/new). +{%- if AddZenodo -%} +GitHub-Zenodo integration will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it. +{%- endif -%} diff --git a/{{cookiecutter.directory_name}}/.editorconfig b/template/{% if AddEditorConfig %}.editorconfig{% endif %} similarity index 100% rename from {{cookiecutter.directory_name}}/.editorconfig rename to template/{% if AddEditorConfig %}.editorconfig{% endif %} diff --git a/{{cookiecutter.directory_name}}/docs/Makefile b/template/{% if AddLocalDocumentation %}docs{% endif %}/Makefile.jinja similarity index 92% rename from {{cookiecutter.directory_name}}/docs/Makefile rename to template/{% if AddLocalDocumentation %}docs{% endif %}/Makefile.jinja index 48ea1625..db428cf5 100644 --- a/{{cookiecutter.directory_name}}/docs/Makefile +++ b/template/{% if AddLocalDocumentation %}docs{% endif %}/Makefile.jinja @@ -4,7 +4,7 @@ # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build -SPHINXPROJ = {{ cookiecutter.package_name }} +SPHINXPROJ = {{ package_name }} SOURCEDIR = . BUILDDIR = _build diff --git a/{{cookiecutter.directory_name}}/tests/__init__.py b/template/{% if AddLocalDocumentation %}docs{% endif %}/_templates/.gitignore similarity index 100% rename from {{cookiecutter.directory_name}}/tests/__init__.py rename to template/{% if AddLocalDocumentation %}docs{% endif %}/_templates/.gitignore diff --git a/{{cookiecutter.directory_name}}/docs/conf.py b/template/{% if AddLocalDocumentation %}docs{% endif %}/conf.py.jinja similarity index 74% rename from {{cookiecutter.directory_name}}/docs/conf.py rename to template/{% if AddLocalDocumentation %}docs{% endif %}/conf.py.jinja index c73e3d3b..ea6ff9a8 100644 --- a/{{cookiecutter.directory_name}}/docs/conf.py +++ b/template/{% if AddLocalDocumentation %}docs{% endif %}/conf.py.jinja @@ -17,16 +17,16 @@ # -- Project information ----------------------------------------------------- -project = u"{{ cookiecutter.package_name }}" -copyright = u"{% now "local", "%Y" %}, {{ cookiecutter.copyright_holder }}" -author = u"{{ cookiecutter.full_name.replace('\"', '\\\"') }}" +project = u"{{ package_name }}" +copyright = u"{{ '%Y-%m-%d %H:%M:%S' | strftime }}, {{ copyright_holder }}" +author = u"{{ full_name|replace('\"', '\\\"') }}" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = "0.1.0" +version = "{{ version }}" # The full version, including alpha/beta/rc tags. release = version @@ -61,7 +61,7 @@ # -- Use autoapi.extension to run sphinx-apidoc ------- -autoapi_dirs = ['../src/{{ cookiecutter.package_name }}'] +autoapi_dirs = ['../src/{{ package_name }}'] # -- Options for HTML output ---------------------------------------------- @@ -78,11 +78,12 @@ # -- Options for Intersphinx -intersphinx_mapping = {'python': ('https://docs.python.org/3', None), - # Commonly used libraries, uncomment when used in package - # 'numpy': ('http://docs.scipy.org/doc/numpy/', None), - # 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None), - # 'scikit-learn': ('https://scikit-learn.org/stable/', None), - # 'matplotlib': ('https://matplotlib.org/stable/', None), - # 'pandas': ('http://pandas.pydata.org/docs/', None), - } +intersphinx_mapping = { + 'python': ('https://docs.python.org/3', None), + # Commonly used libraries, uncomment when used in package + # 'numpy': ('http://docs.scipy.org/doc/numpy/', None), + # 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None), + # 'scikit-learn': ('https://scikit-learn.org/stable/', None), + # 'matplotlib': ('https://matplotlib.org/stable/', None), + # 'pandas': ('http://pandas.pydata.org/docs/', None), +} diff --git a/{{cookiecutter.directory_name}}/docs/index.rst b/template/{% if AddLocalDocumentation %}docs{% endif %}/index.rst.jinja similarity index 73% rename from {{cookiecutter.directory_name}}/docs/index.rst rename to template/{% if AddLocalDocumentation %}docs{% endif %}/index.rst.jinja index d4af697b..61a86b28 100644 --- a/{{cookiecutter.directory_name}}/docs/index.rst +++ b/template/{% if AddLocalDocumentation %}docs{% endif %}/index.rst.jinja @@ -1,9 +1,9 @@ -.. {{ cookiecutter.package_name }} documentation master file, created by +.. {{ package_name }} documentation master file, created by sphinx-quickstart on Wed May 5 22:45:36 2021. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to {{ cookiecutter.package_name }}'s documentation! +Welcome to {{ package_name }}'s documentation! ========================================================== .. toctree:: diff --git a/{{cookiecutter.directory_name}}/docs/make.bat b/template/{% if AddLocalDocumentation %}docs{% endif %}/make.bat.jinja similarity index 94% rename from {{cookiecutter.directory_name}}/docs/make.bat rename to template/{% if AddLocalDocumentation %}docs{% endif %}/make.bat.jinja index 8176c5be..aa58b03f 100644 --- a/{{cookiecutter.directory_name}}/docs/make.bat +++ b/template/{% if AddLocalDocumentation %}docs{% endif %}/make.bat.jinja @@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" ( ) set SOURCEDIR=. set BUILDDIR=_build -set SPHINXPROJ={{ cookiecutter.package_name }} +set SPHINXPROJ={{ package_name }} if "%1" == "" goto help diff --git a/template/{% if AddLocalTests %}tests{% endif %}/__init__.py b/template/{% if AddLocalTests %}tests{% endif %}/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/template/{% if AddLocalTests %}tests{% endif %}/test_my_module.py.jinja b/template/{% if AddLocalTests %}tests{% endif %}/test_my_module.py.jinja new file mode 100644 index 00000000..bb26591e --- /dev/null +++ b/template/{% if AddLocalTests %}tests{% endif %}/test_my_module.py.jinja @@ -0,0 +1,27 @@ +"""Tests for the {{ package_name }}.my_module module.""" + +import pytest +from {{ package_name }}.my_module import hello + + +def test_hello(): + """Example using assert.""" + assert hello("nlesc") == "Hello nlesc!" + + +def test_hello_with_error(): + """Example of testing for raised errors.""" + with pytest.raises(ValueError) as excinfo: + hello("nobody") + assert "Can not say hello to nobody" in str(excinfo.value) + + +@pytest.fixture +def some_name(): + """Example fixture.""" + return "Jane Smith" + + +def test_hello_with_fixture(some_name: str): + """Example using a fixture.""" + assert hello(some_name) == "Hello Jane Smith!" diff --git a/{{cookiecutter.directory_name}}/.readthedocs.yaml b/template/{% if AddOnlineDocumentation %}.readthedocs.yaml{% endif %} similarity index 100% rename from {{cookiecutter.directory_name}}/.readthedocs.yaml rename to template/{% if AddOnlineDocumentation %}.readthedocs.yaml{% endif %} diff --git a/{{cookiecutter.directory_name}}/.githooks/pre-commit b/template/{% if AddPreCommit %}.githooks{% endif %}/pre-commit similarity index 100% rename from {{cookiecutter.directory_name}}/.githooks/pre-commit rename to template/{% if AddPreCommit %}.githooks{% endif %}/pre-commit diff --git a/template/{% if AddSonarCloud %}sonar-project.properties{% endif %}.jinja b/template/{% if AddSonarCloud %}sonar-project.properties{% endif %}.jinja new file mode 100644 index 00000000..268e30d7 --- /dev/null +++ b/template/{% if AddSonarCloud %}sonar-project.properties{% endif %}.jinja @@ -0,0 +1,12 @@ +sonar.organization={{ github_organization }} +sonar.projectKey={{ github_organization }}_{{ package_name }} +sonar.host.url=https://sonarcloud.io +sonar.sources=src/{{ package_name }}/ +sonar.tests=tests/ +sonar.links.homepage={{ repository_url }} +sonar.links.scm={{ repository }} +sonar.links.issue={{ repository_url }}/issues +sonar.links.ci={{ repository_url }}/actions +sonar.python.coverage.reportPaths=coverage.xml +sonar.python.xunit.reportPath=xunit-result.xml +sonar.python.pylint.reportPaths=pylint-report.txt diff --git a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddCFFConvert %}cffconvert.yml{% endif %} similarity index 100% rename from {{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddCFFConvert %}cffconvert.yml{% endif %} diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddCitation %}next_steps_citation_issue.md{% endif %}.jinja similarity index 76% rename from {{cookiecutter.directory_name}}/.github/next_steps/02_citation.md rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddCitation %}next_steps_citation_issue.md{% endif %}.jinja index 7a3279d7..b725b437 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddCitation %}next_steps_citation_issue.md{% endif %}.jinja @@ -2,19 +2,21 @@ title: 'Next step: Citation data' --- -It is likely that your `CITATION.cff` currently doesn't pass validation. The error messages you get from the [`cffconvert`]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) GitHub Action are unfortunately a bit cryptic, but doing the following helps: +It is likely that your `CITATION.cff` currently doesn't pass validation. The error messages you get from the [`cffconvert`]({{repository_url}}/actions/workflows/cffconvert.yml) GitHub Action are unfortunately a bit cryptic, but doing the following helps: - [ ] Check if the `given-name` and `family-name` keys need updating. If your family name has a name particle like `von` or `van` or `de`, use the `name-particle` key; if your name has a suffix like `Sr` or `IV`, use `name-suffix`. For details, refer to the schema description: https://github.com/citation-file-format/citation-file-format - [ ] Update the value of the `orcid` key. If you do not have an orcid yet, you can get one here [https://orcid.org/](https://orcid.org/). - [ ] Add more authors if needed - [ ] Update `date-released` using the YYYY-MM-DD format. + +{% if AddZenodo -%} - [ ] Update the `doi` key with the conceptDOI for your repository (see [https://help.zenodo.org](https://help.zenodo.org/) for more information on what a conceptDOI is). If your project doesn't have a DOI yet, you can use the string `10.0000/FIXME` to pass validation. +{%- endif -%} - [ ] Verify that the `keywords` array accurately describes your project. Afterwards, the `cffconvert` GitHub Action should be green. -To make sure services like [Zenodo](https://zenodo.org) and the [Research Software Directory](https://research-software-directory.org/) can keep your citation data up to date, the [`cffconvert`]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) GitHub Action checks the following: - +To make sure services like {% if AddZenodo -%} [Zenodo](https://zenodo.org) and {%- endif -%} the [Research Software Directory](https://research-software-directory.org/) can keep your citation data up to date, the [`cffconvert`]({{repository_url}}/actions/workflows/cffconvert.yml) GitHub Action checks the following: 1. Whether your repository includes a `CITATION.cff` file. _By including this file, authors of the software can receive credit for the work they put in._ diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja similarity index 94% rename from {{cookiecutter.directory_name}}/.github/workflows/build.yml rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja index 97c648cf..bbc9d50a 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja @@ -14,10 +14,10 @@ jobs: name: Build for (${{ '{{ ' -}} matrix.python-version }}, ${{ '{{ ' -}} matrix.os }}) runs-on: ${{ '{{ ' -}} matrix.os }} strategy: - fail-fast: false + fail-fast: true matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ '{{ ' -}} matrix.python-version }} @@ -38,6 +38,7 @@ jobs: - name: Verify that we can build the package run: python -m build +{%- if AddLinting %} lint: name: Linting build runs-on: ubuntu-latest @@ -62,3 +63,4 @@ jobs: run: | ruff check ruff format --check +{%- endif %} diff --git a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionDocumentation %}documentation.yml{% endif %} similarity index 100% rename from {{cookiecutter.directory_name}}/.github/workflows/documentation.yml rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionDocumentation %}documentation.yml{% endif %} diff --git a/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddLinkCheck %}link-check.yml{% endif %} b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddLinkCheck %}link-check.yml{% endif %} new file mode 100644 index 00000000..34781c39 --- /dev/null +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddLinkCheck %}link-check.yml{% endif %} @@ -0,0 +1,38 @@ +name: link-check + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: '0 0 1 * *' # first day of every month at midnight + +permissions: + contents: read + issues: write + +jobs: + linkChecker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v1 + + - name: Set Issue Title + id: set_title + run: echo "ISSUE_TITLE=Link Checker Report - $(date '+%Y-%m-%d')" >> $GITHUB_ENV + + - name: Create Issue From File + if: env.lychee_exit_code != 0 + uses: peter-evans/create-issue-from-file@v5 + with: + title: ${{ env.ISSUE_TITLE }} + content-filepath: ./lychee/out.md + labels: report, automated issue diff --git a/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddLinting %}next_steps_linting_issue.md{% endif %}.jinja b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddLinting %}next_steps_linting_issue.md{% endif %}.jinja new file mode 100644 index 00000000..3c1db2b7 --- /dev/null +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddLinting %}next_steps_linting_issue.md{% endif %}.jinja @@ -0,0 +1,17 @@ +--- +title: 'Next step: Linting' +--- + +Your repository has a [workflow]({{ repository_url }}/blob/main/.github/workflows/build.yml) which [lints](https://en.wikipedia.org/wiki/Lint_(software)) your code after every push and when creating a pull request. + +Linter workflow may fail if `description` or `keywords` field in [pyproject.toml]({{ repository_url }}/blob/main/pyproject.toml) is empty. Please update these fields. To validate your changes run: + +```shell +ruff . +``` + +Enabling [githook](https://git-scm.com/docs/githooks) will automatically lint your code in every commit. You can enable it by running the command below. + +```shell +git config --local core.hooksPath .githooks +``` diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddOnlineDocumentation %}next_steps_online_documentation_issue.md{% endif %}.jinja similarity index 63% rename from {{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddOnlineDocumentation %}next_steps_online_documentation_issue.md{% endif %}.jinja index fb72b7f3..5648c020 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddOnlineDocumentation %}next_steps_online_documentation_issue.md{% endif %}.jinja @@ -9,12 +9,12 @@ To host the documentation of this repository please perform the following instru 1. go to [Read the Docs](https://readthedocs.org/dashboard/import/?) 1. log in with your GitHub account -1. find `{{ cookiecutter.github_organization }}/{{ cookiecutter.directory_name }}` in list and press `+` button. +1. find `{{ github_organization }}/{{ package_name }}` in list and press `+` button. * If repository is not listed, 1. go to [Read the Docs GitHub app](https://github.com/settings/connections/applications/fae83c942bc1d89609e2) - 2. make sure {{ cookiecutter.github_organization }} has been granted access. + 2. make sure {{ github_organization }} has been granted access. 3. reload repository list on Read the Docs import page -1. wait for the first build to be completed at -1. check that the link of the documentation badge in the [README.md]({{ cookiecutter.repository_url }}) works +1. wait for the first build to be completed at +1. check that the link of the documentation badge in the [README.md]({{ repository_url }}) works -See [README.dev.md#]({{cookiecutter.repository_url}}/blob/main/README.dev.md#generating-the-api-docs) how to build documentation site locally. +See [README.dev.md#]({{repository_url}}/blob/main/README.dev.md#generating-the-api-docs) how to build documentation site locally. diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddSonarCloud %}next_steps_sonarcloud_issue.md{% endif %}.jinja similarity index 67% rename from {{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddSonarCloud %}next_steps_sonarcloud_issue.md{% endif %}.jinja index 23761831..bcc69ce0 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddSonarCloud %}next_steps_sonarcloud_issue.md{% endif %}.jinja @@ -4,13 +4,13 @@ title: 'Next step: Sonarcloud integration' Continuous code quality can be handled by [Sonarcloud](https://sonarcloud.io/). This repository is configured to use Sonarcloud to perform quality analysis and code coverage report on each push. -In order to configure Sonarcloud analysis [GitHub Action workflow]({{cookiecutter.repository_url}}/blob/main/.github/workflows/sonarcloud.yml) you must follow the steps below: +In order to configure Sonarcloud analysis [GitHub Action workflow]({{repository_url}}/blob/main/.github/workflows/sonarcloud.yml) you must follow the steps below: 1. go to [Sonarcloud](https://sonarcloud.io/projects/create) to create a new Sonarcloud project 1. login with your GitHub account 1. add Sonarcloud organization or reuse existing one 1. set up a repository -1. go to [new code definition administration page](https://sonarcloud.io/project/new_code?id={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}) and select `Number of days` option +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 1. To be able to run the analysis: 1. a token must be created at [Sonarcloud account](https://sonarcloud.io/account/security/) - 1. the created token must be added as `SONAR_TOKEN` to [secrets on GitHub](https://github.com/{{cookiecutter.github_organization}}/{{cookiecutter.directory_name}}/settings/secrets/actions) + 1. the created token must be added as `SONAR_TOKEN` to [secrets on GitHub](https://github.com/{{github_organization}}/{{package_name}}/settings/secrets/actions) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddSonarCloud %}sonarcloud.yml{% endif %} similarity index 86% rename from {{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddSonarCloud %}sonarcloud.yml{% endif %} index 1c7ec8b3..e8ca8152 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddSonarCloud %}sonarcloud.yml{% endif %} @@ -36,5 +36,5 @@ jobs: - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: - GITHUB_TOKEN: ${{ '{{' -}} secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ '{{' -}} secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddZenodo %}next_steps_zenodo_issue.md{% endif %}.jinja similarity index 92% rename from {{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md rename to template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddZenodo %}next_steps_zenodo_issue.md{% endif %}.jinja index 45ecb639..911d824b 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddZenodo %}next_steps_zenodo_issue.md{% endif %}.jinja @@ -8,7 +8,7 @@ To enable Zenodo integration: 1. Go to http://zenodo.org and login with your GitHub account. When you are redirected to GitHub, *Authorize application* to give permission to Zenodo to access your account. 1. Go to and enable Zenodo integration of your repository by clicking on `On` toggle button. -2. Your package will get a DOI only after you make a release. Create a new release as described in [README.dev.md]({{cookiecutter.repository_url}}/blob/main/README.dev.md#33-github) +2. Your package will get a DOI only after you make a release. Create a new release as described in [README.dev.md]({{repository_url}}/blob/main/README.dev.md#33-github) 3. At this point you should have a DOI. To find out the DOI generated by Zenodo: 1. Visit https://zenodo.org/deposit and click on your repository link 2. You will find the latest DOI in the right column in Versions box in **Cite all versions?** section diff --git a/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if HasWorkflows %}next_steps.yml{% endif %}.jinja b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if HasWorkflows %}next_steps.yml{% endif %}.jinja new file mode 100644 index 00000000..b0fbef61 --- /dev/null +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if HasWorkflows %}next_steps.yml{% endif %}.jinja @@ -0,0 +1,131 @@ +on: [push] +permissions: + contents: write + issues: write +name: Create GitHub issues +jobs: + next_steps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + +{%- if AddCitation %} + - name: Create citation data issue + uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: {{ '${{' }}secrets.GITHUB_TOKEN{{ '}}' }} + with: + filename: .github/workflows/next_steps_citation_issue.md + id: citation + - name: List created issues + run: | + echo "Created issues that must be completed to have fully working Python package: + * Citation data {{ '${{' }} steps.citation.outputs.url {{ '}}' }}" + - name: Cleanup files needed to create next steps issues + run: | + git config --global user.name 'NLeSC Python template' + git config --global user.email 'nlesc-python-template@users.noreply.github.com' + git pull # other next step workflows may push changes before + git rm .github/workflows/next_steps_citation_issue.md + git commit -am "Cleanup automated next steps issue generator for citation" + git push +{%- endif %} + +{%- if AddLinting %} + - name: Create linting issue + uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: {{ '${{' }}secrets.GITHUB_TOKEN{{ '}}' }} + with: + filename: .github/workflows/next_steps_linting_issue.md + id: linting + - name: List created issues + run: | + echo "Created issues that must be completed to have fully working Python package: + * Linting fixes {{ '${{' }} steps.linting.outputs.url {{ '}}' }}" + - name: Cleanup files needed to create next steps issues + run: | + git config --global user.name 'NLeSC Python template' + git config --global user.email 'nlesc-python-template@users.noreply.github.com' + git pull # other next step workflows may push changes before + git rm .github/workflows/next_steps_linting_issue.md + git commit -am "Cleanup automated next steps issue generator" + git push +{%- endif %} + +{%- if AddOnlineDocumentation %} + - name: Create online documentation issue + uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: {{ '${{' }}secrets.GITHUB_TOKEN{{ '}}' }} + with: + filename: .github/workflows/next_steps_online_documentation_issue.md + id: readthedocs + - name: List created issues + run: | + echo "Created issues that must be completed to have fully working Python package: + * Read the Docs instructions {{ '${{' }} steps.readthedocs.outputs.url {{ '}}' }}" + - name: Cleanup files needed to create next steps issues + run: | + git config --global user.name 'NLeSC Python template' + git config --global user.email 'nlesc-python-template@users.noreply.github.com' + git pull # other next step workflows may push changes before + git rm .github/workflows/next_steps_online_documentation_issue.md + git commit -am "Cleanup automated next steps issue generator for online documentation" + git push +{%- endif %} + +{%- if AddZenodo %} + - name: Create Zenodo integration issue + uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: {{ '${{' }}secrets.GITHUB_TOKEN{{ '}}' }} + with: + filename: .github/workflows/next_steps_zenodo_issue.md + id: zenodo + - name: List created issues + run: | + echo "Created issues that must be completed to have fully working Python package: + * Sonarcloud integration {{ '${{' }} steps.sonarcloud.outputs.url {{ '}}' }}" + - name: Cleanup files needed to create next steps issues + run: | + git config --global user.name 'NLeSC Python template' + git config --global user.email 'nlesc-python-template@users.noreply.github.com' + git pull # other next step workflows may push changes before + git rm .github/workflows/next_steps_zenodo_issue.md + git commit -am "Cleanup automated next steps issue generator for zenodo" + git push +{%- endif %} + +{%- if AddSonarCloud %} + - name: Create Sonarcloud issue + uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: {{ '${{' }}secrets.GITHUB_TOKEN{{ '}}' }} + with: + filename: .github/workflows/next_steps_sonarcloud_issue.md + id: sonarcloud + - name: List created issues + run: | + echo "Created issues that must be completed to have fully working Python package: + * Sonarcloud integration {{ '${{' }} steps.sonarcloud.outputs.url {{ '}}' }}" + - name: Cleanup files needed to create next steps issues + run: | + git config --global user.name 'NLeSC Python template' + git config --global user.email 'nlesc-python-template@users.noreply.github.com' + git pull # other next step workflows may push changes before + git rm .github/workflows/next_steps_sonarcloud_issue.md + git commit -am "Cleanup automated next steps issue generator for sonarcloud" + git push +{%- endif %} + +{%- if AddCitation or AddLinting or AddOnlineDocumentation or AddZenodo or AddSonarCloud %} + - name: Cleanup files needed to create next steps issues + run: | + git config --global user.name 'NLeSC Python template' + git config --global user.email 'nlesc-python-template@users.noreply.github.com' + git pull # other next step workflows may push changes before + git rm .github/workflows/next_steps.yml + git commit -am "Cleanup automated next steps issue generator" + git push +{%- endif %} diff --git a/template/{% if license == 'Apachev2' %}LICENSE{% endif %}.jinja b/template/{% if license == 'Apachev2' %}LICENSE{% endif %}.jinja new file mode 100644 index 00000000..7d423b82 --- /dev/null +++ b/template/{% if license == 'Apachev2' %}LICENSE{% endif %}.jinja @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {{ '%Y' | strftime }} {{ copyright_holder }} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/template/{% if license == 'Apachev2' %}NOTICE{% endif %}.jinja b/template/{% if license == 'Apachev2' %}NOTICE{% endif %}.jinja new file mode 100644 index 00000000..6bfd7580 --- /dev/null +++ b/template/{% if license == 'Apachev2' %}NOTICE{% endif %}.jinja @@ -0,0 +1,2 @@ +This product includes {{ package_name }}, software developed by +{{ copyright_holder }}. diff --git a/template/{% if license == 'BSD' %}LICENSE{% endif %}.jinja b/template/{% if license == 'BSD' %}LICENSE{% endif %}.jinja new file mode 100644 index 00000000..3c40829a --- /dev/null +++ b/template/{% if license == 'BSD' %}LICENSE{% endif %}.jinja @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) {{ '%Y' | strftime }}, {{ copyright_holder }} +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/template/{% if license == 'GNULesserv3' %}LICENSE{% endif %}.jinja b/template/{% if license == 'GNULesserv3' %}LICENSE{% endif %}.jinja new file mode 100644 index 00000000..7125e3e6 --- /dev/null +++ b/template/{% if license == 'GNULesserv3' %}LICENSE{% endif %}.jinja @@ -0,0 +1,166 @@ +GNU LESSER GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + + +This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + +0. Additional Definitions. + +As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + +"The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + +An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + +A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + +The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + +The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + +1. Exception to Section 3 of the GNU GPL. + +You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + +2. Conveying Modified Versions. + +If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + +a) under this License, provided that you make a good faith effort to +ensure that, in the event an Application does not supply the +function or data, the facility still operates, and performs +whatever part of its purpose remains meaningful, or + +b) under the GNU GPL, with none of the additional permissions of +this License applicable to that copy. + +3. Object Code Incorporating Material from Library Header Files. + +The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + +a) Give prominent notice with each copy of the object code that the +Library is used in it and that the Library and its use are +covered by this License. + +b) Accompany the object code with a copy of the GNU GPL and this license +document. + +4. Combined Works. + +You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + +a) Give prominent notice with each copy of the Combined Work that +the Library is used in it and that the Library and its use are +covered by this License. + +b) Accompany the Combined Work with a copy of the GNU GPL and this license +document. + +c) For a Combined Work that displays copyright notices during +execution, include the copyright notice for the Library among +these notices, as well as a reference directing the user to the +copies of the GNU GPL and this license document. + +d) Do one of the following: + +0) Convey the Minimal Corresponding Source under the terms of this +License, and the Corresponding Application Code in a form +suitable for, and under terms that permit, the user to +recombine or relink the Application with a modified version of +the Linked Version to produce a modified Combined Work, in the +manner specified by section 6 of the GNU GPL for conveying +Corresponding Source. + +1) Use a suitable shared library mechanism for linking with the +Library. A suitable mechanism is one that (a) uses at run time +a copy of the Library already present on the user's computer +system, and (b) will operate properly with a modified version +of the Library that is interface-compatible with the Linked +Version. + +e) Provide Installation Information, but only if you would otherwise +be required to provide such information under section 6 of the +GNU GPL, and only to the extent that such information is +necessary to install and execute a modified version of the +Combined Work produced by recombining or relinking the +Application with a modified version of the Linked Version. (If +you use option 4d0, the Installation Information must accompany +the Minimal Corresponding Source and Corresponding Application +Code. If you use option 4d1, you must provide the Installation +Information in the manner specified by section 6 of the GNU GPL +for conveying Corresponding Source.) + +5. Combined Libraries. + +You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + +a) Accompany the combined library with a copy of the same work based +on the Library, uncombined with any other library facilities, +conveyed under the terms of this License. + +b) Give prominent notice with the combined library that part of it +is a work based on the Library, and explaining where to find the +accompanying uncombined form of the same work. + +6. Revised Versions of the GNU Lesser General Public License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. \ No newline at end of file diff --git a/{{cookiecutter.directory_name}}/LICENSE b/template/{% if license == 'GNUv3' %}LICENSE{% endif %}.jinja similarity index 60% rename from {{cookiecutter.directory_name}}/LICENSE rename to template/{% if license == 'GNUv3' %}LICENSE{% endif %}.jinja index aa06a167..d479de78 100644 --- a/{{cookiecutter.directory_name}}/LICENSE +++ b/template/{% if license == 'GNUv3' %}LICENSE{% endif %}.jinja @@ -1,255 +1,3 @@ -{% if cookiecutter.license == 'MIT license' %} -MIT License - -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.copyright_holder }} - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -{% elif cookiecutter.license == 'BSD license' %} -BSD License - -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.copyright_holder }} -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -* Neither the name of {{ cookiecutter.package_name }} nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. -{% elif cookiecutter.license == 'ISC license' %} -ISC License - -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.copyright_holder }} - -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -{% elif cookiecutter.license == 'Apache Software License 2.0' %} - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -{% elif cookiecutter.license == 'GNU General Public License v3 or later' %} GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -884,7 +632,7 @@ state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) + Copyright (C) {{ '%Y' | strftime }} {{ copyright_holder }} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -904,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) + Copyright (C) {{ '%Y' | strftime }} {{ copyright_holder }} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -924,170 +672,3 @@ may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . -{% elif cookiecutter.license == 'GNU Lesser General Public License v3 or later' %} - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. -{% endif %} diff --git a/template/{% if license == 'ISC' %}LICENSE{% endif %}.jinja b/template/{% if license == 'ISC' %}LICENSE{% endif %}.jinja new file mode 100644 index 00000000..137e91fa --- /dev/null +++ b/template/{% if license == 'ISC' %}LICENSE{% endif %}.jinja @@ -0,0 +1,12 @@ +ISC License + +Copyright (c) {{ '%Y' | strftime }}, {{ copyright_holder }} + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, +provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/template/{% if license == 'MIT' %}LICENSE{% endif %}.jinja b/template/{% if license == 'MIT' %}LICENSE{% endif %}.jinja new file mode 100644 index 00000000..416f547d --- /dev/null +++ b/template/{% if license == 'MIT' %}LICENSE{% endif %}.jinja @@ -0,0 +1,16 @@ +MIT License + +Copyright (c) {{ '%Y' | strftime }}, {{ copyright_holder }} + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/template/{% if license == 'Other' %}LICENSE{% endif %}.jinja b/template/{% if license == 'Other' %}LICENSE{% endif %}.jinja new file mode 100644 index 00000000..df35cc43 --- /dev/null +++ b/template/{% if license == 'Other' %}LICENSE{% endif %}.jinja @@ -0,0 +1 @@ +Copyright (C) {{ '%Y' | strftime }} {{ copyright_holder }} diff --git a/template/{{_copier_conf.answers_file}}.jinja b/template/{{_copier_conf.answers_file}}.jinja new file mode 100644 index 00000000..ea97bd4b --- /dev/null +++ b/template/{{_copier_conf.answers_file}}.jinja @@ -0,0 +1,2 @@ +# Changes here will be overwritten by Copier +{{ _copier_answers|to_nice_yaml -}} \ No newline at end of file diff --git a/tests/test_project.py b/tests/test_project.py index 1eb97d46..a2b5a35f 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -4,18 +4,33 @@ from sys import platform from typing import Sequence +from copier import run_copy import pytest IS_WINDOWS = platform.startswith('win') -def test_project_folder(cookies): - project = cookies.bake() +@pytest.fixture(scope='session') +def copier_project_defaults(): + return { + "package_name": "my_python_package", + "package_short_description": "Short description of package", + "keywords": "keyword1,keyword2", + "version": "0.1.0", + "github_organization": "", + "full_name": "Jane Smith", + "email": "yourname@esciencecenter.nl", + "code_of_conduct_email": "yourname@esciencecenter.nl", + "copyright_holder": "Netherlands eScience Center" + } + +def test_project_folder(copie, copier_project_defaults): + project_defaults = copier_project_defaults + project = copie.copy(extra_answers=project_defaults) assert project.exit_code == 0 assert project.exception is None - assert project.project_path.name == 'my-python-project' - assert project.project_path.is_dir() + assert project.project_dir.is_dir() def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProcess: @@ -41,15 +56,17 @@ def project_env_bin_dir(tmp_path_factory): @pytest.fixture(scope='session') -def baked_with_development_dependencies(cookies_session, project_env_bin_dir): - result = cookies_session.bake() +def baked_with_development_dependencies(copie_session, project_env_bin_dir, copier_project_defaults): + result = copie_session.copy(extra_answers=copier_project_defaults) assert result.exit_code == 0 + project_dir = result.project_dir + bin_dir = project_env_bin_dir - latest_pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], result.project_path) + latest_pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], project_dir) assert latest_pip_output.returncode == 0 - pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.[dev]'], result.project_path) + pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.[dev]'], project_dir) assert pip_output.returncode == 0 - return result.project_path + return project_dir def test_pytest(baked_with_development_dependencies, project_env_bin_dir): @@ -167,7 +184,7 @@ def test_ruff_check(baked_with_development_dependencies, project_env_bin_dir): project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir - result = run([f'{bin_dir}ruff', 'check', '--fix'], project_dir) + result = run([f'{bin_dir}ruff', 'check'], project_dir) assert result.returncode == 0 assert '' in result.stdout @@ -178,7 +195,7 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir): original_version = '0.1.0' assert original_version in (project_dir / 'pyproject.toml').read_text('utf-8') - assert original_version in (project_dir / 'CITATION.cff').read_text('utf-8') + # assert original_version in (project_dir / 'CITATION.cff').read_text('utf-8') assert original_version in (project_dir / 'src' / 'my_python_package' / '__init__.py').read_text('utf-8') assert original_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8') @@ -187,6 +204,6 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir): assert '' in result.stdout expected_version = '1.0.0' assert expected_version in (project_dir / 'pyproject.toml').read_text('utf-8') - assert expected_version in (project_dir / 'CITATION.cff').read_text('utf-8') + # assert expected_version in (project_dir / 'CITATION.cff').read_text('utf-8') assert expected_version in (project_dir / 'src' / 'my_python_package' / '__init__.py').read_text('utf-8') assert expected_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8') diff --git a/tests/test_values.py b/tests/test_values.py index 01d748a9..6bb78dad 100644 --- a/tests/test_values.py +++ b/tests/test_values.py @@ -1,36 +1,24 @@ -def test_double_quotes_in_name_and_description(cookies): - ctx = { +from test_project import copier_project_defaults + +def test_double_quotes_in_name_and_description(copie, copier_project_defaults): + project_defaults = copier_project_defaults + test_values = { "project_short_description": '"double quotes"', "full_name": '"name"name' } - project = cookies.bake(extra_context=ctx) + project_defaults.update(test_values) + project = copie.copy(extra_answers=project_defaults) assert project.exit_code == 0 -def test_single_quotes_in_name_and_description(cookies): - ctx = { +def test_single_quotes_in_name_and_description(copie, copier_project_defaults): + project_defaults = copier_project_defaults + test_values = { "project_short_description": "'single quotes'", "full_name": "Mr. O'Keefe" } - project = cookies.bake(extra_context=ctx) - - assert project.exit_code == 0 - - -def test_dash_in_directory_name(cookies): - ctx = { - "directory_name": "my-python-project" - } - project = cookies.bake(extra_context=ctx) - - assert project.exit_code == 0 - - -def test_space_in_directory_name(cookies): - ctx = { - "directory_name": "my python project" - } - project = cookies.bake(extra_context=ctx) + project_defaults.update(test_values) + project = copie.copy(extra_answers=project_defaults) assert project.exit_code == 0 diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md deleted file mode 100644 index cc603833..00000000 --- a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: 'Next step: Linting' ---- - -Your repository has a [workflow]({{ cookiecutter.repository_url }}/blob/main/.github/workflows/build.yml) which [lints](https://en.wikipedia.org/wiki/Lint_(software)) your code after every push and when creating a pull request. - -Linter workflow may fail if `description` or `keywords` field in [pyproject.toml]({{ cookiecutter.repository_url }}/blob/main/pyproject.toml) is empty. Please update these fields. To validate your changes run: - -```shell -ruff . -``` - -Enabling [githook](https://git-scm.com/docs/githooks) will automatically lint your code in every commit. You can enable it by running the command below. - -```shell -git config --local core.hooksPath .githooks -``` diff --git a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml deleted file mode 100644 index e27e10b3..00000000 --- a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: markdown-link-check - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - - markdown-link-check: - name: Check markdown links - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gaurav-nelson/github-action-markdown-link-check@v1 - with: - use-quiet-mode: 'yes' - config-file: '.mlc-config.json' diff --git a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml deleted file mode 100644 index e759c491..00000000 --- a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml +++ /dev/null @@ -1,62 +0,0 @@ -on: [push] -permissions: - contents: write - issues: write -name: Create issues for next steps -jobs: - next_steps: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Create Sonarcloud integration issue - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} - with: - filename: .github/next_steps/01_sonarcloud_integration.md - id: sonarcloud - - - name: Create citation data issue - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} - with: - filename: .github/next_steps/02_citation.md - id: citation - - name: Create readthedocs issue - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} - with: - filename: .github/next_steps/03_readthedocs.md - id: readthedocs - - name: Create Zenodo integration issue - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} - with: - filename: .github/next_steps/04_zenodo_integration.md - id: zenodo - - name: Create linting issue - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} - with: - filename: .github/next_steps/05_linting.md - id: linting - - name: List created issues - run: | - echo 'Created issues that must be completed to have fully working Python package: - * Sonarcloud integration ${{ '{{ ' -}} steps.sonarcloud.outputs.url }} - * Zenodo integration ${{ '{{ ' -}} steps.zenodo.outputs.url }} - * Read the Docs instructions ${{ '{{ ' -}} steps.readthedocs.outputs.url }} - * Citation data ${{ '{{ ' -}} steps.citation.outputs.url }} - * Linting fixes ${{ '{{ ' -}} steps.linting.outputs.url }}' - - name: Cleanup files needed to create next steps issues - run: | - git config --global user.name 'NLeSC Python template' - git config --global user.email 'nlesc-python-template@users.noreply.github.com' - git rm .github/workflows/next_steps.yml - git rm -r .github/next_steps - git commit -am "Cleanup automated next steps issue generator" - git push diff --git a/{{cookiecutter.directory_name}}/.gitignore b/{{cookiecutter.directory_name}}/.gitignore deleted file mode 100644 index 57fb2ab9..00000000 --- a/{{cookiecutter.directory_name}}/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -*.py[cod] -*.egg-info -*.eggs -.ipynb_checkpoints - -build -dist -.cache -__pycache__ - -htmlcov -.coverage -coverage.xml -.pytest_cache -.tox - -docs/_build - -# ide -.idea -.eclipse -.vscode - -# Mac -.DS_Store - -# virtual environments -env -env3 -venv -venv3 diff --git a/{{cookiecutter.directory_name}}/.mlc-config.json b/{{cookiecutter.directory_name}}/.mlc-config.json deleted file mode 100644 index 1d388679..00000000 --- a/{{cookiecutter.directory_name}}/.mlc-config.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "_comment": "Markdown Link Checker configuration, see https://github.com/gaurav-nelson/github-action-markdown-link-check and https://github.com/tcort/markdown-link-check", - "ignorePatterns": [ - { - "pattern": "^http://localhost" - }, - { - "pattern": "^https://doi.org/" - }, - { - "pattern": "^https://github.com/.*/settings/secrets/actions$" - }, - { - "pattern": "^https://github.com/organizations/.*/repositories/new" - }, - { - "pattern": "^https://test.pypi.org" - }, - { - "pattern": "^https://bestpractices.coreinfrastructure.org/projects/" - }, - { - "pattern": "^https://readthedocs.org/dashboard/import.*" - } - ], - "replacementPatterns": [ - ], - "retryOn429": true, - "timeout": "20s" -} diff --git a/{{cookiecutter.directory_name}}/CITATION.cff b/{{cookiecutter.directory_name}}/CITATION.cff deleted file mode 100644 index 88cb9c25..00000000 --- a/{{cookiecutter.directory_name}}/CITATION.cff +++ /dev/null @@ -1,24 +0,0 @@ -# YAML 1.2 ---- -cff-version: "1.2.0" -title: "{{ cookiecutter.package_name }}" -authors: - - - family-names: {{ cookiecutter.full_name.split(' ')[-1] }} - given-names: {{ cookiecutter.full_name.split(' ')[0] }} - orcid: "https://orcid.org/0000-0000-0000-0000" -date-released: 20??-MM-DD -doi: -version: "{{ cookiecutter.version }}" -repository-code: "{{ cookiecutter.repository_url }}" -keywords: - - {{ cookiecutter.keyword1 }} - - {{ cookiecutter.keyword2 }} -message: "If you use this software, please cite it using these metadata." -{{ { "Apache Software License 2.0": "license: Apache-2.0", - "MIT license": "license: MIT", - "BSD license": "license: BSD-3-Clause", - "ISC license": "license: ISC", - "GNU General Public License v3 or later": "license: GPL-3.0-or-later", - "Not open source": "" -}[cookiecutter.license] }} diff --git a/{{cookiecutter.directory_name}}/MANIFEST.in b/{{cookiecutter.directory_name}}/MANIFEST.in deleted file mode 100644 index f128825e..00000000 --- a/{{cookiecutter.directory_name}}/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -include CITATION.cff -include LICENSE -include NOTICE -include README.md diff --git a/{{cookiecutter.directory_name}}/NOTICE b/{{cookiecutter.directory_name}}/NOTICE deleted file mode 100644 index 3ddc2d32..00000000 --- a/{{cookiecutter.directory_name}}/NOTICE +++ /dev/null @@ -1,2 +0,0 @@ -This product includes {{ cookiecutter.package_name }}, software developed by -{{ cookiecutter.copyright_holder }}. diff --git a/{{cookiecutter.directory_name}}/README.md b/{{cookiecutter.directory_name}}/README.md deleted file mode 100644 index 0e5e2918..00000000 --- a/{{cookiecutter.directory_name}}/README.md +++ /dev/null @@ -1,50 +0,0 @@ -## Badges - -(Customize these badges with your own links, and check https://shields.io/ or https://badgen.net/ to see which other badges are available.) - -| fair-software.eu recommendations | | -| :-- | :-- | -| (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)]({{cookiecutter.repository_url}}) | -| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{cookiecutter.github_organization}}/{{cookiecutter.directory_name}})]({{cookiecutter.repository_url}}) | -| (3/5) community registry | [![RSD](https://img.shields.io/badge/rsd-{{cookiecutter.package_name}}-00a3e3.svg)](https://www.research-software.nl/software/{{cookiecutter.package_name}}) [![workflow pypi badge](https://img.shields.io/pypi/v/{{cookiecutter.package_name}}.svg?colorB=blue)](https://pypi.python.org/project/{{cookiecutter.package_name}}/) | -| (4/5) citation | [![DOI](https://zenodo.org/badge/DOI/.svg)](https://doi.org/) | -| (5/5) checklist | [![workflow cii badge](https://bestpractices.coreinfrastructure.org/projects//badge)](https://bestpractices.coreinfrastructure.org/projects/) | -| 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) | -| **Other best practices** |   | -| Static analysis | [![workflow scq badge](https://sonarcloud.io/api/project_badges/measure?project={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}&metric=alert_status)](https://sonarcloud.io/dashboard?id={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}) | -| Coverage | [![workflow scc badge](https://sonarcloud.io/api/project_badges/measure?project={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}&metric=coverage)](https://sonarcloud.io/dashboard?id={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}) | -| Documentation | [![Documentation Status](https://readthedocs.org/projects/{{cookiecutter.directory_name}}/badge/?version=latest)](https://{{cookiecutter.directory_name}}.readthedocs.io/en/latest/?badge=latest) | -| **GitHub Actions** |   | -| Build | [![build]({{cookiecutter.repository_url}}/actions/workflows/build.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/build.yml) | -| Citation data consistency | [![cffconvert]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) | -| SonarCloud | [![sonarcloud]({{cookiecutter.repository_url}}/actions/workflows/sonarcloud.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/sonarcloud.yml) | -| MarkDown link checker | [![markdown-link-check]({{cookiecutter.repository_url}}/actions/workflows/markdown-link-check.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/markdown-link-check.yml) | - -## How to use {{ cookiecutter.package_name }} - -{{ cookiecutter.package_short_description }} - -The project setup is documented in [project_setup.md](project_setup.md). Feel free to remove this document (and/or the link to this document) if you don't need it. - -## Installation - -To install {{ cookiecutter.package_name }} from GitHub repository, do: - -```console -git clone {{ cookiecutter.repository }}.git -cd {{ cookiecutter.directory_name }} -python -m pip install . -``` - -## Documentation - -Include a link to your project's full documentation here. - -## Contributing - -If you want to contribute to the development of {{ cookiecutter.package_name }}, -have a look at the [contribution guidelines](CONTRIBUTING.md). - -## Credits - -This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [NLeSC/python-template](https://github.com/NLeSC/python-template). diff --git a/{{cookiecutter.directory_name}}/next_steps.md b/{{cookiecutter.directory_name}}/next_steps.md deleted file mode 100644 index c9710c54..00000000 --- a/{{cookiecutter.directory_name}}/next_steps.md +++ /dev/null @@ -1,47 +0,0 @@ -# Next steps - -## Put the generated files under version control - -Once your Python package is created, put it under [version -control](https://guide.esciencecenter.nl/#/best_practices/version_control) using -[git](https://git-scm.com/) and [GitHub](https://github.com/). - -Note that the next step assumes you have setup your connection to GitHub via SSH, -see [Connecting to GitHub with SSH](https://docs.github.com/en/github-ae@latest/authentication/connecting-to-github-with-ssh). - -Alternatively, you can also use a personal access token, see -[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 -`git@github.com:` by `https://github.com/`. - -```shell -cd {{ cookiecutter.directory_name }} -git init -git add --all -git commit -m "first commit" -git branch -M main -git remote add origin {{ cookiecutter.repository }} -``` - -## Push the initial commit to a new repo on GitHub - -Go to -[https://github.com/organizations/{{cookiecutter.github_organization}}/repositories/new](https://github.com/organizations/{{cookiecutter.github_organization}}/repositories/new) -and create a new repository named `{{ cookiecutter.directory_name }}` as an empty repository, then push your commits to GitHub: - -```shell -git push --set-upstream origin main -``` - -## Check automatically generated issues - -A short while after you push your commits to GitHub for the first time, a few issues outlining next steps will added -automatically ([here]({{cookiecutter.repository_url}}/issues?q=author%3Aapp%2Fgithub-actions)). Resolve them to complete the -setup of your repository. - -## Project development documentation - -The [README.dev.md](README.dev.md) contains developer documentation. - -## Project layout explained - -For an explanation of what files are there, and what each of these do, please refer to [project_setup.md](project_setup.md). diff --git a/{{cookiecutter.directory_name}}/sonar-project.properties b/{{cookiecutter.directory_name}}/sonar-project.properties deleted file mode 100644 index 512f6831..00000000 --- a/{{cookiecutter.directory_name}}/sonar-project.properties +++ /dev/null @@ -1,12 +0,0 @@ -sonar.organization={{ cookiecutter.github_organization }} -sonar.projectKey={{ cookiecutter.github_organization }}_{{ cookiecutter.directory_name }} -sonar.host.url=https://sonarcloud.io -sonar.sources=src/{{ cookiecutter.package_name }}/ -sonar.tests=tests/ -sonar.links.homepage={{ cookiecutter.repository_url }} -sonar.links.scm={{ cookiecutter.repository }} -sonar.links.issue={{ cookiecutter.repository_url }}/issues -sonar.links.ci={{ cookiecutter.repository_url }}/actions -sonar.python.coverage.reportPaths=coverage.xml -sonar.python.xunit.reportPath=xunit-result.xml -sonar.python.pylint.reportPaths=pylint-report.txt diff --git a/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/__init__.py deleted file mode 100644 index 4a72a364..00000000 --- a/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -"""Documentation about {{ cookiecutter.package_name }}.""" -import logging - -logging.getLogger(__name__).addHandler(logging.NullHandler()) - -__author__ = "{{ cookiecutter.full_name }}" -__email__ = "{{ cookiecutter.email }}" -__version__ = "{{ cookiecutter.version }}" diff --git a/{{cookiecutter.directory_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py deleted file mode 100644 index ad6481d6..00000000 --- a/{{cookiecutter.directory_name}}/tests/test_my_module.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Tests for the {{ cookiecutter.package_name }}.my_module module.""" -import pytest -from {{ cookiecutter.package_name }}.my_module import hello - - -def test_hello(): - """Example using assert.""" - assert hello('nlesc') == 'Hello nlesc!' - - -def test_hello_with_error(): - """Example of testing for raised errors.""" - with pytest.raises(ValueError) as excinfo: - hello('nobody') - assert 'Can not say hello to nobody' in str(excinfo.value) - - -@pytest.fixture -def some_name(): - """Example fixture.""" - return 'Jane Smith' - - -def test_hello_with_fixture(some_name): - """Example using a fixture.""" - assert hello(some_name) == 'Hello Jane Smith!'