-
Notifications
You must be signed in to change notification settings - Fork 92
Modernize packaging and fix CI #130
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
Open
ngoldbaum
wants to merge
5
commits into
MagicStack:master
Choose a base branch
from
ngoldbaum:static-metadata
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+35
−86
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
27bf5c5
Move static metadata to a pyproject.toml file
ngoldbaum 5a852cd
drop editable install in CI
ngoldbaum 6045853
add cython as a build dependency
ngoldbaum 6fe9f20
add license-files
ngoldbaum 75fa978
drop Python 3.8 from builds
ngoldbaum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[build-system] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["setuptools", "cython"] | ||
|
||
[project] | ||
name = "httptools" | ||
dynamic = ["version", "optional-dependencies"] | ||
classifiers = [ | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python :: 3", | ||
"Operating System :: POSIX", | ||
"Operating System :: MacOS :: MacOS X", | ||
"Environment :: Web Environment", | ||
"Development Status :: 5 - Production/Stable", | ||
] | ||
requires-python = ">=3.8" | ||
authors = [ | ||
{name = "Yury Selivanov", email="[email protected]"}, | ||
] | ||
license = "MIT" | ||
license-files = ["LICENSE"] | ||
description = "A collection of framework independent HTTP protocol utils." | ||
readme = "README.md" | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/MagicStack/httptools" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import sys | ||
|
||
from Cython.Build import cythonize | ||
|
||
vi = sys.version_info | ||
if vi < (3, 8): | ||
raise RuntimeError('httptools require Python 3.8 or greater') | ||
|
@@ -15,26 +17,18 @@ | |
|
||
ROOT = pathlib.Path(__file__).parent | ||
|
||
CYTHON_DEPENDENCY = 'Cython>=0.29.24' | ||
CYTHON_DEPENDENCY = 'Cython>=3.1.0' | ||
|
||
|
||
class httptools_build_ext(build_ext): | ||
user_options = build_ext.user_options + [ | ||
('cython-always', None, | ||
'run cythonize() even if .c files are present'), | ||
('cython-annotate', None, | ||
'Produce a colorized HTML version of the Cython source.'), | ||
('cython-directives=', None, | ||
'Cythion compiler directives'), | ||
('use-system-llhttp', None, | ||
'Use the system provided llhttp, instead of the bundled one'), | ||
('use-system-http-parser', None, | ||
'Use the system provided http-parser, instead of the bundled one'), | ||
] | ||
|
||
boolean_options = build_ext.boolean_options + [ | ||
'cython-always', | ||
'cython-annotate', | ||
'use-system-llhttp', | ||
'use-system-http-parser', | ||
] | ||
|
@@ -49,9 +43,6 @@ def initialize_options(self): | |
super().initialize_options() | ||
self.use_system_llhttp = False | ||
self.use_system_http_parser = False | ||
self.cython_always = False | ||
self.cython_annotate = None | ||
self.cython_directives = None | ||
|
||
def finalize_options(self): | ||
# finalize_options() may be called multiple times on the | ||
|
@@ -60,53 +51,6 @@ def finalize_options(self): | |
if getattr(self, '_initialized', False): | ||
return | ||
|
||
need_cythonize = self.cython_always | ||
cfiles = {} | ||
|
||
for extension in self.distribution.ext_modules: | ||
for i, sfile in enumerate(extension.sources): | ||
if sfile.endswith('.pyx'): | ||
prefix, ext = os.path.splitext(sfile) | ||
cfile = prefix + '.c' | ||
|
||
if os.path.exists(cfile) and not self.cython_always: | ||
extension.sources[i] = cfile | ||
else: | ||
if os.path.exists(cfile): | ||
cfiles[cfile] = os.path.getmtime(cfile) | ||
else: | ||
cfiles[cfile] = 0 | ||
need_cythonize = True | ||
|
||
if need_cythonize: | ||
try: | ||
import Cython | ||
except ImportError: | ||
raise RuntimeError( | ||
'please install Cython to compile httptools from source') | ||
|
||
if Cython.__version__ < '0.29': | ||
raise RuntimeError( | ||
'httptools requires Cython version 0.29 or greater') | ||
|
||
from Cython.Build import cythonize | ||
|
||
directives = {} | ||
if self.cython_directives: | ||
for directive in self.cython_directives.split(','): | ||
k, _, v = directive.partition('=') | ||
if v.lower() == 'false': | ||
v = False | ||
if v.lower() == 'true': | ||
v = True | ||
|
||
directives[k] = v | ||
|
||
self.distribution.ext_modules[:] = cythonize( | ||
self.distribution.ext_modules, | ||
compiler_directives=directives, | ||
annotate=self.cython_annotate) | ||
|
||
super().finalize_options() | ||
|
||
self._initialized = True | ||
|
@@ -145,10 +89,6 @@ def build_extensions(self): | |
super().build_extensions() | ||
|
||
|
||
with open(str(ROOT / 'README.md')) as f: | ||
long_description = f.read() | ||
|
||
|
||
with open(str(ROOT / 'httptools' / '_version.py')) as f: | ||
for line in f: | ||
if line.startswith('__version__ ='): | ||
|
@@ -169,32 +109,14 @@ def build_extensions(self): | |
|
||
|
||
setup( | ||
name='httptools', | ||
version=VERSION, | ||
description='A collection of framework independent HTTP protocol utils.', | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
url='https://github.com/MagicStack/httptools', | ||
classifiers=[ | ||
'License :: OSI Approved :: MIT License', | ||
'Intended Audience :: Developers', | ||
'Programming Language :: Python :: 3', | ||
'Operating System :: POSIX', | ||
'Operating System :: MacOS :: MacOS X', | ||
'Environment :: Web Environment', | ||
'Development Status :: 5 - Production/Stable', | ||
], | ||
platforms=['macOS', 'POSIX', 'Windows'], | ||
python_requires='>=3.8.0', | ||
zip_safe=False, | ||
author='Yury Selivanov', | ||
author_email='[email protected]', | ||
license='MIT', | ||
packages=['httptools', 'httptools.parser'], | ||
cmdclass={ | ||
'build_ext': httptools_build_ext, | ||
}, | ||
ext_modules=[ | ||
ext_modules=cythonize([ | ||
Extension( | ||
"httptools.parser.parser", | ||
sources=[ | ||
|
@@ -209,7 +131,7 @@ def build_extensions(self): | |
], | ||
extra_compile_args=CFLAGS, | ||
), | ||
], | ||
]), | ||
include_package_data=True, | ||
exclude_package_data={"": ["*.c", "*.h"]}, | ||
test_suite='tests.suite', | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.9 per the changes