diff --git a/CMakeLists.txt b/CMakeLists.txt index 43151613..612387e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,14 +61,8 @@ if(NOT Python3_FOUND AND NOT Python2_FOUND) endif() if(Python3_FOUND) - function(Python_add_library) - Python3_add_library(${ARGV}) - endfunction() set(PYVER PY3) else() - function(Python_add_library) - Python2_add_library(${ARGV}) - endfunction() set(PYVER PY2) endif() diff --git a/README.rst b/README.rst index e3187bad..76396907 100644 --- a/README.rst +++ b/README.rst @@ -47,10 +47,10 @@ The simplest approach is to install via .. code:: bash - mkvirtualenv --system-site-packages pylada + python -m venv pylada source pylada/bin/activate pip install git+https://github.com/pylada/pylada-light - + This last approach is recommended since it keeps the pylada environment isolated from the rest of the system. Susbsequently, this environment can be accessed by running the second line. @@ -62,19 +62,20 @@ Installation for development .. code:: bash - mkvirtualenv --system-site-packages pylada + python -m venv pylada source pylada/bin/activate git clone https://github.com/pylada/pylada-light cd pylada-light - pip install cython setuptools wheel scikit-build cmake ninja numpy - python setup.py develop + python -m pip install cython setuptools wheel scikit-build cmake ninja numpy + python -m pip install -e .[dev] python setup.py test - + ln -s src/pylada . # because https://github.com/scikit-build/scikit-build/issues/363 + The above creates a virtual environment and installs pylada inside it in development mode. This means that the virtual environment will know about the pylada flavor in development. It is possible to edit a file, do - :bash:`make`, launch python and debug. One just needs to active the virtual - environment once per session. + :bash:`make`, launch python and debug. One just needs to active the + virtual environment once per session. - When modifying files that are built (`.pyx`, `.cc`, `.h`), it is necessary to run `python - setup.py develop` again. + When modifying files that are built (`.pyx`, `.cc`, `.h`), it may be + necessary to run `python setup.py develop` again. diff --git a/src/pylada/CMakeLists.txt b/src/pylada/CMakeLists.txt index a72e0423..7bccf299 100644 --- a/src/pylada/CMakeLists.txt +++ b/src/pylada/CMakeLists.txt @@ -8,6 +8,7 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_version.py" ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_version.py" DESTINATION ${PY_ROOT_DIR}) +include_directories("${PYTHON_INCLUDE_DIR}") add_subdirectory(crystal) add_subdirectory(decorations) add_subdirectory(ewald) diff --git a/src/pylada/crystal/CMakeLists.txt b/src/pylada/crystal/CMakeLists.txt index 3d05cb40..bfc272db 100644 --- a/src/pylada/crystal/CMakeLists.txt +++ b/src/pylada/crystal/CMakeLists.txt @@ -30,16 +30,18 @@ set(cython_sources foreach(filename ${cython_sources}) get_filename_component(name "${filename}" NAME_WE) add_cython_target(cython_${name} ${filename} CXX ${PYVER}}) - Python_add_library(${name} MODULE ${cython_${name}}) - target_link_libraries(${name} PRIVATE Eigen3::Eigen) + add_library(${name} MODULE ${cython_${name}}) + python_extension_module(${name}) + target_link_libraries(${name} Eigen3::Eigen) target_include_directories(${name} PRIVATE "${PY_HEADER_DIR}" "${NumPy_INCLUDE_DIRS}") install(TARGETS ${name} LIBRARY DESTINATION ${PY_ROOT_DIR}/crystal) endforeach() add_cython_target(cython_cutilities cutilities.pyx CXX ${PYVER}) -Python_add_library(cutilities MODULE ${cython_cutilities} smith_normal_form.cc gruber.cc noopt.cc) +add_library(cutilities MODULE ${cython_cutilities} smith_normal_form.cc gruber.cc noopt.cc) +python_extension_module(cutilities) target_include_directories(cutilities PRIVATE "${PY_HEADER_DIR}" "${NumPy_INCLUDE_DIRS}") -target_link_libraries(cutilities PRIVATE Eigen3::Eigen) +target_link_libraries(cutilities Eigen3::Eigen) install(TARGETS cutilities LIBRARY DESTINATION ${PY_ROOT_DIR}/crystal) add_subdirectory(defects) diff --git a/src/pylada/crystal/defects/CMakeLists.txt b/src/pylada/crystal/defects/CMakeLists.txt index c09a03c6..0c54f549 100644 --- a/src/pylada/crystal/defects/CMakeLists.txt +++ b/src/pylada/crystal/defects/CMakeLists.txt @@ -24,7 +24,11 @@ ############################### add_cython_target(defects_cython _defects.pyx CXX ${PYVER}) -Python_add_library(_defects MODULE ${defects_cython} third_order.cc) -target_link_libraries(_defects PRIVATE Eigen3::Eigen) -target_include_directories(_defects PRIVATE "${PY_HEADER_DIR}" "${NumPy_INCLUDE_DIRS}") +add_library(_defects MODULE ${defects_cython} third_order.cc) +python_extension_module(_defects) +target_link_libraries(_defects Eigen3::Eigen) +target_include_directories( + _defects PRIVATE + "${PY_HEADER_DIR}" "${NumPy_INCLUDE_DIRS}" "${PYTHON_INCLUDE_DIR}" +) install(TARGETS _defects LIBRARY DESTINATION ${PY_ROOT_DIR}/crystal/defects) diff --git a/src/pylada/decorations/CMakeLists.txt b/src/pylada/decorations/CMakeLists.txt index 14e47848..06d3124a 100644 --- a/src/pylada/decorations/CMakeLists.txt +++ b/src/pylada/decorations/CMakeLists.txt @@ -21,6 +21,10 @@ ############################### add_cython_target(decorations_cython _decorations.pyx CXX ${PYVER}}) -Python_add_library(_decorations MODULE ${decorations_cython}) -target_include_directories(_decorations PRIVATE "${PY_HEADER_DIR}" "${NumPy_INCLUDE_DIRS}") +add_library(_decorations MODULE ${decorations_cython}) +python_extension_module(_decorations) +target_include_directories( + _decorations PRIVATE + "${PY_HEADER_DIR}" "${NumPy_INCLUDE_DIRS}" "${PYTHON_INCLUDE_DIR}" +) install(TARGETS _decorations LIBRARY DESTINATION ${PY_ROOT_DIR}/decorations) diff --git a/src/pylada/ewald/CMakeLists.txt b/src/pylada/ewald/CMakeLists.txt index 3b851d97..f07a93e5 100644 --- a/src/pylada/ewald/CMakeLists.txt +++ b/src/pylada/ewald/CMakeLists.txt @@ -20,7 +20,8 @@ # . ############################### add_cython_target(ewald_cython ewald.pyx CXX ${PYVER}) -Python_add_library(ewald MODULE +add_library(ewald MODULE ${ewald_cython} ep_com.f90 erfc.cc ewaldf.f90 ewald.cc) +python_extension_module(ewald) target_include_directories(ewald PRIVATE "${PY_HEADER_DIR}") install(TARGETS ewald LIBRARY DESTINATION ${PY_ROOT_DIR}/ewald)