Skip to content

Commit a2f92fd

Browse files
woodruffwfrostming
andauthored
workflows: add a release workflow (#308)
* workflows: add a release workflow * Update .github/workflows/release.yml Co-authored-by: Frost Ming <[email protected]> * 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 <[email protected]>
1 parent 6ba7229 commit a2f92fd

11 files changed

+213
-93
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
22
current_version = 0.13.0
3-
files = setup.py cachecontrol/__init__.py docs/conf.py
3+
files = cachecontrol/__init__.py docs/conf.py
44
commit = True
55
tag = True

.github/workflows/release.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
on:
2+
release:
3+
types:
4+
- published
5+
6+
name: release
7+
8+
jobs:
9+
pypi:
10+
name: upload release to PyPI
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
# Used to authenticate to PyPI via OIDC.
15+
# Used to sign the release's artifacts with sigstore-python.
16+
id-token: write
17+
18+
# Used to attach signing artifacts to the published release.
19+
contents: write
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- uses: actions/setup-python@v4
25+
with:
26+
python-version: ">= 3.6"
27+
28+
- name: deps
29+
run: python -m pip install -U build
30+
31+
- name: build
32+
run: python -m build
33+
34+
- name: publish
35+
uses: pypa/gh-action-pypi-publish@release/v1
36+
37+
- name: sign
38+
uses: sigstore/[email protected]
39+
with:
40+
inputs: ./dist/*.tar.gz ./dist/*.whl
41+
release-signing-artifacts: true

CONTRIBUTING.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Contributing to CacheControl
2+
3+
Thank you for your interest in contributing to `CacheControl`!
4+
5+
The information below will help you set up a local development environment
6+
and perform common development tasks.
7+
8+
## Requirements
9+
10+
`CacheControl`'s only external development requirement is Python 3.7 or newer.
11+
12+
## Development steps
13+
14+
First, clone this repository:
15+
16+
```bash
17+
git clone https://github.com/psf/cachecontrol
18+
cd cachecontrol
19+
```
20+
21+
Then, bootstrap your local development environment:
22+
23+
```bash
24+
make bootstrap
25+
# OPTIONAL: enter the new environment, if you'd like to run things directly
26+
source .venv/bin/activate
27+
```
28+
29+
Once you've run `make bootstrap`, you can run the other `make` targets
30+
to perform particular tasks.
31+
32+
Any changes you make to the `cachecontrol` source tree will take effect
33+
immediately in the development environment.
34+
35+
### Linting
36+
37+
You can run the current formatters with:
38+
39+
```bash
40+
make format
41+
```
42+
43+
### Testing
44+
45+
You can run the unit tests locally with:
46+
47+
```bash
48+
# run the test suite in the current environment
49+
make test
50+
51+
# OPTIONAL: use `tox` to fan out across multiple interpreters
52+
make test-all
53+
```
54+
55+
### Documentation
56+
57+
You can build the Sphinx-based documentation with:
58+
59+
```bash
60+
# puts the generated HTML in docs/_build/html/
61+
make doc
62+
```
63+
64+
### Releasing
65+
66+
**NOTE**: If you're a non-maintaining contributor, you don't need the steps
67+
here! They're documented for completeness and for onboarding future maintainers.
68+
69+
Releases of `CacheControl` are managed by GitHub Actions.
70+
71+
To perform a release:
72+
73+
1. Update `CacheControl`'s `__version__` attribute. It can be found under
74+
`cachecontrol/__init__.py`.
75+
76+
1. Create a new tag corresponding to your new version, with a `v` prefix. For example:
77+
78+
```bash
79+
# IMPORTANT: don't forget the `v` prefix!
80+
git tag v1.2.3
81+
```
82+
83+
1. Push your changes to `master` and to the new remote tag.
84+
85+
1. Create, save, and publish a GitHub release for your new tag, including any
86+
`CHANGELOG` entries.

MANIFEST.in

-1
This file was deleted.

Makefile

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ VENV_CMD=python3 -m venv
77
ACTIVATE = $(VENV)/bin/activate
88
CHEESE=https://pypi.python.org/pypi
99
BUMPTYPE=patch
10+
BUMPPRE=0
1011

1112

1213
$(VENV)/bin/pip3:
1314
$(VENV_CMD) $(VENV)
1415

1516
bootstrap: $(VENV)/bin/pip3
16-
$(VENV)/bin/pip3 install -r dev_requirements.txt
17+
$(VENV)/bin/pip3 install -e .[dev]
1718

1819
format:
1920
$(VENV)/bin/black .
@@ -49,13 +50,6 @@ test:
4950
coverage:
5051
$(VENV)/bin/py.test --cov cachecontrol
5152

52-
release: dist
53-
$(VENV)/bin/twine upload dist/*
54-
5553
dist: clean
56-
$(VENV)/bin/python setup.py sdist bdist_wheel
54+
$(VENV)/bin/python -m build
5755
ls -l dist
58-
59-
bump:
60-
$(VENV)/bin/bumpversion $(BUMPTYPE)
61-
git push && git push --tags

dev_requirements.txt

-18
This file was deleted.

docs/conf.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# serve to show the default.
1717

1818

19+
from cachecontrol import __version__
20+
1921
# If extensions (or modules to document with autodoc) are in another directory,
2022
# add these directories to sys.path here. If the directory is relative to the
2123
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -51,9 +53,9 @@
5153
# built documents.
5254
#
5355
# The short X.Y version.
54-
version = "0.13.0"
56+
version = __version__
5557
# The full version, including alpha/beta/rc tags.
56-
release = "0.13.0"
58+
release = __version__
5759

5860
# The language for content autogenerated by Sphinx. Refer to documentation
5961
# for a list of supported languages.

pyproject.toml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[build-system]
2+
requires = ["flit_core >=3.2,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[tool.flit.module]
6+
name = "cachecontrol"
7+
8+
[tool.flit.sdist]
9+
include = ["tests/"]
10+
11+
[project]
12+
name = "CacheControl"
13+
dynamic = ["version"]
14+
description = "httplib2 caching for requests"
15+
readme = "README.rst"
16+
license = { file = "LICENSE.txt" }
17+
authors = [
18+
{ name = "Eric Larson", email = "[email protected]" },
19+
{ name = "Frost Ming", email = "[email protected]" },
20+
{ name = "William Woodruff", email = "[email protected]" },
21+
]
22+
classifiers = [
23+
"Development Status :: 4 - Beta",
24+
"Environment :: Web Environment",
25+
"License :: OSI Approved :: Apache Software License",
26+
"Operating System :: OS Independent",
27+
"Programming Language :: Python :: 3.6",
28+
"Programming Language :: Python :: 3.7",
29+
"Programming Language :: Python :: 3.8",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Topic :: Internet :: WWW/HTTP",
34+
]
35+
keywords = ["requests", "http", "caching", "web"]
36+
dependencies = ["requests >= 2.16.0", "msgpack >= 0.5.2"]
37+
requires-python = ">=3.7"
38+
39+
[project.urls]
40+
Homepage = "https://pypi.org/project/CacheControl/"
41+
Issues = "https://github.com/psf/cachecontrol/issues"
42+
Source = "https://github.com/psf/cachecontrol"
43+
44+
[project.optional-dependencies]
45+
# End-user extras.
46+
filecache = ["filelock >= 3.8.0"]
47+
redis = ["redis>=2.10.5"]
48+
49+
# Development extras.
50+
dev = [
51+
"CacheControl[filecache,redis]",
52+
"build",
53+
"mypy",
54+
"tox",
55+
"pytest-cov",
56+
"pytest",
57+
"cherrypy",
58+
"sphinx",
59+
"black",
60+
"types-redis",
61+
"types-requests",
62+
]
63+
64+
[project.scripts]
65+
doesitcache = "cachecontrol._cmd:main"
66+
67+
[tool.mypy]
68+
show_error_codes = true
69+
strict = true
70+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
71+
72+
[[tool.mypy.overrides]]
73+
module = "msgpack"
74+
ignore_missing_imports = true
75+
76+
[tool.pytest.ini_options]
77+
norecursedirs = ["bin", "lib", "include", "build"]

setup.cfg

-18
This file was deleted.

setup.py

-44
This file was deleted.

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
; SPDX-License-Identifier: Apache-2.0
44

55
[tox]
6+
isolated_build = True
67
envlist = py{36,37,38,39,310,311}, mypy
78

89
[gh-actions]

0 commit comments

Comments
 (0)