Skip to content

Commit d15dca4

Browse files
authored
feat: move project metadata to pyproject.toml (#120)
* Move project metadata to pyproject.toml * Drop Python 3.8 + adopt PEP 639 license expression * Optimize build matrix * Partial revert build matrix change * Fix warning during pypi upload * Add authors files
1 parent b55809b commit d15dca4

File tree

8 files changed

+66
-85
lines changed

8 files changed

+66
-85
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
paths:
66
- ".github/workflows/build-and-publish.yml"
7+
- "pyproject.toml"
78
- "setup.*"
89

910
workflow_dispatch:
@@ -15,24 +16,19 @@ on:
1516

1617
jobs:
1718
os-built-distributions:
18-
name: Build on ${{ matrix.os }}
19+
name: Build ${{ matrix.arch }} on ${{ matrix.os }}
1920
runs-on: ${{ matrix.os }}
2021
strategy:
22+
fail-fast: false
2123
matrix:
22-
os: [ubuntu-latest, windows-latest, macos-latest]
24+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-latest]
2325
steps:
2426
- name: Checkout
2527
uses: actions/checkout@v4
2628
with:
2729
ref: ${{ github.event.inputs.branch }}
2830
submodules: true
2931

30-
- name: Set up QEMU
31-
if: runner.os == 'Linux'
32-
uses: docker/setup-qemu-action@v3
33-
with:
34-
platforms: all
35-
3632
- name: Install Python
3733
uses: actions/setup-python@v5
3834
with:
@@ -42,13 +38,11 @@ jobs:
4238
- name: Build wheels
4339
run: python -m cibuildwheel
4440
env:
45-
CIBW_SKIP: "pp*" # skip PyPy releases
46-
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
47-
CIBW_ARCHS_LINUX: "auto aarch64"
41+
CIBW_ARCHS_MACOS: "auto x86_64"
4842
CIBW_ENABLE: cpython-freethreading
4943
- uses: actions/upload-artifact@v4
5044
with:
51-
name: python-package-distributions-${{ matrix.os }}
45+
name: python-package-distributions-${{ matrix.os }}-${{ matrix.arch }}
5246
path: ./wheelhouse/*.whl
5347

5448
source-distribution:
@@ -66,9 +60,8 @@ jobs:
6660
python-version: "3.12"
6761
- name: Build source distribution
6862
run: |
69-
# FIXME: setuptools was removed starting with Python 3.12
70-
pip install --upgrade --force setuptools
71-
python setup.py sdist
63+
pip install build
64+
python -m build --sdist
7265
- name: Store the source distribution
7366
uses: actions/upload-artifact@v4
7467
with:
@@ -96,4 +89,4 @@ jobs:
9689
with:
9790
user: __token__
9891
password: ${{ secrets.PYPI_API_TOKEN }}
99-
skip_existing: true
92+
skip-existing: true

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ubuntu-latest, windows-latest, macos-latest]
13-
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
13+
python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v4

CHANGES.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ CHANGES
66
------------------
77

88
* Updated ``libmarisa-trie`` to the latest version (0.2.7) (#116).
9-
* Dropped Python 3.7 support (#112).
9+
* Dropped Python 3.7, 3.8 support (#112, #120).
1010
* Added Python 3.13 support (#112).
1111
* Rebuild Cython wrapper with Cython 3.1.2 (#119).
12+
* Moved static project metadata to ``pyproject.toml`` (#120).
13+
* Updated metadata license to include the bundled one from marisa-trie as well (#120).
1214

1315
1.2.1 (2024-10-12)
1416
------------------

MANIFEST.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
include README.rst
2-
include CHANGES.rst
3-
include LICENSE
41
include update_cpp.sh
52

63
recursive-include src *.cpp *.pxd *.pyx

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ License
5858
Wrapper code is licensed under MIT License.
5959

6060
Bundled `marisa-trie`_ C++ library is dual-licensed under
61-
LGPL and BSD 2-clause license.
61+
LGPL or BSD 2-clause license.
6262

6363
.. |PyPI Version| image:: https://img.shields.io/pypi/v/marisa-trie.svg
6464
:target: https://pypi.python.org/pypi/marisa-trie/

pyproject.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = ["setuptools>=77.0"]
4+
5+
[project]
6+
name = "marisa-trie"
7+
version = "1.2.1"
8+
license = "MIT AND (BSD-2-Clause OR LGPL-2.1-or-later)"
9+
license-files = [
10+
"AUTHORS.rst",
11+
"LICENSE",
12+
"marisa-trie/AUTHORS",
13+
"marisa-trie/COPYING.md",
14+
]
15+
description = "Static memory-efficient and fast Trie-like structures for Python."
16+
authors = [{ name = "Mikhail Korobov", email = "kmike84@gmail.com" }]
17+
requires-python = ">=3.9"
18+
classifiers = [
19+
"Development Status :: 4 - Beta",
20+
"Intended Audience :: Developers",
21+
"Intended Audience :: Science/Research",
22+
"Programming Language :: Cython",
23+
"Programming Language :: Python",
24+
"Programming Language :: Python :: 3",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: 3.13",
30+
"Programming Language :: Python :: 3.14",
31+
"Programming Language :: Python :: Implementation :: CPython",
32+
"Topic :: Software Development :: Libraries :: Python Modules",
33+
"Topic :: Scientific/Engineering :: Information Analysis",
34+
"Topic :: Text Processing :: Linguistic",
35+
]
36+
dynamic = ["readme"]
37+
38+
[project.optional-dependencies]
39+
# Note: keep requirements here to ease distributions packaging
40+
test = [
41+
"hypothesis",
42+
"pytest",
43+
"readme_renderer",
44+
]
45+
46+
[project.urls]
47+
Source = "https://github.com/pytries/marisa-trie"
48+
49+
[tool.setuptools.dynamic]
50+
readme = { file = ["README.rst", "CHANGES.rst"] }

setup.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
"""Static memory-efficient and fast Trie-like structures for Python."""
2-
31
import glob
42
import itertools
53
import os.path
64

75
from setuptools import setup, Extension
86

97

10-
# Note: keep requirements here to ease distributions packaging
11-
tests_require = [
12-
"hypothesis",
13-
"pytest",
14-
"readme_renderer",
15-
]
16-
install_requires = [
17-
"setuptools",
18-
]
19-
208
MARISA_ROOT_DIR = "marisa-trie"
219
MARISA_SOURCE_DIR = os.path.join(MARISA_ROOT_DIR, "lib")
2210
MARISA_INCLUDE_DIR = os.path.join(MARISA_ROOT_DIR, "include")
@@ -32,45 +20,8 @@
3220
*(glob.glob(os.path.join(MARISA_SOURCE_DIR, path)) for path in MARISA_FILES)
3321
)
3422

35-
DESCRIPTION = __doc__
36-
with open("README.rst", encoding="utf-8") as f1, open(
37-
"CHANGES.rst", encoding="utf-8"
38-
) as f2:
39-
LONG_DESCRIPTION = f1.read() + f2.read()
40-
LICENSE = "MIT"
41-
42-
CLASSIFIERS = [
43-
"Development Status :: 4 - Beta",
44-
"Intended Audience :: Developers",
45-
"Intended Audience :: Science/Research",
46-
"License :: OSI Approved :: MIT License",
47-
"Programming Language :: Cython",
48-
"Programming Language :: Python",
49-
"Programming Language :: Python :: 3",
50-
"Programming Language :: Python :: 3.8",
51-
"Programming Language :: Python :: 3.9",
52-
"Programming Language :: Python :: 3.10",
53-
"Programming Language :: Python :: 3.11",
54-
"Programming Language :: Python :: 3.12",
55-
"Programming Language :: Python :: 3.13",
56-
"Programming Language :: Python :: 3.14",
57-
"Programming Language :: Python :: Implementation :: CPython",
58-
"Topic :: Software Development :: Libraries :: Python Modules",
59-
"Topic :: Scientific/Engineering :: Information Analysis",
60-
"Topic :: Text Processing :: Linguistic",
61-
]
6223

6324
setup(
64-
name="marisa-trie",
65-
version="1.2.1",
66-
description=DESCRIPTION,
67-
long_description=LONG_DESCRIPTION,
68-
long_description_content_type="text/x-rst",
69-
author="Mikhail Korobov",
70-
author_email="kmike84@gmail.com",
71-
license=LICENSE,
72-
url="https://github.com/pytries/marisa-trie",
73-
classifiers=CLASSIFIERS,
7425
libraries=[
7526
(
7627
"libmarisa-trie",
@@ -97,9 +48,4 @@
9748
include_dirs=[MARISA_INCLUDE_DIR],
9849
)
9950
],
100-
python_requires=">=3.8",
101-
install_requires=install_requires,
102-
extras_require={
103-
"test": tests_require,
104-
},
10551
)

tests/test_packaging.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"""
44
import io
55
import re
6-
import subprocess
7-
from email import message_from_string
8-
from pkg_resources import get_distribution
6+
from importlib.metadata import metadata
97

108
from readme_renderer.rst import render
119

@@ -45,12 +43,7 @@ def __str__(self) -> str:
4543

4644

4745
def test_check_pypi_rendering():
48-
subprocess.check_call(["python3", "setup.py", "sdist"])
49-
50-
package = get_distribution("marisa-trie")
51-
pkg_info = message_from_string(package.get_metadata("PKG-INFO"))
52-
metadata = dict(pkg_info.items())
53-
lines = metadata["Summary"].splitlines()
46+
lines = metadata("marisa-trie").get("Summary", "").splitlines()
5447
description = lines.pop(0) + "\n"
5548
description += "\n".join(l[8:] for l in lines)
5649

0 commit comments

Comments
 (0)