Skip to content

Commit

Permalink
Try replacing setup.* with pyproject.toml (#144)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Mr0grog and danielballan authored Dec 16, 2023
1 parent 2220fc2 commit 790ad74
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 3,129 deletions.
16 changes: 5 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ commands:
steps:
- restore_cache:
keys:
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-docs.txt" }}
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-
- cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-
- cache_v10-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "pyproject.toml" }}
- cache_v10-wayback-<< parameters.python-version >>-{{ arch }}-

- run:
name: Install Dependencies
Expand Down Expand Up @@ -56,7 +54,7 @@ commands:
pip install .[docs]
- save_cache:
key: cache_v9-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-docs.txt" }}
key: cache_v10-wayback-<< parameters.python-version >>-{{ arch }}-{{ checksum "pyproject.toml" }}
paths:
- ~/venv

Expand Down Expand Up @@ -116,7 +114,7 @@ jobs:
name: Build Distribution
command: |
. ~/venv/bin/activate
python setup.py sdist bdist_wheel
python -m build .
- run:
name: Check Distribution
command: |
Expand Down Expand Up @@ -150,12 +148,8 @@ workflows:
- test:
matrix:
parameters:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
urllib3-version: ["1.20", "2.0"]
exclude:
# urllib3v2 is not compatible with Python < 3.7.
- python-version: "3.6"
urllib3-version: "2.0"
- lint
- build
- docs
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
wayback/_version.py export-subst
.git_archival.txt export-subst
*.py diff=python
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ target/

#Ipython Notebook
.ipynb_checkpoints

# generated by hatch-vcs
wayback/_version.py
18 changes: 8 additions & 10 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ Ready to contribute? Here's how to set up `wayback` for local development.

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

$ mkvirtualenv wayback
$ cd wayback/
$ python setup.py develop
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install -e '.[dev,docs]'

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.

4. Create a branch for local development::

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

Now you can make your changes locally.

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

$ flake8 wayback tests
$ pytest
$ tox

To get flake8, pytest and tox, just pip install them into your virtualenv using `pip install -r requirements-dev.txt`.
$ pytest -v .

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

Expand All @@ -101,7 +101,5 @@ Before you submit a pull request, check that it meets these guidelines:
2. 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.
3. The pull request should work for Python 2.7, 3.3, 3.4, 3.5 and for PyPy. Check
https://travis-ci.org/edgi-govdata-archiving/wayback/pull_requests
and make sure that the tests pass for all supported Python versions.
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.

15 changes: 0 additions & 15 deletions MANIFEST.in

This file was deleted.

2 changes: 2 additions & 0 deletions docs/source/release-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ In Development
Breaking Changes
^^^^^^^^^^^^^^^^

- 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.

- 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).

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.
Expand Down
82 changes: 82 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[project]
name = "wayback"
# version = "0.0.1"
dynamic=["version"]
description = "Python API to Internet Archive Wayback Machine"
readme = "README.rst"
maintainers = [
{ name = "Rob Brackett", email = "[email protected]" },
{ name="Environmental Data Governance Initiative", email="[email protected]" },
]
# TODO: put contributors in `authors` field?
# authors = [ { name="XYZ" }, ... ]
license = {text = "BSD (3-clause)"}
requires-python = ">=3.8"
classifiers = [
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
# It would be nice to have a license classifier here, but there isn't one:
# https://github.com/pypa/trove-classifiers/issues/70
]
dependencies = [
"requests",
"urllib3>=1.20",
]

[project.optional-dependencies]
# For developing the package (running tests, packaging, etc.) but not needed
# for _using_ it. Some tooling requires newer Python versions than the package
# itself (>=3.8). This depends on the `test` extra, which _does_ work on the
# same Python versions as the main package source.
dev = [
"build ~=1.0.3",
"check-wheel-contents ~=0.6.0",
"flake8 ~=6.1.0",
"twine ~=4.0.2",
"wayback[test]"
]
# For building documentation. These are separated from dev because there are a
# a variety of compatibility issues with our other dev dependencies on Python
# versions < 3.10 (which we support), so you have to install them in a separate
# environment from the other dev dependencies.
docs = [
"sphinx ~=7.2.6",
"ipython ~=8.16.1",
"numpydoc ~=1.6.0",
"sphinx-copybutton ~=0.5.2",
"sphinx_rtd_theme ~=1.3.0",
]
# For running tests.
test = [
"codecov",
"coverage",
"requests-mock",
"pytest",
"vcrpy",
]

[project.urls]
"Homepage" = "https://github.com/edgi-govdata-archiving/wayback"
"Documentation" = "https://wayback.readthedocs.io/en/stable/"
"Changelog" = "https://wayback.readthedocs.io/en/stable/release-history.html"
"Source code" = "https://github.com/edgi-govdata-archiving/wayback"
"Issues" = "https://github.com/edgi-govdata-archiving/wayback/issues"

[build-system]
requires = ["hatchling ~=1.19", "hatch-vcs ~=0.4"]
build-backend = "hatchling.build"

[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "wayback/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [".git_archival.txt"]

[tool.hatch.build.targets.wheel]
packages = ["wayback"]
exclude = ["wayback/tests/*"]

[tool.check-wheel-contents]
toplevel = "wayback"
8 changes: 0 additions & 8 deletions requirements-dev.txt

This file was deleted.

9 changes: 0 additions & 9 deletions requirements-docs.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements-test.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

9 changes: 0 additions & 9 deletions setup.cfg

This file was deleted.

91 changes: 0 additions & 91 deletions setup.py

This file was deleted.

Loading

0 comments on commit 790ad74

Please sign in to comment.