EDIT: The question is too long. Here is my real question: how to create and install a python package with setuptools (setup.py) inside CMake? The detail of my code is shown below (but using the source build method, the source method works).
I have a project where I need to distribute my own python package. I created a setup.py script, but I would like to create and install it using CMake.
I used Using CMake with setup.py , but it only works with one CMakeLists.txt along with setup.py and the python folder and without executing cmake from the build directory.
With this arrangement:
Project/ --build/ --lib/ ----python/ ------folder1/ ------folder2/ ------data/ ------... ------__init__.py ----setup.py ----CMakeLists.txt --CMakeLists.txt
and with CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) add_subdirectory(lib) (..)
and with lib / CMakeLists.txt:
find_program(PYTHON "python") if (PYTHON) set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py") set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/python/__init__.py") set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build") configure_file(${SETUP_PY_IN} ${SETUP_PY}) add_custom_command(OUTPUT ${OUTPUT} COMMAND ${PYTHON} ARGS setup.py build DEPENDS ${DEPS}) add_custom_target(target ALL DEPENDS ${OUTPUT}) install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)") endif()
and using setup.py
from setuptools import setup, find_packages setup(name="python", version="xx", author="xx", packages = find_packages(), package_data = {'': ['*.txt']}, description="Python lib for xx")
When I run CMake from the build directory and then do, the target is created, but nothing. As if no packages were found. Installation installs a python package without .py files ...
thanks
source share