From 663f946a3a90dbc5bb27dc0d2c2b208b158c3b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 30 Jun 2015 12:45:09 -0400 Subject: [PATCH] python: build cython module with autotools --- configure.ac | 19 +++++++++++++++++-- tools/Makefile.am | 4 ++++ tools/python/Makefile.am | 13 +++++++++++++ tools/python/setup.py | 2 ++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tools/python/Makefile.am diff --git a/configure.ac b/configure.ac index 89790bf0..0254785a 100644 --- a/configure.ac +++ b/configure.ac @@ -18,6 +18,18 @@ AC_CHECK_PROGS([DOXYGEN], [doxygen]) if test -z "$DOXYGEN"; then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support]) fi +AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) + +AM_PATH_PYTHON([3.3],, [:]) +AM_CONDITIONAL([HAVE_PYTHON], [test -n "$PYTHON"]) + +if test -n "$PYTHON"; then + AC_CHECK_PROGS([CYTHON], [cython]) + if test -z "$CYTHON"; + then AC_MSG_WARN([Cython not found - continuing without cython support]) + fi +fi +AM_CONDITIONAL([USE_CYTHON], [test -n "$CYTHON"]) case "${host_os}" in "") @@ -64,8 +76,11 @@ PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.1]) AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools],[Disable tools (CLI DHT node)]),,build_tools=yes) AM_CONDITIONAL(ENABLE_TOOLS, test x$build_tools == xyes) -AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile doc/Makefile])]) +AM_COND_IF([USE_CYTHON], [AC_CONFIG_FILES([tools/python/Makefile])]) -AC_CONFIG_FILES([Makefile src/Makefile tools/Makefile opendht.pc]) +AC_CONFIG_FILES([Makefile + src/Makefile + tools/Makefile + opendht.pc]) AC_OUTPUT diff --git a/tools/Makefile.am b/tools/Makefile.am index 81233c7c..31f77f09 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,3 +1,7 @@ +if USE_CYTHON +SUBDIRS = python +endif + libexec_PROGRAMS = dhtnode dhtchat AM_CPPFLAGS = -I../include diff --git a/tools/python/Makefile.am b/tools/python/Makefile.am new file mode 100644 index 00000000..c0a07e53 --- /dev/null +++ b/tools/python/Makefile.am @@ -0,0 +1,13 @@ +if USE_CYTHON + +pybuild.stamp: + LDFLAGS="-L$(top_srcdir)/src/.libs" $(PYTHON) setup.py build_ext --inplace + echo stamp > pybuild.stamp + +CLEANFILES = pybuild.stamp + +all-local: pybuild.stamp +clean-local: + rm -rf $(builddir)/build $(builddir)/*.so + +endif \ No newline at end of file diff --git a/tools/python/setup.py b/tools/python/setup.py index d3845fbd..82f8ede3 100644 --- a/tools/python/setup.py +++ b/tools/python/setup.py @@ -20,12 +20,14 @@ from distutils.core import setup, Extension from Cython.Build import cythonize +from Cython.Distutils import build_ext setup(name="opendht", version="0.1", description="Cython generated wrapper for opendht", author="Guillaume Roguez", license="GPLv3", + cmdclass = { 'build_ext' : build_ext }, ext_modules = cythonize(Extension( "opendht", ["opendht.pyx"], -- GitLab