-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Support using system llhttp library (#10759) #10760
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
base: master
Are you sure you want to change the base?
Changes from all commits
cb9ac7d
96f1cb0
0b7c184
9b16cdc
9eff9e8
006048f
c9d281c
7ce83ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Added support for building against system ``llhttp`` library -- by :user:`mgorny`. | ||
|
||
This change adds support for :envvar:`AIOHTTP_USE_SYSTEM_DEPS` environment variable that | ||
can be used to build aiohttp against the system install of the ``llhttp`` library rather | ||
than the vendored one. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,7 @@ kwargs | |
latin | ||
lifecycle | ||
linux | ||
llhttp | ||
localhost | ||
Locator | ||
login | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[build-system] | ||
requires = [ | ||
"pkgconfig", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep this list sorted? Is there a minimum version we'd need? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. My idea was to keep I don't think we do need a minimal version. The two functions we're using are available since the first release, 0.1.0. I've just tried forcing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, makes sense. I often make this separation by having an empty line and adding code comments marking essential and plugin sections of the list. But since it wasn't here, I forgot about that habit :) |
||
"setuptools >= 46.4.0", | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ | |
raise RuntimeError("aiohttp 4.x requires Python 3.9+") | ||
|
||
|
||
USE_SYSTEM_DEPS = bool( | ||
os.environ.get("AIOHTTP_USE_SYSTEM_DEPS", os.environ.get("USE_SYSTEM_DEPS")) | ||
) | ||
NO_EXTENSIONS: bool = bool(os.environ.get("AIOHTTP_NO_EXTENSIONS")) | ||
HERE = pathlib.Path(__file__).parent | ||
IS_GIT_REPO = (HERE / ".git").exists() | ||
|
@@ -17,7 +20,11 @@ | |
NO_EXTENSIONS = True | ||
|
||
|
||
if IS_GIT_REPO and not (HERE / "vendor/llhttp/README.md").exists(): | ||
if ( | ||
not USE_SYSTEM_DEPS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, I think this block does not need to be executed with |
||
and IS_GIT_REPO | ||
and not (HERE / "vendor/llhttp/README.md").exists() | ||
): | ||
print("Install submodules when building from git clone", file=sys.stderr) | ||
print("Hint:", file=sys.stderr) | ||
print(" git submodule update --init", file=sys.stderr) | ||
|
@@ -26,19 +33,37 @@ | |
|
||
# NOTE: makefile cythonizes all Cython modules | ||
|
||
if USE_SYSTEM_DEPS: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, I could also add |
||
import shlex | ||
|
||
import pkgconfig | ||
|
||
llhttp_sources = [] | ||
llhttp_kwargs = { | ||
"extra_compile_args": shlex.split(pkgconfig.cflags("libllhttp")), | ||
"extra_link_args": shlex.split(pkgconfig.libs("libllhttp")), | ||
} | ||
else: | ||
llhttp_sources = [ | ||
"vendor/llhttp/build/c/llhttp.c", | ||
"vendor/llhttp/src/native/api.c", | ||
"vendor/llhttp/src/native/http.c", | ||
] | ||
llhttp_kwargs = { | ||
"define_macros": [("LLHTTP_STRICT_MODE", 0)], | ||
"include_dirs": ["vendor/llhttp/build"], | ||
} | ||
|
||
extensions = [ | ||
Extension("aiohttp._websocket.mask", ["aiohttp/_websocket/mask.c"]), | ||
Extension( | ||
"aiohttp._http_parser", | ||
[ | ||
"aiohttp/_http_parser.c", | ||
"aiohttp/_find_header.c", | ||
"vendor/llhttp/build/c/llhttp.c", | ||
"vendor/llhttp/src/native/api.c", | ||
"vendor/llhttp/src/native/http.c", | ||
*llhttp_sources, | ||
], | ||
define_macros=[("LLHTTP_STRICT_MODE", 0)], | ||
include_dirs=["vendor/llhttp/build"], | ||
**llhttp_kwargs, | ||
), | ||
Extension("aiohttp._http_writer", ["aiohttp/_http_writer.c"]), | ||
Extension("aiohttp._websocket.reader_c", ["aiohttp/_websocket/reader_c.c"]), | ||
|
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.
Preview: https://aiohttp--10760.org.readthedocs.build/en/10760/changes.html#packaging-updates-and-notes-for-downstreams