Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try replacing setup.* with pyproject.toml #144

Merged
merged 21 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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$

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mr0grog FYI it was later determined that having ref-names is problematic, and it's no longer recommended to include it into this template: https://setuptools-scm.rtfd.io/en/latest/usage/#git-archives / pypa/setuptools-scm#1033.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that is interesting, thanks very much. I’ll pull it out of the main development branch. 🙇

That said, please post things like this as a new issue (or an existing open issue if applicable) rather than re-opening discussion on a completed PR in the future. It makes it a little easier to track things that need to get done (and attribution for release notes). 🙂

Copy link

@webknjaz webknjaz Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was more of a drive-by discovery, a thing that I noticed in passing so I put a comment where some context exists. I'm not a user of this project, but when I notice something in places I visit while doing git paleontology, and don't have time to spend on writing a long explanation, this seems like an acceptable middle ground :)

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