Skip to content

Commit a39cd67

Browse files
authored
Modernize to use pyproject.toml and drop versioneer (#607)
* Modernize to use pyproject.toml and drop versioneer - support Python 3.14 and drop Python 3.8 - some additional cleanup and modernization * Add basic pre-commit hooks; use pycodestyle, not pep8 * Always include building wheels in CI for PRs * Test the version (for coverage!) * Add `"PyToolz Contributors"` as authors in pyproject.toml * Try to get trusted publishing to work * Make publishing a trigger-able workflow
1 parent 688a812 commit a39cd67

32 files changed

+336
-2490
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Alternatively, consider using https://pre-commit.ci/
2+
name: pre-commit checks
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches: [master]
8+
9+
jobs:
10+
pre-commit:
11+
name: pre-commit-hooks
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
fetch-depth: 0
17+
persist-credentials: false
18+
- uses: actions/setup-python@v6
19+
with:
20+
python-version: "3.13"
21+
- uses: pre-commit/[email protected]

.github/workflows/publish_pypi.yml

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,98 @@
11
name: Publish to PyPI
22

33
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
upload_dest:
8+
type: choice
9+
description: Upload wheels to
10+
options:
11+
- No Upload
12+
- PyPI
13+
- Test PyPI
414
push:
15+
branches:
16+
- master
517
tags:
618
- '[0-9]+.[0-9]+.[0-9]+*'
719

20+
permissions: {}
21+
822
jobs:
9-
build_and_deploy:
23+
build-artifacts:
1024
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
1127
defaults:
1228
run:
1329
shell: bash -l {0}
1430
steps:
1531
- name: Checkout
16-
uses: actions/checkout@v4
32+
uses: actions/checkout@v5
1733
with:
1834
fetch-depth: 0
35+
persist-credentials: false
1936
- name: Set up Python
20-
uses: actions/setup-python@v5
37+
uses: actions/setup-python@v6
2138
with:
22-
python-version: "3.8"
39+
python-version: "3.9"
2340
- name: Install build dependencies
24-
run: python -m pip install setuptools wheel
25-
- name: Build wheel
26-
run: python setup.py sdist bdist_wheel
41+
run: |
42+
python -m pip install --upgrade pip
43+
python -m pip install build twine
44+
- name: Build wheel and sdist
45+
run: python -m build
46+
- uses: actions/upload-artifact@v4
47+
with:
48+
name: releases
49+
path: dist
50+
if-no-files-found: error
51+
- name: Check with twine
52+
run: python -m twine check --strict dist/*
53+
54+
upload-to-test-pypi:
55+
needs: build-artifacts
56+
runs-on: ubuntu-latest
57+
if: github.repository == 'pytoolz/toolz' && (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'Test PyPI')
58+
59+
environment:
60+
name: test-pypi
61+
url: https://test.pypi.org/p/toolz
62+
permissions:
63+
contents: read
64+
id-token: write
65+
66+
steps:
67+
- uses: actions/download-artifact@v5
68+
with:
69+
name: releases
70+
path: dist
71+
- name: Publish to Test-PyPI
72+
uses: pypa/[email protected]
73+
with:
74+
print-hash: true
75+
verbose: true
76+
77+
upload-to-pypi:
78+
needs: build-artifacts
79+
runs-on: ubuntu-latest
80+
if: github.repository == 'pytoolz/toolz' && startsWith(github.ref, 'refs/tags/') && (github.event_name != 'workflow_dispatch' || github.event.inputs.upload_dest == 'PyPI')
81+
82+
environment:
83+
name: pypi
84+
url: https://pypi.org/p/toolz
85+
permissions:
86+
contents: read
87+
id-token: write
88+
89+
steps:
90+
- uses: actions/download-artifact@v5
91+
with:
92+
name: releases
93+
path: dist
2794
- name: Publish to PyPI
28-
uses: pypa/gh-action-pypi-publish@v1.8.11
95+
uses: pypa/gh-action-pypi-publish@v1.13.0
2996
with:
30-
user: __token__
31-
password: ${{ secrets.PYPI_TOKEN }}
97+
print-hash: true
98+
verbose: true

.github/workflows/test.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Test
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
77

88
jobs:
@@ -13,34 +13,37 @@ jobs:
1313
matrix:
1414
os: ["ubuntu-latest"]
1515
python-version:
16-
- "3.8"
1716
- "3.9"
1817
- "3.10"
1918
- "3.11"
2019
- "3.12"
2120
- "3.13"
22-
- "3.14-dev"
23-
- "pypy-3.8"
21+
- "3.13t"
22+
- "3.14"
23+
- "3.14t"
2424
- "pypy-3.9"
2525
- "pypy-3.10"
2626
- "pypy-3.11"
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v5
30+
with:
31+
fetch-depth: 0
32+
persist-credentials: false
3033
- name: Set up Python
31-
uses: actions/setup-python@v5
34+
uses: actions/setup-python@v6
3235
with:
3336
python-version: ${{ matrix.python-version }}
3437
- name: Install dependencies
3538
run: |
3639
python -m pip install --upgrade pip setuptools wheel
37-
pip install coverage pep8 pytest
40+
pip install coverage pycodestyle pytest
3841
pip install -e .
39-
- name: PyTest
42+
- name: Pytest
4043
run: |
4144
coverage run -m pytest --doctest-modules toolz/
4245
pytest bench/
43-
pep8 --ignore="E731,W503,E402" --exclude=conf.py,tests,examples,bench -r --show-source .
46+
pycodestyle --ignore="E731,W503,W504,E402" --exclude=conf.py,tests,examples,bench -r --show-source .
4447
- name: Coverage
4548
if: (! contains(matrix.python-version, 'pypy'))
4649
run: |

.pre-commit-config.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
fail_fast: false
2+
default_language_version:
3+
python: python3
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v6.0.0
7+
hooks:
8+
# Sanity checks
9+
- id: check-added-large-files
10+
- id: check-case-conflict
11+
- id: check-illegal-windows-names
12+
- id: check-merge-conflict
13+
# Checks based on file type
14+
- id: check-ast
15+
- id: check-toml
16+
# Detect mistakes
17+
- id: check-vcs-permalinks
18+
- id: debug-statements
19+
- id: destroyed-symlinks
20+
- id: detect-private-key
21+
- id: forbid-submodules
22+
# Automatic fixes
23+
- id: end-of-file-fixer
24+
- id: mixed-line-ending
25+
args: [--fix=lf]
26+
- id: trailing-whitespace
27+
- id: name-tests-test
28+
args: ["--pytest-test-first"]
29+
- repo: https://github.com/abravalheri/validate-pyproject
30+
rev: v0.24.1
31+
hooks:
32+
- id: validate-pyproject
33+
name: Validate pyproject.toml
34+
- repo: https://github.com/asottile/pyupgrade
35+
rev: v3.21.0
36+
hooks:
37+
- id: pyupgrade
38+
args: [--py39-plus]
39+
- repo: https://github.com/codespell-project/codespell
40+
rev: v2.4.1
41+
hooks:
42+
- id: codespell
43+
types_or: [python, markdown, rst, toml, yaml]
44+
additional_dependencies:
45+
- tomli; python_version<'3.11'
46+
files: ^(toolz|tlz|docs)/
47+
- repo: https://github.com/pre-commit/pygrep-hooks
48+
rev: v1.10.0
49+
hooks:
50+
- id: rst-directive-colons
51+
- id: rst-inline-touching-normal
52+
- id: python-check-blanket-noqa
53+
- id: python-check-blanket-type-ignore
54+
- id: python-no-eval
55+
- id: python-no-log-warn
56+
- id: text-unicode-replacement-char
57+
- repo: https://github.com/python-jsonschema/check-jsonschema
58+
rev: 0.34.1
59+
hooks:
60+
- id: check-dependabot
61+
- id: check-github-workflows
62+
- id: check-readthedocs
63+
- repo: meta
64+
hooks:
65+
- id: check-hooks-apply
66+
- id: check-useless-excludes

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ python:
1414
install:
1515
- requirements: doc/requirements.txt
1616
- method: pip
17-
path: .
17+
path: .

MANIFEST.in

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
recursive-include toolz *
2+
recursive-include tlz *
3+
include AUTHORS.md
14
include LICENSE.txt
2-
3-
include toolz/tests/*.py
4-
include versioneer.py
5-
include toolz/_version.py
5+
include MANIFEST.in
6+
include README.rst
7+
include pyproject.toml
8+
global-exclude *.pyc *~ *.bak *.swp *.swo *.pyo *.so

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ This builds a standard wordcount function from pieces within ``toolz``:
7373
Dependencies
7474
------------
7575

76-
``toolz`` supports Python 3.8+ with a common codebase.
76+
``toolz`` supports Python 3.9+ with a common codebase.
7777
It is pure Python and requires no dependencies beyond the standard
7878
library.
7979

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sphinx
2-
furo
2+
furo

doc/source/conf.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
#
31
# Toolz documentation build configuration file, created by
42
# sphinx-quickstart on Sun Sep 22 18:06:00 2013.
53
#
@@ -41,8 +39,8 @@
4139
master_doc = 'index'
4240

4341
# General information about the project.
44-
project = u'Toolz'
45-
copyright = u'2013, Matthew Rocklin, John Jacobsen'
42+
project = 'Toolz'
43+
copyright = '2013, Matthew Rocklin, John Jacobsen'
4644

4745
# The version info for the project you're documenting, acts as replacement for
4846
# |version| and |release|, also used in various other places throughout the
@@ -185,8 +183,8 @@
185183
# Grouping the document tree into LaTeX files. List of tuples
186184
# (source start file, target name, title, author, documentclass [howto/manual]).
187185
latex_documents = [
188-
('index', 'Toolz.tex', u'Toolz Documentation',
189-
u'Matthew Rocklin, John Jacobsen', 'manual'),
186+
('index', 'Toolz.tex', 'Toolz Documentation',
187+
'Matthew Rocklin, John Jacobsen', 'manual'),
190188
]
191189

192190
# The name of an image file (relative to this directory) to place at the top of
@@ -215,8 +213,8 @@
215213
# One entry per manual page. List of tuples
216214
# (source start file, name, description, authors, manual section).
217215
man_pages = [
218-
('index', 'toolz', u'Toolz Documentation',
219-
[u'Matthew Rocklin, John Jacobsen'], 1)
216+
('index', 'toolz', 'Toolz Documentation',
217+
['Matthew Rocklin, John Jacobsen'], 1)
220218
]
221219

222220
# If true, show URL addresses after external links.
@@ -229,8 +227,8 @@
229227
# (source start file, target name, title, author,
230228
# dir menu entry, description, category)
231229
texinfo_documents = [
232-
('index', 'Toolz', u'Toolz Documentation',
233-
u'Matthew Rocklin, John Jacobsen', 'Toolz', 'One line description of project.',
230+
('index', 'Toolz', 'Toolz Documentation',
231+
'Matthew Rocklin, John Jacobsen', 'Toolz', 'One line description of project.',
234232
'Miscellaneous'),
235233
]
236234

@@ -247,10 +245,10 @@
247245
# -- Options for Epub output ---------------------------------------------------
248246

249247
# Bibliographic Dublin Core info.
250-
epub_title = u'Toolz'
251-
epub_author = u'Matthew Rocklin, John Jacobsen'
252-
epub_publisher = u'Matthew Rocklin, John Jacobsen'
253-
epub_copyright = u'2013, Matthew Rocklin, John Jacobsen'
248+
epub_title = 'Toolz'
249+
epub_author = 'Matthew Rocklin, John Jacobsen'
250+
epub_publisher = 'Matthew Rocklin, John Jacobsen'
251+
epub_copyright = '2013, Matthew Rocklin, John Jacobsen'
254252

255253
# The language of the text. It defaults to the language option
256254
# or en if the language is not set.
@@ -273,7 +271,7 @@
273271
# The format is a list of tuples containing the path and title.
274272
#epub_pre_files = []
275273

276-
# HTML files shat should be inserted after the pages created by sphinx.
274+
# HTML files that should be inserted after the pages created by sphinx.
277275
# The format is a list of tuples containing the path and title.
278276
#epub_post_files = []
279277

0 commit comments

Comments
 (0)