Skip to content

Commit

Permalink
llhttp: s/llhttp/lib/, add llhttp/__init__
Browse files Browse the repository at this point in the history
Move the external sources from llhttp/ to lib/, compile the external module
as __llhttp instead of llhttp, and add an llhttp/__init__ that imports the
compiled module into the existing namespace.  This makes it easier to add
additional python code to the module without changing the module's name.
  • Loading branch information
pallas committed Dec 2, 2020
1 parent 8abe61e commit 349f3e1
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include llhttp/llhttp.h
include lib/llhttp.h
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions llhttp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from __llhttp import *
__all__ = ("Request", "Response")
4 changes: 2 additions & 2 deletions pyllhttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include "llhttp/llhttp.h"
#include "lib/llhttp.h"

#define STRING(x) #x
#define XSTRING(x) STRING(x)
Expand Down Expand Up @@ -435,7 +435,7 @@ snake_to_camel(char * string) {
}

PyMODINIT_FUNC
PyInit_llhttp(void) {
PyInit___llhttp(void) {
PyObject *m = PyModule_Create(&llhttp_module);
if (!m)
return NULL;
Expand Down
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"License :: OSI Approved :: MIT License",
],
headers = [ "llhttp/llhttp.h" ],
ext_modules = [ Extension('llhttp',
packages = [ "llhttp" ],
headers = [ "lib/llhttp.h" ],
ext_modules = [ Extension('__llhttp',
sources = """
pyllhttp.c
llhttp/llhttp.c
llhttp/http.c
llhttp/api.c
lib/llhttp.c
lib/http.c
lib/api.c
""".split(),
language = "c",
) ],
Expand Down

0 comments on commit 349f3e1

Please sign in to comment.