Skip to content

Commit 59bf94f

Browse files
ngoldbaumCarreaufantix
authored
Modernize packaging and fix CI (#130)
* Drop Python 3.8 * Bump llhttp to 9.3.0 --------- Co-authored-by: M Bussonnier <bussonniermatthias@gmail.com> Co-authored-by: Fantix King <fantix.king@gmail.com>
1 parent 922f366 commit 59bf94f

File tree

7 files changed

+60
-76
lines changed

7 files changed

+60
-76
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@ jobs:
5252
fetch-depth: 50
5353
submodules: true
5454

55-
- name: Set up Python
56-
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
55+
- name: Install the latest version of uv
56+
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c # 7.0.0
5757

5858
- name: Build source distribution
5959
run: |
60-
python -m pip install -U setuptools wheel pip
61-
python setup.py sdist
60+
uv build --sdist
6261
6362
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
6463
with:
@@ -73,12 +72,12 @@ jobs:
7372
os: [ubuntu-latest, macos-latest, windows-latest]
7473
cibw_arch: ["auto64", "aarch64", "universal2"]
7574
cibw_python:
76-
- "cp38"
7775
- "cp39"
7876
- "cp310"
7977
- "cp311"
8078
- "cp312"
8179
- "cp313"
80+
- "cp314"
8281
exclude:
8382
- os: ubuntu-latest
8483
cibw_arch: universal2
@@ -108,7 +107,7 @@ jobs:
108107
with:
109108
platforms: arm64
110109

111-
- uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3
110+
- uses: pypa/cibuildwheel@7c619efba910c04005a835b110b057fc28fd6e93 # v3.2.0
112111
env:
113112
CIBW_BUILD_VERBOSITY: 1
114113
CIBW_BUILD: ${{ matrix.cibw_python }}-*

.github/workflows/tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1818
os: [windows-latest, ubuntu-latest, macos-latest]
1919

2020
env:
@@ -46,5 +46,6 @@ jobs:
4646
if: steps.release.outputs.version == 0
4747
run: |
4848
python -m pip install -U pip setuptools wheel
49-
python -m pip install -e .[test]
50-
python -m unittest -v tests.suite
49+
python -m pip install .[test]
50+
cd tests
51+
python -m unittest -v

Makefile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33

44
PYTHON ?= python3
55
ROOT = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
6-
6+
UV := $(shell command -v uv 2> /dev/null)
7+
ifdef UV
8+
PYTHON := uv run
9+
PIP := uv pip
10+
else
11+
PIP := pip
12+
endif
713

814
compile:
9-
python3 setup.py build_ext --inplace
10-
11-
12-
release: compile test
13-
python3 setup.py sdist upload
14-
15+
$(PIP) install -e .
1516

1617
test: compile
17-
python3 -m unittest -v
18+
$(PYTHON) -m unittest -v
1819

1920
clean:
2021
find $(ROOT)/httptools/parser -name '*.c' | xargs rm -f
22+
find $(ROOT)/httptools/parser -name '*.so' | xargs rm -f
2123
find $(ROOT)/httptools/parser -name '*.html' | xargs rm -f
24+
rm -rf build
2225

2326
distclean: clean
2427
git --git-dir="$(ROOT)/vendor/http-parser/.git" clean -dfx
2528
git --git-dir="$(ROOT)/vendor/llhttp/.git" clean -dfx
26-
27-
28-
testinstalled:
29-
cd /tmp && $(PYTHON) $(ROOT)/tests/__init__.py

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ def parse_url(url: bytes):
9999

100100
3. Activate the environment with `source envname/bin/activate`
101101

102-
4. Install development requirements with `pip install -e .[test]`
103-
104-
5. Run `make` and `make test`.
102+
4. Run `make` and `make test`.
105103

106104

107105
# License

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = ["setuptools==80.9.0"]
4+
5+
[project]
6+
name = "httptools"
7+
dynamic = ["version"]
8+
classifiers = [
9+
"Intended Audience :: Developers",
10+
"Programming Language :: Python :: 3",
11+
"Operating System :: POSIX",
12+
"Operating System :: MacOS :: MacOS X",
13+
"Environment :: Web Environment",
14+
"Development Status :: 5 - Production/Stable",
15+
]
16+
requires-python = ">=3.9"
17+
authors = [
18+
{name = "Yury Selivanov", email="yury@magic.io"},
19+
]
20+
license = "MIT"
21+
license-files = ["LICENSE"]
22+
description = "A collection of framework independent HTTP protocol utils."
23+
readme = "README.md"
24+
25+
[project.urls]
26+
Homepage = "https://github.com/MagicStack/httptools"
27+
28+
[project.optional-dependencies]
29+
test = [] # for backward compatibility

setup.py

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import sys
22

3-
vi = sys.version_info
4-
if vi < (3, 8):
5-
raise RuntimeError('httptools require Python 3.8 or greater')
6-
else:
7-
import os.path
8-
import pathlib
3+
import os.path
4+
import pathlib
95

10-
from setuptools import setup, Extension
11-
from setuptools.command.build_ext import build_ext as build_ext
6+
from setuptools import setup, Extension
7+
from setuptools.command.build_ext import build_ext as build_ext
128

139

1410
CFLAGS = ['-O2']
1511

1612
ROOT = pathlib.Path(__file__).parent
1713

18-
CYTHON_DEPENDENCY = 'Cython>=0.29.24'
14+
CYTHON_DEPENDENCY = 'Cython>=3.1.0'
1915

2016

2117
class httptools_build_ext(build_ext):
@@ -52,6 +48,8 @@ def initialize_options(self):
5248
self.cython_always = False
5349
self.cython_annotate = None
5450
self.cython_directives = None
51+
if 'editable_wheel' in sys.argv:
52+
self.inplace = True
5553

5654
def finalize_options(self):
5755
# finalize_options() may be called multiple times on the
@@ -82,12 +80,9 @@ def finalize_options(self):
8280
try:
8381
import Cython
8482
except ImportError:
85-
raise RuntimeError(
86-
'please install Cython to compile httptools from source')
83+
import setuptools.build_meta
8784

88-
if Cython.__version__ < '0.29':
89-
raise RuntimeError(
90-
'httptools requires Cython version 0.29 or greater')
85+
raise setuptools.build_meta.SetupRequirementsError([CYTHON_DEPENDENCY])
9186

9287
from Cython.Build import cythonize
9388

@@ -145,10 +140,6 @@ def build_extensions(self):
145140
super().build_extensions()
146141

147142

148-
with open(str(ROOT / 'README.md')) as f:
149-
long_description = f.read()
150-
151-
152143
with open(str(ROOT / 'httptools' / '_version.py')) as f:
153144
for line in f:
154145
if line.startswith('__version__ ='):
@@ -160,36 +151,10 @@ def build_extensions(self):
160151
'unable to read the version from httptools/_version.py')
161152

162153

163-
setup_requires = []
164-
165-
if (not (ROOT / 'httptools' / 'parser' / 'parser.c').exists() or
166-
'--cython-always' in sys.argv):
167-
# No Cython output, require Cython to build.
168-
setup_requires.append(CYTHON_DEPENDENCY)
169-
170-
171154
setup(
172-
name='httptools',
173155
version=VERSION,
174-
description='A collection of framework independent HTTP protocol utils.',
175-
long_description=long_description,
176-
long_description_content_type='text/markdown',
177-
url='https://github.com/MagicStack/httptools',
178-
classifiers=[
179-
'License :: OSI Approved :: MIT License',
180-
'Intended Audience :: Developers',
181-
'Programming Language :: Python :: 3',
182-
'Operating System :: POSIX',
183-
'Operating System :: MacOS :: MacOS X',
184-
'Environment :: Web Environment',
185-
'Development Status :: 5 - Production/Stable',
186-
],
187156
platforms=['macOS', 'POSIX', 'Windows'],
188-
python_requires='>=3.8.0',
189157
zip_safe=False,
190-
author='Yury Selivanov',
191-
author_email='yury@magic.io',
192-
license='MIT',
193158
packages=['httptools', 'httptools.parser'],
194159
cmdclass={
195160
'build_ext': httptools_build_ext,
@@ -212,11 +177,4 @@ def build_extensions(self):
212177
],
213178
include_package_data=True,
214179
exclude_package_data={"": ["*.c", "*.h"]},
215-
test_suite='tests.suite',
216-
setup_requires=setup_requires,
217-
extras_require={
218-
'test': [
219-
CYTHON_DEPENDENCY
220-
]
221-
}
222180
)

0 commit comments

Comments
 (0)