Skip to content

Commit

Permalink
Merge pull request #1131 from VincentRouvreau/symbolic_links_for_setu…
Browse files Browse the repository at this point in the history
…p_py

Symbolic links for cython and pybind11 compilation
  • Loading branch information
VincentRouvreau authored Sep 19, 2024
2 parents 903f210 + 1e15367 commit 4d8779b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/for_maintainers/new_gudhi_version_creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ nor [unlabelled closed PRs](https://github.com/GUDHI/gudhi-devel/pulls?q=is%3Apr
**Edit the file CMakeGUDHIVersion.txt**, and increment major, minor, or patch version number, in function of the version new delivery.
```bash
# cf. .gitignore - ignore this if it is a fresh clone version
rm -rf data/points/COIL_database/lucky_cat.off_dist data/points/COIL_database/lucky_cat.off_sc.dot data/points/KleinBottle5D.off_dist data/points/KleinBottle5D.off_sc.dot data/points/human.off_dist data/points/human.off_sc.off data/points/human.off_sc.txt src/python/test/__pycache__ src/python/gudhi/*.cpp
rm -rf data/points/COIL_database/lucky_cat.off_dist data/points/COIL_database/lucky_cat.off_sc.dot data/points/KleinBottle5D.off_dist data/points/KleinBottle5D.off_sc.dot data/points/human.off_dist data/points/human.off_sc.off data/points/human.off_sc.txt src/python/test/__pycache__
```

Checkin the modifications, build and test the version:
Expand Down Expand Up @@ -154,4 +154,4 @@ Send version mail to the following lists :

**Edit the file CMakeGUDHIVersion.txt**, and increment major, minor, or patch version number, in function of the future version (something like `3.X+1.0a0`).

Reset [.github/next_release.md](.github/next_release.md) with [.github/for_maintainers/next_release_template.md](.github/for_maintainers/next_release_template.md).
Reset [.github/next_release.md](.github/next_release.md) with [.github/for_maintainers/next_release_template.md](.github/for_maintainers/next_release_template.md).
5 changes: 0 additions & 5 deletions .github/workflows/pip-packaging-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
# numpy~=1.21.4 means any numpy=1.21.*, but also numpy>=1.21.4 (numpy~=1.21 do not work as it means any numpy==1.*)
- name: Build wheel for Python 3.8
run: |
rm -rf src/python/gudhi/*.cpp
mkdir build_38
cd build_38
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON38/bin/python ..
Expand All @@ -38,7 +37,6 @@ jobs:
$PYTHON38/bin/python -m pytest -v src/python/test/test_rips_complex.py
- name: Build wheel for Python 3.9
run: |
rm -rf src/python/gudhi/*.cpp
mkdir build_39
cd build_39
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON39/bin/python ..
Expand All @@ -61,7 +59,6 @@ jobs:
$PYTHON39/bin/python -m pytest -v src/python/test/test_rips_complex.py
- name: Build wheel for Python 3.10
run: |
rm -rf src/python/gudhi/*.cpp
mkdir build_310
cd build_310
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON310/bin/python ..
Expand All @@ -80,7 +77,6 @@ jobs:
$PYTHON310/bin/python -m pytest -v src/python/test/test_rips_complex.py
- name: Build wheel for Python 3.11
run: |
rm -rf src/python/gudhi/*.cpp
mkdir build_311
cd build_311
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON311/bin/python ..
Expand All @@ -99,7 +95,6 @@ jobs:
$PYTHON311/bin/python -m pytest -v src/python/test/test_rips_complex.py
- name: Build wheel for Python 3.12
run: |
rm -rf src/python/gudhi/*.cpp
mkdir build_312
cd build_312
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON312/bin/python ..
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Classical CMake build directory
/*build*

# Generated by Cython
src/python/gudhi/*.cpp

# Generated by tests
data/points/COIL_database/lucky_cat.off_dist
data/points/COIL_database/lucky_cat.off_sc.dot
Expand Down
25 changes: 22 additions & 3 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ function( add_gudhi_py_test THE_TEST )
endif()
endfunction( add_gudhi_py_test )

function( add_gudhi_symbolic_links GLOBBING_EXPRESSION )
# No symbolic links if build in sources (aka. 'cmake .' in sources)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
return()
endif()
file(GLOB GUDHI_GLOB_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${GLOBBING_EXPRESSION})
foreach(GUDHI_GLOB_FILENAME ${GUDHI_GLOB_FILES})
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/${GUDHI_GLOB_FILENAME}" "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_GLOB_FILENAME}" SYMBOLIC)
endforeach()
endfunction( add_gudhi_symbolic_links )

# Set gudhi.__debug_info__
# WARNING : to be done before setup.py.in configure_file
function( add_gudhi_debug_info DEBUG_INFO )
Expand Down Expand Up @@ -382,6 +393,14 @@ file(COPY "gudhi/flag_filtration" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi
# Some files for pip package
file(COPY "pyproject.toml" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")

# Symbolic links to cython and Pybind11 sources to be built. "MAKE_DIRECTORY gudhi" must be done before
add_gudhi_symbolic_links("gudhi/*.pxd")
add_gudhi_symbolic_links("gudhi/*.pyx")
add_gudhi_symbolic_links("gudhi/*.cc")
add_gudhi_symbolic_links("gudhi/clustering/_tomato.cc")
add_gudhi_symbolic_links("gudhi/hera/*.cc")
add_gudhi_symbolic_links("gudhi/datasets/generators/_points.cc")

add_custom_command(
OUTPUT gudhi.so
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand Down Expand Up @@ -438,7 +457,7 @@ add_test(NAME random_cubical_complex_persistence_example_py_test

add_gudhi_py_test(test_cubical_complex)

# Datasets are fetched for these tests
# Datasets are fetched for these tests
if(SKLEARN_FOUND AND WITH_GUDHI_REMOTE_TEST)
add_gudhi_py_test(test_sklearn_cubical_persistence)

Expand Down Expand Up @@ -574,7 +593,7 @@ if(SKLEARN_FOUND)
add_gudhi_py_test(test_sklearn_rips_persistence)
endif()

# Datasets are fetched for these tests
# Datasets are fetched for these tests
if(WITH_GUDHI_REMOTE_TEST)
add_test(NAME rips_complex_sklearn_itf_py_test
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand Down Expand Up @@ -690,4 +709,4 @@ if(MATPLOTLIB_FOUND)
endif()

# Set missing or not modules
set(GUDHI_MODULES ${GUDHI_MODULES} "python" CACHE INTERNAL "GUDHI_MODULES")
set(GUDHI_MODULES ${GUDHI_MODULES} "python" CACHE INTERNAL "GUDHI_MODULES")
2 changes: 1 addition & 1 deletion src/python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import pybind11
cython_modules = [@GUDHI_CYTHON_MODULES@]
pybind11_modules = [@GUDHI_PYBIND11_MODULES@]

source_dir='@CMAKE_CURRENT_SOURCE_DIR@/gudhi/'
source_dir='gudhi/'
extra_compile_args=[@GUDHI_PYTHON_EXTRA_COMPILE_ARGS@]
extra_link_args=[@GUDHI_PYTHON_EXTRA_LINK_ARGS@]
libraries=[@GUDHI_PYTHON_LIBRARIES@]
Expand Down

0 comments on commit 4d8779b

Please sign in to comment.