From 42ebdab197c39993963a359d784ff886b8deabe1 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Thu, 2 May 2024 17:37:55 +0200 Subject: [PATCH 01/17] enh: Update some template from xncml feedback --- {{cookiecutter.project_slug}}/CHANGES.rst | 3 + .../CONTRIBUTING.rst | 137 +++++++++++------- {{cookiecutter.project_slug}}/Makefile | 5 +- {{cookiecutter.project_slug}}/pyproject.toml | 29 ++++ 4 files changed, 121 insertions(+), 53 deletions(-) diff --git a/{{cookiecutter.project_slug}}/CHANGES.rst b/{{cookiecutter.project_slug}}/CHANGES.rst index 148566b36..2c9164037 100644 --- a/{{cookiecutter.project_slug}}/CHANGES.rst +++ b/{{cookiecutter.project_slug}}/CHANGES.rst @@ -2,6 +2,9 @@ Changelog ========= +`Unreleased `_ (latest) +====================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} + {{ cookiecutter.version }} ({% now 'local' %}) {% for _ in cookiecutter.version %}-{% endfor -%}----------- diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst index 951cc9e7f..564550562 100644 --- a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst +++ b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst @@ -1,6 +1,3 @@ -.. highlight:: shell - -============ Contributing ============ @@ -62,8 +59,10 @@ Get Started! Anaconda Python users: Due to the complexity of some packages, the default dependency solver can take a long time to resolve the environment. Consider running the following commands in order to speed up the process:: - $ conda install -n base conda-libmamba-solver - $ conda config --set solver libmamba + .. code-block:: console + + conda install -n base conda-libmamba-solver + conda config --set solver libmamba For more information, please see the following link: https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community @@ -76,70 +75,84 @@ Ready to contribute? Here's how to set up ``{{ cookiecutter.project_slug }}`` fo #. Fork the ``{{ cookiecutter.project_slug }}`` repo on GitHub. #. Clone your fork locally:: - $ git clone git@github.com:your_name_here/{{ cookiecutter.project_slug }}.git + .. code-block:: console + + git clone git@github.com:your_name_here/{{ cookiecutter.project_slug }}.git #. Install your local copy into a development environment. {% if cookiecutter.use_conda == 'y' -%} You can create a new Anaconda development environment with:: - $ conda env create -f environment-dev.yml - $ conda activate {{ cookiecutter.project_slug }} - $ flit install --symlink + .. code-block:: console + + conda env create -f environment-dev.yml + conda activate {{ cookiecutter.project_slug }} + make dev {%- else -%} Using ``virtualenv`` (``virtualenvwrapper``), you can create a new development environment with:: - $ python -m pip install flit virtualenvwrapper - $ mkvirtualenv {{ cookiecutter.project_slug }} - $ cd {{ cookiecutter.project_slug }}/ - $ flit install --symlink + .. code-block:: console + + python -m pip install virtualenvwrapper + mkvirtualenv {{ cookiecutter.project_slug }} + cd {{ cookiecutter.project_slug }}/ + make dev {%- endif %} This installs ``{{ cookiecutter.project_slug }}`` in an "editable" state, meaning that changes to the code are immediately seen by the environment. -#. To ensure a consistent coding style, install the ``pre-commit`` hooks to your local clone:: - - $ pre-commit install +#. To ensure a consistent coding style, ``make dev`` also installs the ``pre-commit`` hooks to your local clone:: On commit, ``pre-commit`` will check that{% if cookiecutter.use_black == 'y' %} ``black``, ``blackdoc``, ``isort``,{% endif %} ``flake8``, and ``ruff`` checks are passing, perform automatic fixes if possible, and warn of violations that require intervention. If your commit fails the checks initially, simply fix the errors, re-add the files, and re-commit. You can also run the hooks manually with:: - $ pre-commit run -a + .. code-block:: console + + pre-commit run -a - If you want to skip the ``pre-commit`` hooks temporarily, you can pass the ``--no-verify`` flag to `$ git commit`. + If you want to skip the ``pre-commit`` hooks temporarily, you can pass the ``--no-verify`` flag to `git commit`. #. Create a branch for local development:: - $ git checkout -b name-of-your-bugfix-or-feature + .. code-block:: console + + git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. #. When you're done making changes, we **strongly** suggest running the tests in your environment or with the help of ``tox``:: - $ python -m pytest + .. code-block:: console + + python -m pytest # Or, to run multiple build tests - $ tox + tox #. Commit your changes and push your branch to GitHub:: - $ git add . - $ git commit -m "Your detailed description of your changes." - $ git push origin name-of-your-bugfix-or-feature + .. code-block:: console + + git add . + git commit -m "Your detailed description of your changes." + git push origin name-of-your-bugfix-or-feature - If ``pre-commit`` hooks fail, try re-committing your changes (or, if need be, you can skip them with `$ git commit --no-verify`). + If ``pre-commit`` hooks fail, try re-committing your changes (or, if need be, you can skip them with `git commit --no-verify`). #. Submit a `Pull Request `_ through the GitHub website. #. When pushing your changes to your branch on GitHub, the documentation will automatically be tested to reflect the changes in your Pull Request. This build process can take several minutes at times. If you are actively making changes that affect the documentation and wish to save time, you can compile and test your changes beforehand locally with:: + .. code-block:: console + # To generate the html and open it in your browser - $ make docs + make docs # To only generate the html - $ make autodoc - $ make -C docs html + make autodoc + make -C docs html # To simply test that the docs pass build checks - $ tox -e docs + tox -e docs #. Once your Pull Request has been accepted and merged to the ``main`` branch, several automated workflows will be triggered: @@ -165,19 +178,23 @@ Tips To run a subset of tests:: + .. code-block:: console + {% if cookiecutter.use_pytest == 'y' -%} - $ pytest tests.test_{{ cookiecutter.project_slug }} + pytest tests.test_{{ cookiecutter.project_slug }} {%- else -%} - $ python -m unittest tests.test_{{ cookiecutter.project_slug }} + python -m unittest tests.test_{{ cookiecutter.project_slug }} {%- endif %} To run specific code style checks:: - $ black --check {{ cookiecutter.project_slug }} tests - $ isort --check {{ cookiecutter.project_slug }} tests - $ blackdoc --check {{ cookiecutter.project_slug }} docs - $ ruff {{ cookiecutter.project_slug }} tests - $ flake8 {{ cookiecutter.project_slug }} tests + .. code-block:: console + + black --check {{ cookiecutter.project_slug }} tests + isort --check {{ cookiecutter.project_slug }} tests + blackdoc --check {{ cookiecutter.project_slug }} docs + ruff {{ cookiecutter.project_slug }} tests + flake8 {{ cookiecutter.project_slug }} tests To get ``black``, ``isort``, ``blackdoc``, ``ruff``, and ``flake8`` (with plugins ``flake8-alphabetize`` and ``flake8-rst-docstrings``) simply install them with `pip` {% if cookiecutter.use_conda == 'y' %}(or `conda`) {% endif %}into your environment. @@ -194,14 +211,18 @@ A reminder for the **maintainers** on how to deploy. This section is only releva #. Update the `CHANGES.rst` file to change the `Unreleased` section to the current date. #. Bump the version in your branch to the next version (e.g. `v0.1.0 -> v0.2.0`):: - $ bump-my-version bump minor # In most cases, we will be releasing a minor version - $ git push + .. code-block:: console + + bump-my-version bump minor # In most cases, we will be releasing a minor version + git push #. Create a pull request from your branch to `main`. #. Once the pull request is merged, create a new release on GitHub. On the main branch, run:: - $ git tag v0.2.0 - $ git push --tags + .. code-block:: console + + git tag v0.2.0 + git push --tags This will trigger a GitHub workflow to build the package and upload it to TestPyPI. At the same time, the GitHub workflow will create a draft release on GitHub. Assuming that the workflow passes, the final release can then be published on GitHub by finalizing the draft release. @@ -221,17 +242,21 @@ The simple approach The simplest approach to packaging for general support (pip wheels) requires that ``flit`` be installed:: - $ python -m pip install flit + .. code-block:: console + + python -m pip install flit From the command line on your Linux distribution, simply run the following from the clone's main dev branch:: + .. code-block:: console + # To build the packages (sources and wheel) - $ python -m flit build + make dist # To upload to PyPI - $ python -m flit publish dist/* + make release -The new version based off of the version checked out will now be available via `pip` (`$ pip install {{ cookiecutter.project_slug }}`). +The new version based off of the version checked out will now be available via `pip` (`pip install {{ cookiecutter.project_slug }}`). Releasing on conda-forge ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -245,8 +270,10 @@ Before preparing an initial release on conda-forge, we *strongly* suggest consul In order to create a new conda build recipe, to be used when proposing packages to the conda-forge repository, we strongly suggest using the ``grayskull`` tool:: - $ python -m pip install grayskull - $ grayskull pypi {{ cookiecutter.project_slug }} + .. code-block:: console + + python -m pip install grayskull + grayskull pypi {{ cookiecutter.project_slug }} For more information on ``grayskull``, please see the following link: https://github.com/conda/grayskull @@ -271,17 +298,25 @@ docker images (at time of writing, we endorse using `manylinux_2_24_x86_64`). With `docker` installed and running, begin by pulling the image:: - $ sudo docker pull quay.io/pypa/manylinux_2_24_x86_64 + .. code-block:: console + + sudo docker pull quay.io/pypa/manylinux_2_24_x86_64 From the {{ cookiecutter.project_slug }} source folder we can enter into the docker container, providing access to the `{{ cookiecutter.project_slug }}` source files by linking them to the running image:: - $ sudo docker run --rm -ti -v $(pwd):/{{ cookiecutter.project_slug }} -w /{{ cookiecutter.project_slug }} quay.io/pypa/manylinux_2_24_x86_64 bash + .. code-block:: console + + sudo docker run --rm -ti -v $(pwd):/{{ cookiecutter.project_slug }} -w /{{ cookiecutter.project_slug }} quay.io/pypa/manylinux_2_24_x86_64 bash Finally, to build the wheel, we run it against the provided Python3.9 binary:: - $ /opt/python/cp39-cp39m/bin/python -m build --sdist --wheel + .. code-block:: console + + /opt/python/cp39-cp39m/bin/python -m build --sdist --wheel This will then place two files in `{{ cookiecutter.project_slug }}/dist/` ("{{ cookiecutter.project_slug }}-1.2.3-py3-none-any.whl" and "{{ cookiecutter.project_slug }}-1.2.3.tar.gz"). -We can now leave our docker container (`$ exit`) and continue with uploading the files to PyPI:: +We can now leave our docker container (`exit`) and continue with uploading the files to PyPI:: + + .. code-block:: console - $ twine upload dist/* + twine upload dist/* diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index a1f6a5670..9a4fda43a 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -138,7 +138,8 @@ release: dist ## package and upload a release python -m flit publish dist/* install: clean ## install the package to the active Python's site-packages - python -m flit install + python -m pip install . dev: clean ## install the package to the active Python's site-packages - python -m flit install --symlink + python -m pip install --editable .[all] + pre-commit install diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 851e84a03..83ecc8821 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -90,6 +90,9 @@ docs = [ "ipykernel", "jupyter_client" ] +all = ["xncml[dev]", "xncml[docs]"] +{%- else %} +all = ["xncml[dev]"] {%- endif %} {%- if cookiecutter.command_line_interface != 'No command-line interface' %} @@ -147,6 +150,32 @@ search = "\"version\": \"{current_version}\"" replace = "\"version\": \"{new_version}\"" {%- endif %} + +[[tool.bumpversion.files]] +filename = "CHANGES.rst" +search = """\ +`Unreleased `_ (latest) +====================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} + +""" +replace = """\ +`Unreleased `_ (latest) +====================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} + +Changes: +-------- +- No change. + +Fixes: +------ +- No change. + +.. _changes_{new_version}: + +`{new_version} `_ ({now:%%Y-%%m-%%d}) +==================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} +""" + [tool.bumpversion.parts.build] independent = false From eb54552449efdd1168bc809f6eb8b1101356a2c5 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Thu, 2 May 2024 17:39:21 +0200 Subject: [PATCH 02/17] enh: Update CONTRIBUTING.rst Apply same reccomendations as in the templates for the cookicutter root CONTRIBUTING.rst. --- CONTRIBUTING.rst | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index e1c923482..4ab3a23e1 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,4 +1,3 @@ -============ Contributing ============ @@ -58,15 +57,15 @@ Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local dev .. code-block:: bash - $ cd path_for_the_repo - $ git clone git@github.com:YOUR_NAME/cookiecutter-pypackage.git + cd path_for_the_repo + git clone git@github.com:YOUR_NAME/cookiecutter-pypackage.git #. Assuming you have virtualenv installed (If you have Python 3.8+ this should already be there), you can create a new environment for your local development by typing: .. code-block:: bash - $ virtualenv cookiecutter-pypackage-env - $ source cookiecutter-pypackage-env/bin/activate + virtualenv cookiecutter-pypackage-env + source cookiecutter-pypackage-env/bin/activate This should change the shell to look something like: @@ -78,7 +77,7 @@ Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local dev .. code-block:: bash - $ git checkout -b name-of-your-bugfix-or-feature + git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. @@ -86,27 +85,27 @@ Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local dev .. code-block:: bash - $ flake8 ./tests + flake8 ./tests #. The next step would be to run the test cases. `cookiecutter-pypackage` testing uses the `pytest` framework. Before you run `pytest` you should ensure all dependencies are installed: .. code-block:: bash - $ pip install -rrequirements_dev.txt - $ pytest ./tests + pip install -r requirements_dev.txt + pytest ./tests If you get any errors while installing cryptography package (something like `#include `). Please update your pip version and try again: .. code-block:: bash # Update pip - $ pip install -U pip + pip install -U pip #. Before raising a pull request you should also run tox. This will run the tests across different versions of Python: .. code-block:: bash - $ tox + tox If you are missing flake8, pytest and/or tox, just `pip install` them into your virtualenv. @@ -116,9 +115,9 @@ Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local dev .. code-block:: bash - $ git add . - $ git commit -m "Your detailed description of your changes." - $ git push origin name-of-your-bugfix-or-feature + git add . + git commit -m "Your detailed description of your changes." + git push origin name-of-your-bugfix-or-feature #. Submit a pull request through the GitHub website. @@ -146,27 +145,27 @@ To write and run your new test, follow these steps: .. code-block:: bash - $ git stash - $ git stash list + git stash + git stash list #. Run your test and confirm that your test fails. If your test does not fail, rewrite the test until it fails on the original code: .. code-block:: bash - $ pytest ./tests + pytest ./tests #. (Optional) Run the tests with tox to ensure that the code changes work with different Python versions: .. code-block:: bash - $ tox + tox #. Proceed work on your bug fix or new feature or restore your changes. To restore your stashed changes and confirm their restoration: .. code-block:: bash - $ git stash pop - $ git stash list + git stash pop + git stash list #. Rerun your test and confirm that your test passes. If it passes, congratulations! From 19d2acffd6a09e833d7603a984068c1aae6e3fc8 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Fri, 3 May 2024 10:41:30 +0200 Subject: [PATCH 03/17] fix: lint pyprojet.toml --- {{cookiecutter.project_slug}}/pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 83ecc8821..05e421864 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -150,7 +150,6 @@ search = "\"version\": \"{current_version}\"" replace = "\"version\": \"{new_version}\"" {%- endif %} - [[tool.bumpversion.files]] filename = "CHANGES.rst" search = """\ From c017cabb972efc16fe6b1001e054ca9bf7ea8dd0 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Fri, 3 May 2024 11:44:28 +0200 Subject: [PATCH 04/17] fix: bumversion templating --- {{cookiecutter.project_slug}}/pyproject.toml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 05e421864..df2d915d2 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -154,12 +154,18 @@ replace = "\"version\": \"{new_version}\"" filename = "CHANGES.rst" search = """\ `Unreleased `_ (latest) -====================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} +================================ +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} +============= + """ replace = """\ `Unreleased `_ (latest) -====================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} +================================ +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} +============= + Changes: -------- @@ -172,7 +178,10 @@ Fixes: .. _changes_{new_version}: `{new_version} `_ ({now:%%Y-%%m-%%d}) -==================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} +=========================== +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} +============================ + """ [tool.bumpversion.parts.build] From 08f709079bf00aca63387c856f4fcdcfb3bd2ef2 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Fri, 3 May 2024 13:22:34 +0200 Subject: [PATCH 05/17] fix: more minor fixes --- {{cookiecutter.project_slug}}/CHANGES.rst | 6 ++++-- {{cookiecutter.project_slug}}/pyproject.toml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/CHANGES.rst b/{{cookiecutter.project_slug}}/CHANGES.rst index 2c9164037..1548f3e3c 100644 --- a/{{cookiecutter.project_slug}}/CHANGES.rst +++ b/{{cookiecutter.project_slug}}/CHANGES.rst @@ -3,9 +3,11 @@ Changelog ========= `Unreleased `_ (latest) -====================={% for _ in cookiecutter.github_username %}={% endfor -%}{% for _ in cookiecutter.project_slug %}={% endfor -%} +================================ +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} +============= {{ cookiecutter.version }} ({% now 'local' %}) -{% for _ in cookiecutter.version %}-{% endfor -%}----------- +{% for _ in cookiecutter.version %}-{% endfor -%}------------- * First release on PyPI. diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index df2d915d2..a0f5d97ed 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -90,9 +90,9 @@ docs = [ "ipykernel", "jupyter_client" ] -all = ["xncml[dev]", "xncml[docs]"] +all = ["{{ cookiecutter.project_slug }}[dev]", "{{ cookiecutter.project_slug }}[docs]"] {%- else %} -all = ["xncml[dev]"] +all = ["{{ cookiecutter.project_slug }}[dev]"] {%- endif %} {%- if cookiecutter.command_line_interface != 'No command-line interface' %} From de777009894a86753f6cd976d89e62fed408200d Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Fri, 3 May 2024 13:43:32 +0200 Subject: [PATCH 06/17] fix: remove creation of date in CHANGES.rst Only bump2version allow this syntaxt to add a date when bumping. We use bumpmyversion here. --- {{cookiecutter.project_slug}}/pyproject.toml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index a0f5d97ed..a16bdbf6c 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -158,7 +158,6 @@ search = """\ {%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} ============= - """ replace = """\ `Unreleased `_ (latest) @@ -166,7 +165,6 @@ replace = """\ {%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} ============= - Changes: -------- - No change. @@ -177,10 +175,10 @@ Fixes: .. _changes_{new_version}: -`{new_version} `_ ({now:%%Y-%%m-%%d}) +`{new_version} `_ =========================== {%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} -============================ +======= """ From 146f513a159933c5514782c7e0fd3c2b60165d5f Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 6 May 2024 11:34:43 -0400 Subject: [PATCH 07/17] optional default value --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ba420157f..5c36d74b6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BAKE_OPTIONS=--no-input +BAKE_OPTIONS ?= --no-input help: @echo "bake generate project using defaults" From b7ebd249d368c65ea9e25a974aabf98eecb56e75 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 6 May 2024 11:34:51 -0400 Subject: [PATCH 08/17] add prompts --- cookiecutter.json | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index c918373c9..bdc4859b7 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -23,5 +23,24 @@ "GNU General Public License v3", "Not open source" ], - "generated_with_cruft": "y" + "generated_with_cruft": "y", + "__prompts__": { + "full_name": "Your full name", + "email": "Your email address", + "github_username": "Your GitHub username (or organization)", + "project_name": "The name of your project", + "project_short_description": "A short description of your project", + "pypi_username": "Your PyPI username (or organization)", + "version": "The version of your project", + "use_pytest": "Do you want to use pytest?", + "use_black": "Do you want to use Black for code formatting?", + "use_conda": "Do you want to add configurations for Anaconda package management?", + "add_pyup_badge": "Do you want to add a pyup.io badge? (not recommended)", + "make_docs": "Do you want to generate documentation files", + "add_translations": "Do you want to add translations?", + "command_line_interface": "Which command-line interface do you want to use?", + "create_author_file": "Do you want to create an AUTHORS.rst file?", + "open_source_license": "Which open-source license do you want to use?", + "generated_with_cruft": "Was this project generated with Cruft? (Add a '.cruft.json' file)" + } } From 06fd4602c50a1d580bb916bd02e64e3d9bb1fac4 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Wed, 8 May 2024 09:11:31 +0200 Subject: [PATCH 09/17] improve bumpmyversion templates --- {{cookiecutter.project_slug}}/CHANGES.rst | 11 +++---- {{cookiecutter.project_slug}}/pyproject.toml | 33 ++++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/{{cookiecutter.project_slug}}/CHANGES.rst b/{{cookiecutter.project_slug}}/CHANGES.rst index 1548f3e3c..6c57a6668 100644 --- a/{{cookiecutter.project_slug}}/CHANGES.rst +++ b/{{cookiecutter.project_slug}}/CHANGES.rst @@ -3,11 +3,10 @@ Changelog ========= `Unreleased `_ (latest) -================================ -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} -============= - -{{ cookiecutter.version }} ({% now 'local' %}) -{% for _ in cookiecutter.version %}-{% endfor -%}------------- +-------------------------------- +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} +------------- +Changes +^^^^^^^ * First release on PyPI. diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index a16bdbf6c..9a8828844 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -154,31 +154,32 @@ replace = "\"version\": \"{new_version}\"" filename = "CHANGES.rst" search = """\ `Unreleased `_ (latest) -================================ -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} -============= +-------------------------------- +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} +------------- + """ replace = """\ `Unreleased `_ (latest) -================================ -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} -============= +-------------------------------- +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} +------------- -Changes: --------- -- No change. +Changes +^^^^^^^ +* No change. -Fixes: ------- -- No change. +Fixes +^^^^^ +* No change. .. _changes_{new_version}: -`{new_version} `_ -=========================== -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}={% endfor -%} -======= +`v{new_version} `_ +--------------------------- +{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} +------- """ From e46b715cd33bbc2898db99ca2d4f97a6381fd64a Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Wed, 8 May 2024 09:11:48 +0200 Subject: [PATCH 10/17] doc: add python -m when needed --- {{cookiecutter.project_slug}}/CONTRIBUTING.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst index 564550562..15ac20b20 100644 --- a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst +++ b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst @@ -128,7 +128,7 @@ Ready to contribute? Here's how to set up ``{{ cookiecutter.project_slug }}`` fo python -m pytest # Or, to run multiple build tests - tox + python -m tox #. Commit your changes and push your branch to GitHub:: @@ -152,7 +152,7 @@ Ready to contribute? Here's how to set up ``{{ cookiecutter.project_slug }}`` fo make autodoc make -C docs html # To simply test that the docs pass build checks - tox -e docs + python -m tox -e docs #. Once your Pull Request has been accepted and merged to the ``main`` branch, several automated workflows will be triggered: @@ -190,11 +190,11 @@ To run specific code style checks:: .. code-block:: console - black --check {{ cookiecutter.project_slug }} tests - isort --check {{ cookiecutter.project_slug }} tests - blackdoc --check {{ cookiecutter.project_slug }} docs - ruff {{ cookiecutter.project_slug }} tests - flake8 {{ cookiecutter.project_slug }} tests + python -m black --check {{ cookiecutter.project_slug }} tests + python -m isort --check {{ cookiecutter.project_slug }} tests + python -m blackdoc --check {{ cookiecutter.project_slug }} docs + python -m ruff {{ cookiecutter.project_slug }} tests + python -m flake8 {{ cookiecutter.project_slug }} tests To get ``black``, ``isort``, ``blackdoc``, ``ruff``, and ``flake8`` (with plugins ``flake8-alphabetize`` and ``flake8-rst-docstrings``) simply install them with `pip` {% if cookiecutter.use_conda == 'y' %}(or `conda`) {% endif %}into your environment. @@ -319,4 +319,4 @@ We can now leave our docker container (`exit`) and continue with uploading the f .. code-block:: console - twine upload dist/* + python -m twine upload dist/* From 71cd08de2cf288413605a4ef9dfdb79894427f97 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 8 May 2024 17:50:05 -0400 Subject: [PATCH 11/17] dynamic generation of underlines and Changes for cookiecutter and jinja --- Makefile | 9 +++++---- {{cookiecutter.project_slug}}/CHANGES.rst | 21 +++++++++++++++++--- {{cookiecutter.project_slug}}/pyproject.toml | 21 +++++++------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index cff43bc99..1350d5fb8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ BAKE_OPTIONS ?= --no-input +NO_CRUFT = generated_with_cruft=n help: @echo "bake Generate project using defaults" @@ -6,17 +7,17 @@ help: @echo "test Run the tests" @echo "replay Replay last cookiecutter run and watch for changes" @echo "watch Generate project using defaults and watch for changes" - + bake: # Generate project using defaults - cookiecutter $(BAKE_OPTIONS) . --overwrite-if-exists + cookiecutter $(BAKE_OPTIONS) . --overwrite-if-exists $(NO_CRUFT) watch: bake - watchmedo shell-command -p '*.*' -c 'make bake -e BAKE_OPTIONS=$(BAKE_OPTIONS)' -W -R -D \{{cookiecutter.project_slug}}/ + watchmedo shell-command -p '*.*' -c 'make bake -e BAKE_OPTIONS=$(BAKE_OPTIONS)' -W -R -D \{{cookiecutter.project_slug}}/ $(NO_CRUFT) replay: BAKE_OPTIONS=--replay replay: watch ; test: - pytest \ No newline at end of file + pytest diff --git a/{{cookiecutter.project_slug}}/CHANGES.rst b/{{cookiecutter.project_slug}}/CHANGES.rst index 6c57a6668..d7aa74c7c 100644 --- a/{{cookiecutter.project_slug}}/CHANGES.rst +++ b/{{cookiecutter.project_slug}}/CHANGES.rst @@ -3,9 +3,24 @@ Changelog ========= `Unreleased `_ (latest) --------------------------------- -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} -------------- +{{ '-' * ('`Unreleased `_ (latest)')|length }} + +Contributors: + +Changes +^^^^^^^ +* No change. + +Fixes +^^^^^ +* No change. + +.. _changes_{{ cookiecutter.version }}: + +`v{{ cookiecutter.version }} `_ +{{ '-' * ('`v' + cookiecutter.version + ' `_')|length }} + +Contributors: {{ cookiecutter.full_name }} `{{ cookiecutter.github_username }} `_ Changes ^^^^^^^ diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 0b6348f37..e94407931 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -128,7 +128,7 @@ commit = true commit_args = "--no-verify" tag = false tag_name = "v{new_version}" -allow_dirty = false +allow_dirty = true parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)(\\-(?P[a-z]+)(\\.(?P\\d+)))?" serialize = [ "{major}.{minor}.{patch}-{release}.{build}", @@ -136,7 +136,7 @@ serialize = [ ] [[tool.bumpversion.files]] -filename = "{{ cookiecutter.project_slug }}/__init__.py" +filename = "src/{{ cookiecutter.project_slug }}/__init__.py" search = "__version__ = \"{current_version}\"" replace = "__version__ = \"{new_version}\"" @@ -156,17 +156,13 @@ replace = "\"version\": \"{new_version}\"" filename = "CHANGES.rst" search = """\ `Unreleased `_ (latest) --------------------------------- -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} -------------- - - +{{ '-' * ('`Unreleased `_ (latest)')|length }} """ replace = """\ `Unreleased `_ (latest) --------------------------------- -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} -------------- +{{ '-' * ('`Unreleased `_ (latest)')|length }} + +Contributors: Changes ^^^^^^^ @@ -179,10 +175,7 @@ Fixes .. _changes_{new_version}: `v{new_version} `_ ---------------------------- -{%- for _ in range((cookiecutter.github_username | length) + (cookiecutter.project_slug | length)) %}-{% endfor -%} -------- - +{{ '-' * ('`v' + cookiecutter.version + ' `_ (latest)')|length }} """ [tool.bumpversion.parts.build] From e067601c38d7ec70f732de6e7953e603ad6541b7 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Mon, 13 May 2024 09:48:39 +0200 Subject: [PATCH 12/17] maint: Remove bump templating of CHANGES.rst --- {{cookiecutter.project_slug}}/pyproject.toml | 26 -------------------- 1 file changed, 26 deletions(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index e94407931..22b6cdd89 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -152,32 +152,6 @@ search = "\"version\": \"{current_version}\"" replace = "\"version\": \"{new_version}\"" {%- endif %} -[[tool.bumpversion.files]] -filename = "CHANGES.rst" -search = """\ -`Unreleased `_ (latest) -{{ '-' * ('`Unreleased `_ (latest)')|length }} -""" -replace = """\ -`Unreleased `_ (latest) -{{ '-' * ('`Unreleased `_ (latest)')|length }} - -Contributors: - -Changes -^^^^^^^ -* No change. - -Fixes -^^^^^ -* No change. - -.. _changes_{new_version}: - -`v{new_version} `_ -{{ '-' * ('`v' + cookiecutter.version + ' `_ (latest)')|length }} -""" - [tool.bumpversion.parts.build] independent = false From 1bc3dcfbbf26671ed6ad3c90f27627fbe997d7a1 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Mon, 13 May 2024 10:32:48 +0200 Subject: [PATCH 13/17] maint: Create releasing.rst Moved the 'how to release' from the contributing guide to a dedicated releasing.rst guide. --- .../CONTRIBUTING.rst | 123 ----------------- .../docs/releasing.rst | 127 ++++++++++++++++++ 2 files changed, 127 insertions(+), 123 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/docs/releasing.rst diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst index ff89462a2..ad1bf488b 100644 --- a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst +++ b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst @@ -198,129 +198,6 @@ To run specific code style checks:: To get ``black``, ``isort``, ``blackdoc``, ``ruff``, and ``flake8`` (with plugins ``flake8-alphabetize`` and ``flake8-rst-docstrings``) simply install them with `pip` {% if cookiecutter.use_conda == 'y' %}(or `conda`) {% endif %}into your environment. -Deployment ----------- - -A reminder for the **maintainers** on how to deploy. This section is only relevant when producing a new point release for the package. - -.. warning:: - - It is important to be aware that any changes to files found within the ``{{ cookiecutter.project_slug }}`` folder (with the exception of ``{{ cookiecutter.project_slug }}/__init__.py``) will trigger the ``bump-version.yml`` workflow. Be careful not to commit changes to files in this folder when preparing a new release. - -#. Create a new branch from `main` (e.g. `release-0.2.0`). -#. Update the `CHANGES.rst` file to change the `Unreleased` section to the current date. -#. Bump the version in your branch to the next version (e.g. `v0.1.0 -> v0.2.0`):: - - .. code-block:: console - - bump-my-version bump minor # In most cases, we will be releasing a minor version - git push - -#. Create a pull request from your branch to `main`. -#. Once the pull request is merged, create a new release on GitHub. On the main branch, run:: - - .. code-block:: console - - git tag v0.2.0 - git push --tags - - This will trigger a GitHub workflow to build the package and upload it to TestPyPI. At the same time, the GitHub workflow will create a draft release on GitHub. Assuming that the workflow passes, the final release can then be published on GitHub by finalizing the draft release. - -#. Once the release is published, the `publish-pypi.yml` workflow will go into an `awaiting approval` mode on Github Actions. Only authorized users may approve this workflow (notifications will be sent) to trigger the upload to PyPI. - -.. warning:: - - Uploads to PyPI can **never** be overwritten. If you make a mistake, you will need to bump the version and re-release the package. If the package uploaded to PyPI is broken, you should modify the GitHub release to mark the package as broken, as well as yank the package (mark the version "broken") on PyPI. - -Packaging ---------- - -When a new version has been minted (features have been successfully integrated test coverage and stability is adequate), maintainers should update the pip-installable package (wheel and source release) on PyPI as well as the binary on conda-forge. - -The simple approach -~~~~~~~~~~~~~~~~~~~ - -The simplest approach to packaging for general support (pip wheels) requires that ``flit`` be installed:: - - .. code-block:: console - - python -m pip install flit - -From the command line on your Linux distribution, simply run the following from the clone's main dev branch:: - - .. code-block:: console - - # To build the packages (sources and wheel) - make dist - - # To upload to PyPI - make release - -The new version based off of the version checked out will now be available via `pip` (`pip install {{ cookiecutter.project_slug }}`). - -Releasing on conda-forge -~~~~~~~~~~~~~~~~~~~~~~~~ - -Initial Release -^^^^^^^^^^^^^^^ - -Before preparing an initial release on conda-forge, we *strongly* suggest consulting the following links: - * https://conda-forge.org/docs/maintainer/adding_pkgs.html - * https://github.com/conda-forge/staged-recipes - -In order to create a new conda build recipe, to be used when proposing packages to the conda-forge repository, we strongly suggest using the ``grayskull`` tool:: - - .. code-block:: console - - python -m pip install grayskull - grayskull pypi {{ cookiecutter.project_slug }} - -For more information on ``grayskull``, please see the following link: https://github.com/conda/grayskull - -Before updating the main conda-forge recipe, we echo the conda-forge documentation and *strongly* suggest performing the following checks: - * Ensure that dependencies and dependency versions correspond with those of the tagged version, with open or pinned versions for the `host` requirements. - * If possible, configure tests within the conda-forge build CI (e.g. `imports: {{ cookiecutter.project_slug }}`, `commands: pytest {{ cookiecutter.project_slug }}`). - -Subsequent releases -^^^^^^^^^^^^^^^^^^^ - -If the conda-forge feedstock recipe is built from PyPI, then when a new release is published on PyPI, `regro-cf-autotick-bot` will open Pull Requests automatically on the conda-forge feedstock. It is up to the conda-forge feedstock maintainers to verify that the package is building properly before merging the Pull Request to the main branch. - -Building sources for wide support with `manylinux` image -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. warning:: - This section is for building source files that link to or provide links to C/C++ dependencies. - It is not necessary to perform the following when building pure Python packages. - -In order to do ensure best compatibility across architectures, we suggest building wheels using the `PyPA`'s `manylinux` -docker images (at time of writing, we endorse using `manylinux_2_24_x86_64`). - -With `docker` installed and running, begin by pulling the image:: - - .. code-block:: console - - sudo docker pull quay.io/pypa/manylinux_2_24_x86_64 - -From the {{ cookiecutter.project_slug }} source folder we can enter into the docker container, providing access to the `{{ cookiecutter.project_slug }}` source files by linking them to the running image:: - - .. code-block:: console - - sudo docker run --rm -ti -v $(pwd):/{{ cookiecutter.project_slug }} -w /{{ cookiecutter.project_slug }} quay.io/pypa/manylinux_2_24_x86_64 bash - -Finally, to build the wheel, we run it against the provided Python3.9 binary:: - - .. code-block:: console - - /opt/python/cp39-cp39m/bin/python -m build --sdist --wheel - -This will then place two files in `{{ cookiecutter.project_slug }}/dist/` ("{{ cookiecutter.project_slug }}-1.2.3-py3-none-any.whl" and "{{ cookiecutter.project_slug }}-1.2.3.tar.gz"). -We can now leave our docker container (`exit`) and continue with uploading the files to PyPI:: - - .. code-block:: console - - python -m twine upload dist/* - Code of Conduct --------------- diff --git a/{{cookiecutter.project_slug}}/docs/releasing.rst b/{{cookiecutter.project_slug}}/docs/releasing.rst new file mode 100644 index 000000000..f71069dca --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/releasing.rst @@ -0,0 +1,127 @@ +========= +Releasing +========= + +Deployment +---------- + +A reminder for the **maintainers** on how to deploy. This section is only relevant when producing a new point release for the package. + +.. warning:: + + It is important to be aware that any changes to files found within the ``{{ cookiecutter.project_slug }}`` folder (with the exception of ``{{ cookiecutter.project_slug }}/__init__.py``) will trigger the ``bump-version.yml`` workflow. Be careful not to commit changes to files in this folder when preparing a new release. + +#. Create a new branch from `main` (e.g. `release-0.2.0`). +#. Update the `CHANGES.rst` file to change the `Unreleased` section to the current date. +#. Bump the version in your branch to the next version (e.g. `v0.1.0 -> v0.2.0`):: + + .. code-block:: console + + bump-my-version bump minor # In most cases, we will be releasing a minor version + git push + +#. Create a pull request from your branch to `main`. +#. Once the pull request is merged, create a new release on GitHub. On the main branch, run:: + + .. code-block:: console + + git tag v0.2.0 + git push --tags + + This will trigger a GitHub workflow to build the package and upload it to TestPyPI. At the same time, the GitHub workflow will create a draft release on GitHub. Assuming that the workflow passes, the final release can then be published on GitHub by finalizing the draft release. + +#. Once the release is published, the `publish-pypi.yml` workflow will go into an `awaiting approval` mode on Github Actions. Only authorized users may approve this workflow (notifications will be sent) to trigger the upload to PyPI. + +.. warning:: + + Uploads to PyPI can **never** be overwritten. If you make a mistake, you will need to bump the version and re-release the package. If the package uploaded to PyPI is broken, you should modify the GitHub release to mark the package as broken, as well as yank the package (mark the version "broken") on PyPI. + +Packaging +--------- + +When a new version has been minted (features have been successfully integrated test coverage and stability is adequate), maintainers should update the pip-installable package (wheel and source release) on PyPI as well as the binary on conda-forge. + +The simple approach +~~~~~~~~~~~~~~~~~~~ + +The simplest approach to packaging for general support (pip wheels) requires that ``flit`` be installed:: + + .. code-block:: console + + python -m pip install flit + +From the command line on your Linux distribution, simply run the following from the clone's main dev branch:: + + .. code-block:: console + + # To build the packages (sources and wheel) + make dist + + # To upload to PyPI + make release + +The new version based off of the version checked out will now be available via `pip` (`pip install {{ cookiecutter.project_slug }}`). + +Releasing on conda-forge +~~~~~~~~~~~~~~~~~~~~~~~~ + +Initial Release +^^^^^^^^^^^^^^^ + +Before preparing an initial release on conda-forge, we *strongly* suggest consulting the following links: + * https://conda-forge.org/docs/maintainer/adding_pkgs.html + * https://github.com/conda-forge/staged-recipes + +In order to create a new conda build recipe, to be used when proposing packages to the conda-forge repository, we strongly suggest using the ``grayskull`` tool:: + + .. code-block:: console + + python -m pip install grayskull + grayskull pypi {{ cookiecutter.project_slug }} + +For more information on ``grayskull``, please see the following link: https://github.com/conda/grayskull + +Before updating the main conda-forge recipe, we echo the conda-forge documentation and *strongly* suggest performing the following checks: + * Ensure that dependencies and dependency versions correspond with those of the tagged version, with open or pinned versions for the `host` requirements. + * If possible, configure tests within the conda-forge build CI (e.g. `imports: {{ cookiecutter.project_slug }}`, `commands: pytest {{ cookiecutter.project_slug }}`). + +Subsequent releases +^^^^^^^^^^^^^^^^^^^ + +If the conda-forge feedstock recipe is built from PyPI, then when a new release is published on PyPI, `regro-cf-autotick-bot` will open Pull Requests automatically on the conda-forge feedstock. It is up to the conda-forge feedstock maintainers to verify that the package is building properly before merging the Pull Request to the main branch. + +Building sources for wide support with `manylinux` image +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. warning:: + This section is for building source files that link to or provide links to C/C++ dependencies. + It is not necessary to perform the following when building pure Python packages. + +In order to do ensure best compatibility across architectures, we suggest building wheels using the `PyPA`'s `manylinux` +docker images (at time of writing, we endorse using `manylinux_2_24_x86_64`). + +With `docker` installed and running, begin by pulling the image:: + + .. code-block:: console + + sudo docker pull quay.io/pypa/manylinux_2_24_x86_64 + +From the {{ cookiecutter.project_slug }} source folder we can enter into the docker container, providing access to the `{{ cookiecutter.project_slug }}` source files by linking them to the running image:: + + .. code-block:: console + + sudo docker run --rm -ti -v $(pwd):/{{ cookiecutter.project_slug }} -w /{{ cookiecutter.project_slug }} quay.io/pypa/manylinux_2_24_x86_64 bash + +Finally, to build the wheel, we run it against the provided Python3.9 binary:: + + .. code-block:: console + + /opt/python/cp39-cp39m/bin/python -m build --sdist --wheel + +This will then place two files in `{{ cookiecutter.project_slug }}/dist/` ("{{ cookiecutter.project_slug }}-1.2.3-py3-none-any.whl" and "{{ cookiecutter.project_slug }}-1.2.3.tar.gz"). +We can now leave our docker container (`exit`) and continue with uploading the files to PyPI:: + + .. code-block:: console + + python -m twine upload dist/* + From 6c3c463d203104c87345e03a345f0c4c83facbb2 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Mon, 13 May 2024 11:34:54 +0200 Subject: [PATCH 14/17] fix: lint --- {{cookiecutter.project_slug}}/docs/releasing.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/docs/releasing.rst b/{{cookiecutter.project_slug}}/docs/releasing.rst index f71069dca..7737aa879 100644 --- a/{{cookiecutter.project_slug}}/docs/releasing.rst +++ b/{{cookiecutter.project_slug}}/docs/releasing.rst @@ -124,4 +124,3 @@ We can now leave our docker container (`exit`) and continue with uploading the f .. code-block:: console python -m twine upload dist/* - From ca0170365d975fb10a83ef304474aae8e8ee5d89 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Mon, 13 May 2024 18:24:17 +0200 Subject: [PATCH 15/17] maint: Aplly suggestions from code review Co-authored-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- CONTRIBUTING.rst | 1 + {{cookiecutter.project_slug}}/{CHANGES.rst => CHANGELOG.rst} | 0 {{cookiecutter.project_slug}}/CONTRIBUTING.rst | 1 + .../docs/{changes.rst => changelog.rst} | 0 {{cookiecutter.project_slug}}/docs/index.rst | 1 + 5 files changed, 3 insertions(+) rename {{cookiecutter.project_slug}}/{CHANGES.rst => CHANGELOG.rst} (100%) rename {{cookiecutter.project_slug}}/docs/{changes.rst => changelog.rst} (100%) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 4ab3a23e1..d6fc540f9 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,3 +1,4 @@ +============ Contributing ============ diff --git a/{{cookiecutter.project_slug}}/CHANGES.rst b/{{cookiecutter.project_slug}}/CHANGELOG.rst similarity index 100% rename from {{cookiecutter.project_slug}}/CHANGES.rst rename to {{cookiecutter.project_slug}}/CHANGELOG.rst diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst index ad1bf488b..d24e462b9 100644 --- a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst +++ b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst @@ -1,3 +1,4 @@ +============ Contributing ============ diff --git a/{{cookiecutter.project_slug}}/docs/changes.rst b/{{cookiecutter.project_slug}}/docs/changelog.rst similarity index 100% rename from {{cookiecutter.project_slug}}/docs/changes.rst rename to {{cookiecutter.project_slug}}/docs/changelog.rst diff --git a/{{cookiecutter.project_slug}}/docs/index.rst b/{{cookiecutter.project_slug}}/docs/index.rst index 172867453..cae46ceb8 100644 --- a/{{cookiecutter.project_slug}}/docs/index.rst +++ b/{{cookiecutter.project_slug}}/docs/index.rst @@ -11,6 +11,7 @@ installation usage contributing + releasing {%- if cookiecutter.create_author_file == 'y' %} authors {%- endif %} From 0d153b58abf29b99bbbc0e09228806c7d0951e46 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Mon, 13 May 2024 18:28:03 +0200 Subject: [PATCH 16/17] maint: update docs/changelog.rst inner path --- {{cookiecutter.project_slug}}/docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/docs/changelog.rst b/{{cookiecutter.project_slug}}/docs/changelog.rst index d9e113ec6..565b0521d 100644 --- a/{{cookiecutter.project_slug}}/docs/changelog.rst +++ b/{{cookiecutter.project_slug}}/docs/changelog.rst @@ -1 +1 @@ -.. include:: ../CHANGES.rst +.. include:: ../CHANGELOG.rst From eb50c722e13a6ba0ea824446ffed4d936550ca00 Mon Sep 17 00:00:00 2001 From: Abel Aoun Date: Mon, 13 May 2024 18:33:05 +0200 Subject: [PATCH 17/17] fix: tests --- tests/test_bake_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 6cec49a0c..a5df6ab40 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -186,7 +186,7 @@ def test_bake_without_author_file(cookies): # Assert there are no spaces in the toc tree docs_index_path = result.project_path.joinpath("docs/index.rst") with open(str(docs_index_path)) as index_file: - assert "contributing\n changes" in index_file.read() + assert "releasing\n changes" in index_file.read() # Check that pyproject_path = result.project_path.joinpath("pyproject.toml")