From a2f92fdee213729db1dbd35ede7efb1ad8e87617 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Thu, 8 Jun 2023 00:28:21 -0400 Subject: [PATCH] workflows: add a release workflow (#308) * workflows: add a release workflow * Update .github/workflows/release.yml Co-authored-by: Frost Ming * treewide: pyproject-based metadata Removes setup.{cfg,py} in favor of pyproject.toml, and consolidates all settings. * pyproject: fix typo * tox: use isolated builds Required with PEP 517/8 metadata. * pyproject: include `build` in dev-deps * pyproject: include tests in sdist Also, remove MANIFEST.in. * meta: dedupe version, use `bump` * Makefile, pyproject: remove bump * CONTRIBUTING: initial contributing docs --------- Co-authored-by: Frost Ming --- .bumpversion.cfg | 2 +- .github/workflows/release.yml | 41 +++++++++++++++++ CONTRIBUTING.md | 86 +++++++++++++++++++++++++++++++++++ MANIFEST.in | 1 - Makefile | 12 ++--- dev_requirements.txt | 18 -------- docs/conf.py | 6 ++- pyproject.toml | 77 +++++++++++++++++++++++++++++++ setup.cfg | 18 -------- setup.py | 44 ------------------ tox.ini | 1 + 11 files changed, 213 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 CONTRIBUTING.md delete mode 100644 MANIFEST.in delete mode 100644 dev_requirements.txt create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index d5160c9..437b22e 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] current_version = 0.13.0 -files = setup.py cachecontrol/__init__.py docs/conf.py +files = cachecontrol/__init__.py docs/conf.py commit = True tag = True diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..08c05fb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +on: + release: + types: + - published + +name: release + +jobs: + pypi: + name: upload release to PyPI + runs-on: ubuntu-latest + + permissions: + # Used to authenticate to PyPI via OIDC. + # Used to sign the release's artifacts with sigstore-python. + id-token: write + + # Used to attach signing artifacts to the published release. + contents: write + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: ">= 3.6" + + - name: deps + run: python -m pip install -U build + + - name: build + run: python -m build + + - name: publish + uses: pypa/gh-action-pypi-publish@release/v1 + + - name: sign + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: ./dist/*.tar.gz ./dist/*.whl + release-signing-artifacts: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4630561 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,86 @@ +# Contributing to CacheControl + +Thank you for your interest in contributing to `CacheControl`! + +The information below will help you set up a local development environment +and perform common development tasks. + +## Requirements + +`CacheControl`'s only external development requirement is Python 3.7 or newer. + +## Development steps + +First, clone this repository: + +```bash +git clone https://github.com/psf/cachecontrol +cd cachecontrol +``` + +Then, bootstrap your local development environment: + +```bash +make bootstrap +# OPTIONAL: enter the new environment, if you'd like to run things directly +source .venv/bin/activate +``` + +Once you've run `make bootstrap`, you can run the other `make` targets +to perform particular tasks. + +Any changes you make to the `cachecontrol` source tree will take effect +immediately in the development environment. + +### Linting + +You can run the current formatters with: + +```bash +make format +``` + +### Testing + +You can run the unit tests locally with: + +```bash +# run the test suite in the current environment +make test + +# OPTIONAL: use `tox` to fan out across multiple interpreters +make test-all +``` + +### Documentation + +You can build the Sphinx-based documentation with: + +```bash +# puts the generated HTML in docs/_build/html/ +make doc +``` + +### Releasing + +**NOTE**: If you're a non-maintaining contributor, you don't need the steps +here! They're documented for completeness and for onboarding future maintainers. + +Releases of `CacheControl` are managed by GitHub Actions. + +To perform a release: + +1. Update `CacheControl`'s `__version__` attribute. It can be found under + `cachecontrol/__init__.py`. + +1. Create a new tag corresponding to your new version, with a `v` prefix. For example: + + ```bash + # IMPORTANT: don't forget the `v` prefix! + git tag v1.2.3 + ``` + +1. Push your changes to `master` and to the new remote tag. + +1. Create, save, and publish a GitHub release for your new tag, including any + `CHANGELOG` entries. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index a84b34e..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -graft tests/ diff --git a/Makefile b/Makefile index 50e00ce..26b3831 100644 --- a/Makefile +++ b/Makefile @@ -7,13 +7,14 @@ VENV_CMD=python3 -m venv ACTIVATE = $(VENV)/bin/activate CHEESE=https://pypi.python.org/pypi BUMPTYPE=patch +BUMPPRE=0 $(VENV)/bin/pip3: $(VENV_CMD) $(VENV) bootstrap: $(VENV)/bin/pip3 - $(VENV)/bin/pip3 install -r dev_requirements.txt + $(VENV)/bin/pip3 install -e .[dev] format: $(VENV)/bin/black . @@ -49,13 +50,6 @@ test: coverage: $(VENV)/bin/py.test --cov cachecontrol -release: dist - $(VENV)/bin/twine upload dist/* - dist: clean - $(VENV)/bin/python setup.py sdist bdist_wheel + $(VENV)/bin/python -m build ls -l dist - -bump: - $(VENV)/bin/bumpversion $(BUMPTYPE) - git push && git push --tags diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index 5813414..0000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-FileCopyrightText: 2015 Eric Larson -# -# SPDX-License-Identifier: Apache-2.0 - --e .[filecache,redis] - -tox -pytest-cov -pytest -cherrypy -sphinx -bumpversion -twine -black -wheel -mypy -types-redis -types-requests diff --git a/docs/conf.py b/docs/conf.py index 04a12ea..957a728 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,6 +16,8 @@ # serve to show the default. +from cachecontrol import __version__ + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -51,9 +53,9 @@ # built documents. # # The short X.Y version. -version = "0.13.0" +version = __version__ # The full version, including alpha/beta/rc tags. -release = "0.13.0" +release = __version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ef55536 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,77 @@ +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.module] +name = "cachecontrol" + +[tool.flit.sdist] +include = ["tests/"] + +[project] +name = "CacheControl" +dynamic = ["version"] +description = "httplib2 caching for requests" +readme = "README.rst" +license = { file = "LICENSE.txt" } +authors = [ + { name = "Eric Larson", email = "ericlarson@ionrock.com" }, + { name = "Frost Ming", email = "me@frostming.com" }, + { name = "William Woodruff", email = "william@yossarian.net" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Web Environment", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Internet :: WWW/HTTP", +] +keywords = ["requests", "http", "caching", "web"] +dependencies = ["requests >= 2.16.0", "msgpack >= 0.5.2"] +requires-python = ">=3.7" + +[project.urls] +Homepage = "https://pypi.org/project/CacheControl/" +Issues = "https://github.com/psf/cachecontrol/issues" +Source = "https://github.com/psf/cachecontrol" + +[project.optional-dependencies] +# End-user extras. +filecache = ["filelock >= 3.8.0"] +redis = ["redis>=2.10.5"] + +# Development extras. +dev = [ + "CacheControl[filecache,redis]", + "build", + "mypy", + "tox", + "pytest-cov", + "pytest", + "cherrypy", + "sphinx", + "black", + "types-redis", + "types-requests", +] + +[project.scripts] +doesitcache = "cachecontrol._cmd:main" + +[tool.mypy] +show_error_codes = true +strict = true +enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] + +[[tool.mypy.overrides]] +module = "msgpack" +ignore_missing_imports = true + +[tool.pytest.ini_options] +norecursedirs = ["bin", "lib", "include", "build"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7849c48..0000000 --- a/setup.cfg +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-FileCopyrightText: 2015 Eric Larson -# -# SPDX-License-Identifier: Apache-2.0 - -[metadata] -license_files = - LICENSE.txt - -[tool:pytest] -norecursedirs = bin lib include build - -[mypy] -show_error_codes = true -strict = true -enable_error_code = ignore-without-code,redundant-expr,truthy-bool - -[mypy-msgpack] -ignore_missing_imports = true diff --git a/setup.py b/setup.py deleted file mode 100644 index a1b408b..0000000 --- a/setup.py +++ /dev/null @@ -1,44 +0,0 @@ -# SPDX-FileCopyrightText: 2015 Eric Larson -# -# SPDX-License-Identifier: Apache-2.0 - -import setuptools - -long_description = open("README.rst").read() - -VERSION = "0.13.0" - -setup_params = dict( - name="CacheControl", - version=VERSION, - author="Eric Larson", - author_email="eric@ionrock.org", - url="https://github.com/ionrock/cachecontrol", - keywords="requests http caching web", - packages=setuptools.find_packages(exclude=["tests", "tests.*"]), - package_data={"": ["LICENSE.txt"], "cachecontrol": ["py.typed"]}, - package_dir={"cachecontrol": "cachecontrol"}, - include_package_data=True, - description="httplib2 caching for requests", - long_description=long_description, - install_requires=["requests>=2.16.0", "msgpack>=0.5.2"], - extras_require={"filecache": ["filelock>=3.8.0"], "redis": ["redis>=2.10.5"]}, - entry_points={"console_scripts": ["doesitcache = cachecontrol._cmd:main"]}, - python_requires=">=3.7", - classifiers=[ - "Development Status :: 4 - Beta", - "Environment :: Web Environment", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Internet :: WWW/HTTP", - ], -) - - -if __name__ == "__main__": - setuptools.setup(**setup_params) diff --git a/tox.ini b/tox.ini index b945e7c..d9ceacf 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ ; SPDX-License-Identifier: Apache-2.0 [tox] +isolated_build = True envlist = py{36,37,38,39,310,311}, mypy [gh-actions]