11import 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
1410CFLAGS = ['-O2' ]
1511
1612ROOT = pathlib .Path (__file__ ).parent
1713
18- CYTHON_DEPENDENCY = 'Cython>=0.29.24 '
14+ CYTHON_DEPENDENCY = 'Cython>=3.1.0 '
1915
2016
2117class 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-
152143with 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-
171154setup (
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