Skip to content

Commit 790ad74

Browse files
Try replacing setup.* with pyproject.toml (#144)
Direct usage of `setup.py` (that is, calling `python setup.py some_command` to do builds and such) was deprecated and has not been supported for quite a while! This moves everything to `pyproject.toml` (the new format for declaring package metadata). It *seems* like `pyproject.toml` supports all the nice things now, so we can also drop `setup.cfg`. (This seems like a good time to do this, since there are some other semi-breaking changes on tap, like [rethinking how rate limit errors are handled](#137 (comment)).) --------- Co-authored-by: Dan Allan <[email protected]>
1 parent 2220fc2 commit 790ad74

17 files changed

+106
-3129
lines changed

.circleci/config.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ commands:
2020
steps:
2121
- restore_cache:
2222
keys:
23-
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-docs.txt" }}
24-
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
25-
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-
26-
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-
23+
- cache_v10-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "pyproject.toml" }}
24+
- cache_v10-wayback-<< parameters.python-version >>-{{ arch }}-
2725

2826
- run:
2927
name: Install Dependencies
@@ -56,7 +54,7 @@ commands:
5654
pip install .[docs]
5755
5856
- save_cache:
59-
key: cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-docs.txt" }}
57+
key: cache_v10-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "pyproject.toml" }}
6058
paths:
6159
- ~/venv
6260

@@ -116,7 +114,7 @@ jobs:
116114
name: Build Distribution
117115
command: |
118116
. ~/venv/bin/activate
119-
python setup.py sdist bdist_wheel
117+
python -m build .
120118
- run:
121119
name: Check Distribution
122120
command: |
@@ -150,12 +148,8 @@ workflows:
150148
- test:
151149
matrix:
152150
parameters:
153-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
151+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
154152
urllib3-version: ["1.20", "2.0"]
155-
exclude:
156-
# urllib3v2 is not compatible with Python < 3.7.
157-
- python-version: "3.6"
158-
urllib3-version: "2.0"
159153
- lint
160154
- build
161155
- docs

.git_archival.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
4+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
wayback/_version.py export-subst
1+
.git_archival.txt export-subst
22
*.py diff=python

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,6 @@ target/
8181

8282
#Ipython Notebook
8383
.ipynb_checkpoints
84+
85+
# generated by hatch-vcs
86+
wayback/_version.py

CONTRIBUTING.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ Ready to contribute? Here's how to set up `wayback` for local development.
6666

6767
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
6868

69-
$ mkvirtualenv wayback
7069
$ cd wayback/
71-
$ python setup.py develop
70+
$ python -m venv .venv
71+
$ source .venv/bin/activate
72+
$ pip install -e '.[dev,docs]'
73+
74+
The last step may fail if you are on Python versions earlier than 3.10 (the dev and docs tools are not compatible with each other in older Pythons). In that case, you'll need to have separate virtualenvs for working on the docs vs. working on the code.
7275

7376
4. Create a branch for local development::
7477

7578
$ git checkout -b name-of-your-bugfix-or-feature
7679

7780
Now you can make your changes locally.
7881

79-
5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::
82+
5. When you're done making changes, check that your changes pass flake8 and the tests::
8083

8184
$ flake8 wayback tests
82-
$ pytest
83-
$ tox
84-
85-
To get flake8, pytest and tox, just pip install them into your virtualenv using `pip install -r requirements-dev.txt`.
85+
$ pytest -v .
8686

8787
6. Commit your changes and push your branch to GitHub::
8888

@@ -101,7 +101,5 @@ Before you submit a pull request, check that it meets these guidelines:
101101
2. If the pull request adds functionality, the docs should be updated. Put
102102
your new functionality into a function with a docstring, and add the
103103
feature to the list in README.rst.
104-
3. The pull request should work for Python 2.7, 3.3, 3.4, 3.5 and for PyPy. Check
105-
https://travis-ci.org/edgi-govdata-archiving/wayback/pull_requests
106-
and make sure that the tests pass for all supported Python versions.
104+
3. The pull request should work for Python 3.8 and for PyPy. After you submit your pull request, CircleCI will automatically run tests against all supported Python runtimes, so in most cases, you won't need to exhaustively test each of these yourself.
107105

MANIFEST.in

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/source/release-history.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ In Development
88
Breaking Changes
99
^^^^^^^^^^^^^^^^
1010

11+
- Wayback now requires Python 3.8 or newer. Going forward, we intend to drop support for older Python releases once they hit end-of-life (i.e. they no longer receive any security updates or support from the Core Python team). These updates will always be noted as breaking changes.
12+
1113
- Wayback will no longer automatically pause and retry when the server returns rate-limit errors. Instead, it will raise a :class:`wayback.exceptions.WaybackRetryError` exception (which includes information how long you should probably pause for in the ``time`` attribute).
1214

1315
The previous behavior helped solve some issues with the way rate limits were implemented on the client side that have since been fixed. It was also designed around users who had custom limits on Internet Archive servers, which is an unusual situation. The new approach is safer and can help prevent your IP address from getting blocked. If you need to retry after rate limit errors, make sure your code handles the exception and pauses all requests on all client instances for an appropriate amount of time.

pyproject.toml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[project]
2+
name = "wayback"
3+
# version = "0.0.1"
4+
dynamic=["version"]
5+
description = "Python API to Internet Archive Wayback Machine"
6+
readme = "README.rst"
7+
maintainers = [
8+
{ name = "Rob Brackett", email = "[email protected]" },
9+
{ name="Environmental Data Governance Initiative", email="[email protected]" },
10+
]
11+
# TODO: put contributors in `authors` field?
12+
# authors = [ { name="XYZ" }, ... ]
13+
license = {text = "BSD (3-clause)"}
14+
requires-python = ">=3.8"
15+
classifiers = [
16+
"Development Status :: 3 - Alpha",
17+
"Programming Language :: Python :: 3",
18+
"Operating System :: OS Independent",
19+
# It would be nice to have a license classifier here, but there isn't one:
20+
# https://github.com/pypa/trove-classifiers/issues/70
21+
]
22+
dependencies = [
23+
"requests",
24+
"urllib3>=1.20",
25+
]
26+
27+
[project.optional-dependencies]
28+
# For developing the package (running tests, packaging, etc.) but not needed
29+
# for _using_ it. Some tooling requires newer Python versions than the package
30+
# itself (>=3.8). This depends on the `test` extra, which _does_ work on the
31+
# same Python versions as the main package source.
32+
dev = [
33+
"build ~=1.0.3",
34+
"check-wheel-contents ~=0.6.0",
35+
"flake8 ~=6.1.0",
36+
"twine ~=4.0.2",
37+
"wayback[test]"
38+
]
39+
# For building documentation. These are separated from dev because there are a
40+
# a variety of compatibility issues with our other dev dependencies on Python
41+
# versions < 3.10 (which we support), so you have to install them in a separate
42+
# environment from the other dev dependencies.
43+
docs = [
44+
"sphinx ~=7.2.6",
45+
"ipython ~=8.16.1",
46+
"numpydoc ~=1.6.0",
47+
"sphinx-copybutton ~=0.5.2",
48+
"sphinx_rtd_theme ~=1.3.0",
49+
]
50+
# For running tests.
51+
test = [
52+
"codecov",
53+
"coverage",
54+
"requests-mock",
55+
"pytest",
56+
"vcrpy",
57+
]
58+
59+
[project.urls]
60+
"Homepage" = "https://github.com/edgi-govdata-archiving/wayback"
61+
"Documentation" = "https://wayback.readthedocs.io/en/stable/"
62+
"Changelog" = "https://wayback.readthedocs.io/en/stable/release-history.html"
63+
"Source code" = "https://github.com/edgi-govdata-archiving/wayback"
64+
"Issues" = "https://github.com/edgi-govdata-archiving/wayback/issues"
65+
66+
[build-system]
67+
requires = ["hatchling ~=1.19", "hatch-vcs ~=0.4"]
68+
build-backend = "hatchling.build"
69+
70+
[tool.hatch]
71+
version.source = "vcs"
72+
build.hooks.vcs.version-file = "wayback/_version.py"
73+
74+
[tool.hatch.build.targets.sdist]
75+
exclude = [".git_archival.txt"]
76+
77+
[tool.hatch.build.targets.wheel]
78+
packages = ["wayback"]
79+
exclude = ["wayback/tests/*"]
80+
81+
[tool.check-wheel-contents]
82+
toplevel = "wayback"

requirements-dev.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

requirements-docs.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

requirements-test.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 9 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)