From 311ae33db60bdd3080e590698c1457b5deb22fcb Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:46:16 -0400 Subject: [PATCH 1/4] Use a more modernized approach in the top-level of library --- .github/dependabot.yml | 12 ++++++++- .github/workflows/main.yml | 6 ++--- .readthedocs.yaml | 8 +++--- requirements.in => CI/requirements_ci.in | 0 requirements.txt => CI/requirements_ci.txt | 4 +-- CONTRIBUTING.rst | 14 +++++----- README.rst | 8 +++--- requirements_dev.txt | 11 -------- setup.cfg | 9 ------- setup.py | 27 ++++++++++++++----- tox.ini | 7 +++-- .../.github/dependabot.yml | 5 +++- 12 files changed, 59 insertions(+), 52 deletions(-) rename requirements.in => CI/requirements_ci.in (100%) rename requirements.txt => CI/requirements_ci.txt (95%) delete mode 100644 requirements_dev.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f2ce19fdc..3f11bee3a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,10 +9,20 @@ updates: directory: "/" schedule: interval: "monthly" - open-pull-requests-limit: 10 + groups: + actions: + patterns: + - "*" - package-ecosystem: pip directory: "/" schedule: interval: "monthly" open-pull-requests-limit: 5 + groups: + python: + patterns: + - "setup.py" + ci: + patterns: + - "CI/*" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e44bed171..77044fa0a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: - tox-env: py312 python-version: "3.12" - tox-env: py313 - python-version: "3.13.0-rc.1" + python-version: "3.13.0-rc.2" - tox-env: pypy39 python-version: "pypy3.9" - tox-env: pypy310 @@ -57,9 +57,9 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: pip - - name: Install tox + - name: Install CI dependencies run: | - python -m pip install --require-hashes -r requirements.txt + python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Environment Caching uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f3aa1f5af..515f70b56 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.12" # Build documentation in the docs/ directory with Sphinx sphinx: @@ -17,6 +17,6 @@ sphinx: # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html -# python: -# install: -# - requirements: docs/requirements.txt +python: + install: + - requirements: docs/requirements.txt diff --git a/requirements.in b/CI/requirements_ci.in similarity index 100% rename from requirements.in rename to CI/requirements_ci.in diff --git a/requirements.txt b/CI/requirements_ci.txt similarity index 95% rename from requirements.txt rename to CI/requirements_ci.txt index 0ef6619d9..b322d42da 100644 --- a/requirements.txt +++ b/CI/requirements_ci.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --generate-hashes --output-file=requirements.txt requirements.in +# pip-compile --generate-hashes --output-file=requirements_ci.txt requirements_ci.in # cachetools==5.4.0 \ --hash=sha256:3ae3b49a3d5e28a77a0be2b37dbcb89005058959cb2323858c2657c4a8cab474 \ @@ -55,7 +55,7 @@ tomli==2.0.1 \ tox==4.18.0 \ --hash=sha256:0a457400cf70615dc0627eb70d293e80cd95d8ce174bb40ac011011f0c03a249 \ --hash=sha256:5dfa1cab9f146becd6e351333a82f9e0ade374451630ba65ee54584624c27b58 - # via -r requirements.in + # via -r requirements_ci.in virtualenv==20.26.3 \ --hash=sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a \ --hash=sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index d6fc540f9..df26375ab 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -50,7 +50,8 @@ If you are proposing a new feature: Get Started! ------------ -Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local development. Please note this documentation assumes you already have `virtualenv` and `Git` installed and ready to go. +Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local development. +Please note this documentation assumes you already have `virtualenv` and `Git` installed and ready to go. #. Fork the `cookiecutter-pypackage` repo on GitHub. @@ -82,7 +83,7 @@ Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local dev Now you can make your changes locally. -#. When you're done making changes, check that your changes pass flake8. Since, this package contains mostly templates the flake should be run for tests directory: +#. When you're done making changes, check that your changes pass `flake8`. Since, this package contains mostly templates the flake should be run for tests directory: .. code-block:: bash @@ -100,15 +101,15 @@ Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local dev .. code-block:: bash # Update pip - pip install -U pip + pip install --upgrade pip -#. Before raising a pull request you should also run tox. This will run the tests across different versions of Python: +#. Before raising a pull request you should also run `tox`. This will run the tests across different versions of Python: .. code-block:: bash tox - If you are missing flake8, pytest and/or tox, just `pip install` them into your virtualenv. + If you are missing `flake8`, `pytest` and/or `tox`, just `pip install` them into your virtualenv. #. If your contribution is a bug fix or new feature, you may want to add a test to the existing test suite. See section Add a New Test below for details. @@ -131,7 +132,8 @@ Before you submit a pull request, check that it meets these guidelines: #. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. -#. The pull request should work for Python 3.8, 3.9, 3.10, 3.11, and for PyPy. Check https://github.com/Ouranosinc/cookiecutter-pypackage/actions/workflows/main.yml and make sure that the tests pass for all supported Python versions. +#. The pull request should work for Python 3.8 up to Python 3.13, and for PyPy 3.11 and PyPy 3.12. + Check https://github.com/Ouranosinc/cookiecutter-pypackage/actions/workflows/main.yml and make sure that the tests pass for all supported Python versions. Add a New Test -------------- diff --git a/README.rst b/README.rst index 5d2c6ff7c..ae6ebbe6d 100644 --- a/README.rst +++ b/README.rst @@ -15,10 +15,10 @@ Features -------- * Testing setup with ``unittest`` with ``coverage run`` or ``pytest`` -* `pyproject.toml`_ with flit_ backend for PEP 517/621-compliant packaging. -* `GitHub Actions`_: Ready for GitHub Actions Continuous Integration testing. +* `pyproject.toml`_ with the flit_ backend for PEP 517/621-compliant packaging. +* `GitHub Actions`_: Ready for GitHub Actions Continuous Integration testing and Deployment. * `Conda`_ environment file: Optionally use ``conda env create -f environment-dev.yml`` to create a new environment with the correct Python version. -* Tox_ testing: Setup to easily test for Python 3.8, 3.9, 3.10, 3.11, 3.12, and PyPy3. +* Tox_ testing: Setup to easily test for Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, and PyPy3. * Sphinx_ docs: Documentation ready for generation with, for example, `Read the Docs`_ * pre-commit_ hook: Run your tests and linting (e.g. `black`, `flake8`, `pylint`, etc.) before you commit your code! * `pre-commit.ci`_: Automate `pre-commit` checks and corrections in your Pull Requests. @@ -31,7 +31,7 @@ Features Build Status ------------- -Upstream (audreyfeldroy/cookiecutter-pypackage): |docs-upstream| |pyup-upstream| +Upstream (audreyfeldroy/cookiecutter-pypackage): |docs-upstream| Quickstart ---------- diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index 361279442..000000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,11 +0,0 @@ -alabaster>=0.7.13 -build>=1.2.1 -cookiecutter>=2.6.0 -coverage>=7.5.1 -flit>=3.9.0 -pre-commit>=3.5.0 -pytest-cookies>=0.7.0 -pytest>=8.2.0 -tox>=4.16.0 -twine>=5.0.0 -watchdog>=4.0.0 diff --git a/setup.cfg b/setup.cfg index 5f774da91..5b75d91aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,15 +1,6 @@ -[bumpversion] -current_version = 0.5.10 -commit = True -tag = True - [metadata] description-file = README.rst -[bumpversion:file:setup.py] -search = version='{current_version}' -replace = version='{new_version}' - [tool:pytest] addopts = --verbose diff --git a/setup.py b/setup.py index 32a262f3e..b4178b135 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,17 @@ # !/usr/bin/env python -from distutils.core import setup +from setuptools import setup setup( - name="cookiecutter-pypackage", + name="cookiecutter-pypackage-ouranos", packages=[], version="0.1.0", description="Cookiecutter template for a Python package", - author="Audrey M. Roy Greenfeld", + author="Trevor James Smith", license="BSD", - author_email="audrey@feldroy.com", - url="https://github.com/audreyfeldroy/cookiecutter-pypackage", + author_email="smith.trevorj@ouranos.ca", + url="https://github.com/Ouranosinc/cookiecutter-pypackage", keywords=[ "cookiecutter", "template", @@ -24,8 +24,6 @@ "Intended Audience :: Developers", "Natural Language :: English", "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", @@ -37,4 +35,19 @@ "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development", ], + extras_require={ + "dev": [ + "alabaster>=0.7.13", + "build>=1.2.2", + "cookiecutter>=2.6.0", + "coverage>=7.5.1", + "flit>=3.9.0", + "pre-commit>=3.5.0", + "pytest-cookies>=0.7.0", + "pytest>=8.2.0", + "tox>=4.18.1", + "twine>=5.1.1", + "watchdog>=4.0.0", + ] + }, ) diff --git a/tox.ini b/tox.ini index 2046270ce..17f6a0fbc 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -minversion = 4.17.1 +minversion = 4.18.1 envlist = py{38,39,310,311,312,313}, pypy{39,310}, docs [testenv:docs] @@ -17,11 +17,10 @@ commands = setenv = PYTEST_ADDOPTS = "--color=yes" PYTHONPATH = {toxinidir} -deps = - -r{toxinidir}/requirements_dev.txt +extras = dev download = True commands_pre = pip list - - pip check + pip check commands = pytest {posargs} diff --git a/{{cookiecutter.project_slug}}/.github/dependabot.yml b/{{cookiecutter.project_slug}}/.github/dependabot.yml index 053707cf9..dbeb47997 100644 --- a/{{cookiecutter.project_slug}}/.github/dependabot.yml +++ b/{{cookiecutter.project_slug}}/.github/dependabot.yml @@ -17,6 +17,9 @@ updates: schedule: interval: monthly groups: + ci: + patterns: + - "CI/*" python: patterns: - - "*" + - "pyproject.toml" From ea88d41f3b8e00a4acda1b66c9f938c6ebcd64b1 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:06:26 -0400 Subject: [PATCH 2/4] finalize changes --- .readthedocs.yaml | 8 ++++++-- docs/conf.py | 21 +++++++++++---------- setup.cfg | 3 --- setup.py | 31 ++++++++++++++++++------------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 515f70b56..9647f9849 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.12" + python: "mambaforge-22.9" # Build documentation in the docs/ directory with Sphinx sphinx: @@ -19,4 +19,8 @@ sphinx: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - - requirements: docs/requirements.txt + - method: pip + path: . + extra_requirements: + - dev + - docs diff --git a/docs/conf.py b/docs/conf.py index 4a764c003..2ae2ee37c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,6 +11,7 @@ # # All configuration values have a default; values that are commented out # serve to show the default. +import datetime # import sys # import os @@ -51,18 +52,18 @@ master_doc = 'index' # General information about the project. -project = 'cookiecutter-pypackage' -copyright = '2015, Audrey Roy Greenfeld' -author = 'Audrey Roy Greenfeld' +project = 'cookiecutter-pypackage-ouranos' +copyright = f'2020-{datetime.datetime.now().year}, Trevor James Smith' +author = 'Trevor James Smith' # 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.9.0' +version = '0.1.0' # The full version, including alpha/beta/rc tags. -release = '0.9.0' +release = '0.1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -228,8 +229,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'cookiecutter-pypackage.tex', 'cookiecutter-pypackage Documentation', - 'Audrey Roy Greenfeld', 'manual'), + (master_doc, 'cookiecutter-pypackage-ouranos.tex', 'cookiecutter-pypackage-ouranos Documentation', + 'Trevor James Smith', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -258,7 +259,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'cookiecutter-pypackage', 'cookiecutter-pypackage Documentation', + (master_doc, 'cookiecutter-pypackage-ouranos', 'cookiecutter-pypackage-ouranos Documentation', [author], 1) ] @@ -272,8 +273,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'cookiecutter-pypackage', 'cookiecutter-pypackage Documentation', - author, 'cookiecutter-pypackage', 'One line description of project.', + (master_doc, 'cookiecutter-pypackage-ouranos', 'cookiecutter-pypackage-ouranos Documentation', + author, 'cookiecutter-pypackage-ouranos', 'One line description of project.', 'Miscellaneous'), ] diff --git a/setup.cfg b/setup.cfg index 5b75d91aa..b9033d5a7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[metadata] -description-file = README.rst - [tool:pytest] addopts = --verbose diff --git a/setup.py b/setup.py index b4178b135..69eeff90a 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,15 @@ # !/usr/bin/env python from setuptools import setup - +from pathlib import Path setup( name="cookiecutter-pypackage-ouranos", packages=[], version="0.1.0", description="Cookiecutter template for a Python package", + long_description=Path(__file__).parent.joinpath("README.rst").read_text(), + long_description_content_type="text/x-rst", author="Trevor James Smith", license="BSD", author_email="smith.trevorj@ouranos.ca", @@ -37,17 +39,20 @@ ], extras_require={ "dev": [ - "alabaster>=0.7.13", - "build>=1.2.2", - "cookiecutter>=2.6.0", - "coverage>=7.5.1", - "flit>=3.9.0", - "pre-commit>=3.5.0", - "pytest-cookies>=0.7.0", - "pytest>=8.2.0", - "tox>=4.18.1", - "twine>=5.1.1", - "watchdog>=4.0.0", - ] + "build >=1.2.2", + "cookiecutter >=2.6.0", + "coverage >=7.5.1", + "flit >=3.9.0", + "pre-commit >=3.5.0", + "pytest-cookies >=0.7.0", + "pytest >=8.2.0", + "tox >=4.18.1", + "twine >=5.1.1", + "watchdog >=4.0.0", + ], + "docs": [ + "alabaster >=0.7.13", + "sphinx >=7.0.0", + ], }, ) From 9f0842426c4454fe0f7558379dd781a2effb6c53 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:16:02 -0400 Subject: [PATCH 3/4] revert strict pip check --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 17f6a0fbc..f031c0a31 100644 --- a/tox.ini +++ b/tox.ini @@ -21,6 +21,6 @@ extras = dev download = True commands_pre = pip list - pip check + - pip check commands = pytest {posargs} From 51817e2b426d92c51eb70b27147a75703a6c0c35 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:39:05 -0400 Subject: [PATCH 4/4] autoupdate blackdoc --- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 0c727e6be..58bc138df 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -62,7 +62,8 @@ repos: rev: v0.3.9 hooks: - id: blackdoc - additional_dependencies: [ 'black==24.4.2' ] + additional_dependencies: [ 'black==24.8.0' ] + - id: blackdoc-autoupdate-black {%- endif %} - repo: https://github.com/adrienverge/yamllint.git rev: v1.35.1