Skip to content
Snippets Groups Projects
Commit a31bd73a authored by Adrien Béraud's avatar Adrien Béraud
Browse files

python: properly build and install with cmake and autotools

parent 45d8817e
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required (VERSION 2.8.6) cmake_minimum_required (VERSION 2.8.6)
project (opendht) project (opendht)
set (opendht_VERSION_MAJOR 0)
set (opendht_VERSION_MINOR 1)
set (opendht_VERSION ${opendht_VERSION_MAJOR}.${opendht_VERSION_MINOR})
set (PACKAGE_VERSION ${opendht_VERSION})
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
...@@ -78,6 +82,10 @@ if (OPENDHT_TOOLS) ...@@ -78,6 +82,10 @@ if (OPENDHT_TOOLS)
add_subdirectory(tools) add_subdirectory(tools)
endif () endif ()
if (OPENDHT_PYTHON)
add_subdirectory(python)
endif ()
install (TARGETS opendht opendht-static DESTINATION ${CMAKE_INSTALL_LIBDIR}) install (TARGETS opendht opendht-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
install (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) install (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/opendht.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/opendht.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
...@@ -80,7 +80,15 @@ AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools],[Disable tools (CLI DHT ...@@ -80,7 +80,15 @@ AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools],[Disable tools (CLI DHT
AM_CONDITIONAL(ENABLE_TOOLS, test x$build_tools == xyes) AM_CONDITIONAL(ENABLE_TOOLS, test x$build_tools == xyes)
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile doc/Makefile])]) AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile doc/Makefile])])
AM_COND_IF([USE_CYTHON], [AC_CONFIG_FILES([python/Makefile])])
dnl Configure setup.py if we build the python module
AM_COND_IF([USE_CYTHON], [
AC_SUBST(CURRENT_SOURCE_DIR, ".")
AC_SUBST(CURRENT_BINARY_DIR, ".")
AC_SUBST(PROJECT_SOURCE_DIR, "..")
AC_SUBST(PROJECT_BINARY_DIR, "../src/.libs")
AC_CONFIG_FILES([python/Makefile python/setup.py])
])
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
src/Makefile src/Makefile
......
set(CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
configure_file(setup.py.in setup.py)
add_custom_target(python ALL
COMMAND python3 setup.py build
DEPENDS opendht opendht_cpp.pxd opendht.pyx)
install(CODE "execute_process(COMMAND python3 setup.py install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
...@@ -11,7 +11,7 @@ clean-local: ...@@ -11,7 +11,7 @@ clean-local:
rm -rf $(builddir)/build $(builddir)/*.so rm -rf $(builddir)/build $(builddir)/*.so
install: install:
$(PYTHON) setup.py install $(PYTHON) setup.py install --prefix=$(PYTHON_PREFIX)
rm -rf $(builddir)/build rm -rf $(builddir)/build
endif endif
\ No newline at end of file
...@@ -26,17 +26,32 @@ from Cython.Build import cythonize ...@@ -26,17 +26,32 @@ from Cython.Build import cythonize
from Cython.Distutils import build_ext from Cython.Distutils import build_ext
setup(name="opendht", setup(name="opendht",
version="0.1", version="@PACKAGE_VERSION@",
description="Cython generated wrapper for opendht", description="Python wrapper for opendht",
author="Guillaume Roguez", author="Adrien Béraud, Guillaume Roguez",
license="GPLv3", license="GPLv3",
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Distributed Computing',
'Topic :: System :: Networking'
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
cmdclass = { 'build_ext' : build_ext }, cmdclass = { 'build_ext' : build_ext },
ext_modules = cythonize(Extension( ext_modules = cythonize(Extension(
"opendht", "opendht",
["opendht.pyx"], ["@CURRENT_SOURCE_DIR@/opendht.pyx"],
include_dirs = ['@PROJECT_SOURCE_DIR@/include'],
language="c++", language="c++",
extra_compile_args=["-std=c++11"], extra_compile_args=["-std=c++11"],
extra_link_args=["-std=c++11"], extra_link_args=["-std=c++11"],
libraries=["opendht"] libraries=["opendht"],
library_dirs = ['@CURRENT_BINARY_DIR@', '@PROJECT_BINARY_DIR@']
)) ))
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment