mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-07 18:48:54 +08:00
Integrate Python bindings build into make
Now require python >= 2.7
This commit is contained in:
@@ -21,20 +21,26 @@
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
EXTRA_DIST = README.rst cnghttp2.pxd nghttp2.pyx setup.py
|
||||
EXTRA_DIST = cnghttp2.pxd setup.py
|
||||
|
||||
PYSETUP_INCLUDE_DIRS=$(top_srcdir)/lib/includes:$(top_srcdir)/lib
|
||||
PYSETUP_LIBDIRS=$(top_builddir)/lib/.libs
|
||||
if ENABLE_PYTHON_BINDINGS
|
||||
|
||||
.PHONY: help build_ext
|
||||
distclean-local:
|
||||
-rm -f nghttp2.c
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>\` where <target> is one of"
|
||||
@echo " build_ext to build Python @PYTHON_VERSION@ nghttp2 extension"
|
||||
.pyx.c:
|
||||
$(CYTHON) -o $@ $<
|
||||
|
||||
nghttp2.c: nghttp2.pyx cnghttp2.pxd
|
||||
$(CYTHON) nghttp2.pyx
|
||||
pyexec_LTLIBRARIES = nghttp2.la
|
||||
nghttp2_la_SOURCES = nghttp2.pyx
|
||||
nghttp2_la_CPPFLAGS = \
|
||||
$(PYTHON_CPPFLAGS) \
|
||||
-I$(top_srcdir)/lib/includes \
|
||||
-I$(build_srcdir)/lib/includes \
|
||||
-I$(top_srcdir)/lib
|
||||
nghttp2_la_LDFLAGS = \
|
||||
$(PYTHON_LDFLAGS) \
|
||||
-avoid-version -module
|
||||
nghttp2_la_LIBADD = $(top_builddir)/lib/libnghttp2.la
|
||||
|
||||
build_ext: nghttp2.c
|
||||
$(PYTHON) setup.py build_ext --include-dirs=$(PYSETUP_INCLUDE_DIRS) \
|
||||
--library-dirs=$(PYSETUP_LIBDIRS)
|
||||
endif # ENABLE_PYTHON_BINDINGS
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
nghttp2 Python C extension module
|
||||
=================================
|
||||
|
||||
This directory contains nghttp2 Python C extension module. Currently,
|
||||
header compressor and decompressor are implemented in extension using
|
||||
cython.
|
||||
|
||||
This is experimental and adds some dependencies which is a bit hard to
|
||||
check, so this extension module does not built with usual ``make`` in
|
||||
the top directory. Instead, a user has to run ``make build_ext`` in
|
||||
this directory.
|
||||
|
||||
The build extension module is called ``nghttp2``.
|
||||
|
||||
The module refers to the libnghttp2.so. If nghttp2 is installed using
|
||||
``make install``, then importing nghttp2 module should work. If a
|
||||
user does not want to install nghttp2, then use ``LD_LIBRARY_PATH``
|
||||
pointing to the location of libnghttp2.so, which is usually in
|
||||
``lib/.libs``. If a user also does not want to install nghttp2 module,
|
||||
use PYTHONPATH to point the location of extension module. This depends
|
||||
on the architecture and Python version. For example, x86_64
|
||||
architecture and Python 2.7 series, a module will be located at
|
||||
``build/lib.linux-x86_64-2.7``.
|
||||
|
||||
Header compression
|
||||
------------------
|
||||
|
||||
The following example code illustrates basic usage of compressor and
|
||||
decompressor::
|
||||
|
||||
import binascii
|
||||
import nghttp2
|
||||
|
||||
deflater = nghttp2.HDDeflater(nghttp2.HD_SIDE_REQUEST)
|
||||
inflater = nghttp2.HDInflater(nghttp2.HD_SIDE_REQUEST)
|
||||
|
||||
data = deflater.deflate([(b'foo', b'bar'),
|
||||
(b'baz', b'buz')])
|
||||
print(binascii.b2a_hex(data))
|
||||
|
||||
hdrs = inflater.inflate(data)
|
||||
print(hdrs)
|
||||
Reference in New Issue
Block a user