python: Use distutils to build/install python bindings

automake version is a bit picky about installation location and uses
different compiler flags from distutils. We prefer official distutils.
Now nghttp2.c, which is generated by cython, is distributed in
archive.
This commit is contained in:
Tatsuhiro Tsujikawa 2014-02-27 00:58:21 +09:00
parent abdbd29d5f
commit ddf6162528
3 changed files with 28 additions and 16 deletions

View File

@ -322,6 +322,10 @@ fi
AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS],
[test "x${enable_python_bindings}" = "xyes"])
# Produce cython conditional, so that we can distribute generated C
# source
AM_CONDITIONAL([HAVE_CYTHON], [test "x${CYTHON}" != "x"])
# failmalloc tests
AM_CONDITIONAL([ENABLE_FAILMALLOC], [ test "x${enable_failmalloc}" = "xyes" ])
@ -406,6 +410,7 @@ AC_CONFIG_FILES([
src/Makefile
examples/Makefile
python/Makefile
python/setup.py
doc/Makefile
doc/conf.py
doc/index.rst

View File

@ -21,27 +21,30 @@
# 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 = cnghttp2.pxd setup.py
EXTRA_DIST = cnghttp2.pxd nghttp2.pyx setup.py
# Generate nghttp2.c only if we have cython installed
if HAVE_CYTHON
EXTRA_DIST += nghttp2.c
endif # HAVE_CYTHON
if ENABLE_PYTHON_BINDINGS
distclean-local:
-rm -f nghttp2.c
all-local: nghttp2.c
$(PYTHON) setup.py build
install-exec-local:
$(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix)
uninstall-local:
rm -rf $(DESTDIR)$(libdir)/python*/site-packages/*nghttp2*
clean-local:
$(PYTHON) setup.py clean --all
.pyx.c:
$(CYTHON) -o $@ $<
pyexec_LTLIBRARIES = nghttp2.la
nghttp2_la_SOURCES = nghttp2.pyx
nghttp2_la_CPPFLAGS = \
$(PYTHON_CPPFLAGS) \
-fno-strict-aliasing \
-I$(top_srcdir)/lib/includes \
-I$(top_builddir)/lib/includes \
-I$(top_srcdir)/lib
nghttp2_la_LDFLAGS = \
$(PYTHON_LDFLAGS) \
-avoid-version -module
nghttp2_la_LIBADD = $(top_builddir)/lib/libnghttp2.la
endif # ENABLE_PYTHON_BINDINGS

View File

@ -32,6 +32,10 @@ setup(
keywords = [],
ext_modules = [Extension("nghttp2",
["nghttp2.c"],
include_dirs=['@top_srcdir@/lib',
'@top_srcdir@/lib/includes',
'@top_builddir@/lib/includes'],
library_dirs=['@top_builddir@/lib/.libs'],
libraries=['nghttp2'])],
long_description='TBD'
)