From f339fb0ef1dbe74cdf4912dc256ec3648308ec2b Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Mon, 6 Dec 2021 15:29:37 +0100 Subject: Modify minimal requirements for python typing. Fix no cgal compilation --- .github/next_release.md | 3 +++ 1 file changed, 3 insertions(+) (limited to '.github') diff --git a/.github/next_release.md b/.github/next_release.md index 170c7494..0d4673bd 100644 --- a/.github/next_release.md +++ b/.github/next_release.md @@ -9,6 +9,9 @@ Below is a list of changes made since GUDHI 3.4.0: - [Coxeter triangulation](https://gudhi.inria.fr/doc/latest/group__coxeter__triangulation.html) - constructs a piecewise-linear approximation of an m-dimensional smooth manifold embedded in R^d using an ambient triangulation. +- [Python installation](link) + - Python >= 3.5 and cython >= 0.27 are now required for Python typing purpose. + - [Module](link) - ... -- cgit v1.2.3 From 54f6f178d30f59a35758421e285cfac946927064 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Mon, 6 Dec 2021 17:36:03 +0100 Subject: Doc review: rephrase --- .github/next_release.md | 2 +- src/python/doc/installation.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '.github') diff --git a/.github/next_release.md b/.github/next_release.md index 0d4673bd..5a1215df 100644 --- a/.github/next_release.md +++ b/.github/next_release.md @@ -10,7 +10,7 @@ Below is a list of changes made since GUDHI 3.4.0: - constructs a piecewise-linear approximation of an m-dimensional smooth manifold embedded in R^d using an ambient triangulation. - [Python installation](link) - - Python >= 3.5 and cython >= 0.27 are now required for Python typing purpose. + - Python >= 3.5 and cython >= 0.27 are now required. - [Module](link) - ... diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 6ed53960..e8321fed 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -156,7 +156,7 @@ You shall have something like: + Missing modules are: bottleneck;nerve_gic;subsampling;tangential_complex;alpha_complex;euclidean_witness_complex; euclidean_strong_witness_complex; -Here, you can see that are requiring CGAL are missing because CGAL is not installed. +Here, you can see that the modules that need CGAL are missing, because CGAL is not installed. :code:`persistence_graphical_tools` is installed, but `its functions `_ will produce an error as matplotlib is not available. -- cgit v1.2.3 From 4fc331267735a3368160ea7cd001b7fa45d720f7 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Thu, 10 Feb 2022 10:32:18 +0100 Subject: Boost 1.66.0 is now the minimal version as required from cgal 5.1 - Also remove useless include boost/version.h --- .github/next_release.md | 3 +++ src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 1 - src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h | 1 - src/Subsampling/include/gudhi/sparsify_point_set.h | 5 ----- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- src/common/doc/installation.h | 2 +- src/common/include/gudhi/reader_utils.h | 4 ---- src/python/doc/installation.rst | 2 +- 8 files changed, 6 insertions(+), 14 deletions(-) (limited to '.github') diff --git a/.github/next_release.md b/.github/next_release.md index 65a92816..e21b25c7 100644 --- a/.github/next_release.md +++ b/.github/next_release.md @@ -13,6 +13,9 @@ Below is a list of changes made since GUDHI 3.5.0: - [Representations](https://gudhi.inria.fr/python/latest/representations.html#gudhi.representations.vector_methods.BettiCurve) - A more flexible Betti curve class capable of computing exact curves +- Installation + - Boost ≥ 1.66.0 is now required (was ≥ 1.56.0). + - [Module](link) - ... diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index ccc3d852..df5c630e 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -12,7 +12,6 @@ #ifndef ALPHA_COMPLEX_3D_H_ #define ALPHA_COMPLEX_3D_H_ -#include #include #include #include diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h index ee64a277..e5522cc7 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/src/Subsampling/include/gudhi/sparsify_point_set.h b/src/Subsampling/include/gudhi/sparsify_point_set.h index 4571b8f3..b325fe3c 100644 --- a/src/Subsampling/include/gudhi/sparsify_point_set.h +++ b/src/Subsampling/include/gudhi/sparsify_point_set.h @@ -11,12 +11,7 @@ #ifndef SPARSIFY_POINT_SET_H_ #define SPARSIFY_POINT_SET_H_ -#include -#if BOOST_VERSION < 106600 -# include -#else # include -#endif #include #ifdef GUDHI_SUBSAMPLING_PROFILING diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index b316740d..68ffaee1 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -1,6 +1,6 @@ # This files manage third party libraries required by GUDHI -find_package(Boost 1.56.0 QUIET OPTIONAL_COMPONENTS filesystem unit_test_framework program_options) +find_package(Boost 1.66.0 QUIET OPTIONAL_COMPONENTS filesystem unit_test_framework program_options) # Boost_FOUND is not reliable if(NOT Boost_VERSION) diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index ef668dfb..67d026bd 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -5,7 +5,7 @@ * Examples of GUDHI headers inclusion can be found in \ref utilities. * * \section compiling Compiling - * The library uses c++14 and requires Boost ≥ 1.56.0 + * The library uses c++14 and requires Boost ≥ 1.66.0 * and CMake ≥ 3.5. * It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. * diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index a1b104e2..29d5423d 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -14,11 +14,7 @@ #include #include -#if BOOST_VERSION < 106600 -# include -#else # include -#endif #include #include diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 35c344e3..c2c3db34 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -39,7 +39,7 @@ If you are instead using a git checkout, beware that the paths are a bit different, and in particular the `python/` subdirectory is actually `src/python/` there. -The library uses c++14 and requires `Boost `_ :math:`\geq` 1.56.0, +The library uses c++14 and requires `Boost `_ :math:`\geq` 1.66.0, `CMake `_ :math:`\geq` 3.5 to generate makefiles, `NumPy `_ :math:`\geq` 1.15.0, `Cython `_ and `pybind11 `_ to compile -- cgit v1.2.3 From fb8ce008feadcaf6a936740a3ed54d50970c731c Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Fri, 11 Feb 2022 23:11:26 +0100 Subject: __copy__, __deepcopy__, copy, and copy ctors. Still pb with the doc --- .github/next_release.md | 3 ++ src/python/gudhi/simplex_tree.pyx | 54 +++++++++++++++---- src/python/test/test_simplex_tree.py | 102 +++++++++++++++++++++++++++++++---- 3 files changed, 140 insertions(+), 19 deletions(-) (limited to '.github') diff --git a/.github/next_release.md b/.github/next_release.md index e21b25c7..3946404b 100644 --- a/.github/next_release.md +++ b/.github/next_release.md @@ -13,6 +13,9 @@ Below is a list of changes made since GUDHI 3.5.0: - [Representations](https://gudhi.inria.fr/python/latest/representations.html#gudhi.representations.vector_methods.BettiCurve) - A more flexible Betti curve class capable of computing exact curves +- [Simplex tree](https://gudhi.inria.fr/python/latest/simplex_tree_ref.html) + - `__copy__`, `__deepcopy__`, `copy` and copy constructors + - Installation - Boost ≥ 1.66.0 is now required (was ≥ 1.56.0). diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index 6b3116a4..ed7c3b92 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -30,6 +30,7 @@ cdef class SimplexTree: # unfortunately 'cdef public Simplex_tree_interface_full_featured* thisptr' is not possible # Use intptr_t instead to cast the pointer cdef public intptr_t thisptr + cdef bool __thisptr_to_be_deleted # Get the pointer casted as it should be cdef Simplex_tree_interface_full_featured* get_ptr(self) nogil: @@ -38,17 +39,36 @@ cdef class SimplexTree: cdef Simplex_tree_persistence_interface * pcohptr # Fake constructor that does nothing but documenting the constructor - def __init__(self): + def __init__(self, other = None, copy = True): """SimplexTree constructor. + :param other: If `other` is a SimplexTree (default = None), the SimplexTree is constructed from a deep/shallow copy of `other`. + :type other: SimplexTree + :param copy: If `True`, the copy will be deep and if `False, the copy will be shallow. Default is `True`. + :type copy: bool + :returns: A simplex tree that is a (deep or shallow) copy of itself. + :rtype: SimplexTree + :note: copy constructor requires :func:`compute_persistence` to be launched again as the result is not copied. """ # The real cython constructor - def __cinit__(self): - self.thisptr = (new Simplex_tree_interface_full_featured()) + def __cinit__(self, other = None, copy = True): + cdef SimplexTree ostr + if other and type(other) is SimplexTree: + ostr = other + if copy: + self.thisptr = (new Simplex_tree_interface_full_featured(dereference(ostr.get_ptr()))) + else: + self.thisptr = ostr.thisptr + # Avoid double free - The original is in charge of deletion + self.__thisptr_to_be_deleted = False + else: + self.__thisptr_to_be_deleted = True + self.thisptr = (new Simplex_tree_interface_full_featured()) def __dealloc__(self): cdef Simplex_tree_interface_full_featured* ptr = self.get_ptr() - if ptr != NULL: + # Avoid double free - The original is in charge of deletion + if ptr != NULL and self.__thisptr_to_be_deleted: del ptr if self.pcohptr != NULL: del self.pcohptr @@ -63,20 +83,34 @@ cdef class SimplexTree: """ return self.pcohptr != NULL - def copy(self): + def copy(self, deep=True): """ - :returns: A simplex tree that is a deep copy itself. + :param deep: If `True`, the copy will be deep and if `False`, the copy will be shallow. Default is `True`. + :type deep: bool + :returns: A simplex tree that is a (deep or shallow) copy of itself. :rtype: SimplexTree + :note: copy requires :func:`compute_persistence` to be launched again as the result is not copied. """ stree = SimplexTree() cdef Simplex_tree_interface_full_featured* stree_ptr cdef Simplex_tree_interface_full_featured* self_ptr=self.get_ptr() - with nogil: - stree_ptr = new Simplex_tree_interface_full_featured(dereference(self_ptr)) - - stree.thisptr = (stree_ptr) + if deep: + with nogil: + stree_ptr = new Simplex_tree_interface_full_featured(dereference(self_ptr)) + + stree.thisptr = (stree_ptr) + else: + stree.thisptr = self.thisptr + # Avoid double free - The original is in charge of deletion + stree.__thisptr_to_be_deleted = False return stree + def __copy__(self): + return self.copy(deep=False) + + def __deepcopy__(self): + return self.copy(deep=True) + def filtration(self, simplex): """This function returns the filtration value for a given N-simplex in this simplicial complex, or +infinity if it is not in the complex. diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index dac45288..6db6d8fb 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -448,20 +448,104 @@ def test_persistence_intervals_in_dimension(): # Test empty case assert st.persistence_intervals_in_dimension(3).shape == (0, 2) -def test_simplex_tree_copy(): +def test_simplex_tree_deep_copy(): st = SimplexTree() - st .insert([1,2,3], 0.) - a = st.copy() + st.insert([1, 2, 3], 0.) + # persistence is not copied + st.compute_persistence() + + st_copy = st.copy(deep=True) # TODO(VR): when #463 is merged, replace with - # assert a == st - assert a.num_vertices() == st.num_vertices() - assert a.num_simplices() == st.num_simplices() + # assert st_copy == st + assert st_copy.num_vertices() == st.num_vertices() + assert st_copy.num_simplices() == st.num_simplices() st_filt_list = list(st.get_filtration()) - assert list(a.get_filtration()) == st_filt_list + assert list(st_copy.get_filtration()) == st_filt_list + + assert st.__is_persistence_defined() == True + assert st_copy.__is_persistence_defined() == False - a.remove_maximal_simplex([1, 2, 3]) - a_filt_list = list(a.get_filtration()) + st_copy.remove_maximal_simplex([1, 2, 3]) + a_filt_list = list(st_copy.get_filtration()) assert len(a_filt_list) < len(st_filt_list) for a_splx in a_filt_list: assert a_splx in st_filt_list + + # test double free + del st + del st_copy + +def test_simplex_tree_shallow_copy(): + st = SimplexTree() + st.insert([1, 2, 3], 0.) + # persistence is not copied + st.compute_persistence() + + st_copy = st.copy(deep=False) + # TODO(VR): when #463 is merged, replace with + # assert st_copy == st + assert st_copy.num_vertices() == st.num_vertices() + assert st_copy.num_simplices() == st.num_simplices() + assert list(st_copy.get_filtration()) == list(st.get_filtration()) + + assert st.__is_persistence_defined() == True + assert st_copy.__is_persistence_defined() == False + + st_copy.assign_filtration([1, 2, 3], 2.) + assert list(st_copy.get_filtration()) == list(st.get_filtration()) + + # test double free + del st + del st_copy + +def test_simplex_tree_deep_copy_constructor(): + st = SimplexTree() + st.insert([1, 2, 3], 0.) + # persistence is not copied + st.compute_persistence() + + st_copy = SimplexTree(st, copy = True) + # TODO(VR): when #463 is merged, replace with + # assert st_copy == st + assert st_copy.num_vertices() == st.num_vertices() + assert st_copy.num_simplices() == st.num_simplices() + st_filt_list = list(st.get_filtration()) + assert list(st_copy.get_filtration()) == st_filt_list + + assert st.__is_persistence_defined() == True + assert st_copy.__is_persistence_defined() == False + + st_copy.remove_maximal_simplex([1, 2, 3]) + a_filt_list = list(st_copy.get_filtration()) + assert len(a_filt_list) < len(st_filt_list) + + for a_splx in a_filt_list: + assert a_splx in st_filt_list + + # test double free + del st + del st_copy + +def test_simplex_tree_shallow_copy(): + st = SimplexTree() + st.insert([1, 2, 3], 0.) + # persistence is not copied + st.compute_persistence() + + st_copy = SimplexTree(st, copy = False) + # TODO(VR): when #463 is merged, replace with + # assert st_copy == st + assert st_copy.num_vertices() == st.num_vertices() + assert st_copy.num_simplices() == st.num_simplices() + assert list(st_copy.get_filtration()) == list(st.get_filtration()) + + assert st.__is_persistence_defined() == True + assert st_copy.__is_persistence_defined() == False + + st_copy.assign_filtration([1, 2, 3], 2.) + assert list(st_copy.get_filtration()) == list(st.get_filtration()) + + # test double free + del st + del st_copy -- cgit v1.2.3 From 43981a4d487669fe2002337ab62b72dd9e83a64a Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Mon, 14 Feb 2022 11:08:00 +0100 Subject: Remove shallow copy --- .github/next_release.md | 2 +- src/python/gudhi/simplex_tree.pyx | 54 +++++++++++++----------------------- src/python/test/test_simplex_tree.py | 50 ++------------------------------- 3 files changed, 23 insertions(+), 83 deletions(-) (limited to '.github') diff --git a/.github/next_release.md b/.github/next_release.md index 3946404b..3d4761eb 100644 --- a/.github/next_release.md +++ b/.github/next_release.md @@ -14,7 +14,7 @@ Below is a list of changes made since GUDHI 3.5.0: - A more flexible Betti curve class capable of computing exact curves - [Simplex tree](https://gudhi.inria.fr/python/latest/simplex_tree_ref.html) - - `__copy__`, `__deepcopy__`, `copy` and copy constructors + - `__deepcopy__`, `copy` and copy constructors - Installation - Boost ≥ 1.66.0 is now required (was ≥ 1.56.0). diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx index ed7c3b92..0213e363 100644 --- a/src/python/gudhi/simplex_tree.pyx +++ b/src/python/gudhi/simplex_tree.pyx @@ -30,7 +30,6 @@ cdef class SimplexTree: # unfortunately 'cdef public Simplex_tree_interface_full_featured* thisptr' is not possible # Use intptr_t instead to cast the pointer cdef public intptr_t thisptr - cdef bool __thisptr_to_be_deleted # Get the pointer casted as it should be cdef Simplex_tree_interface_full_featured* get_ptr(self) nogil: @@ -39,36 +38,32 @@ cdef class SimplexTree: cdef Simplex_tree_persistence_interface * pcohptr # Fake constructor that does nothing but documenting the constructor - def __init__(self, other = None, copy = True): + def __init__(self, other = None): """SimplexTree constructor. - :param other: If `other` is a SimplexTree (default = None), the SimplexTree is constructed from a deep/shallow copy of `other`. + + :param other: If `other` is a `None` (default value), an empty `SimplexTree` is created. + If `other` is a `SimplexTree`, the `SimplexTree` is constructed from a deep copy of `other`. :type other: SimplexTree - :param copy: If `True`, the copy will be deep and if `False, the copy will be shallow. Default is `True`. - :type copy: bool - :returns: A simplex tree that is a (deep or shallow) copy of itself. + :returns: An empty or a copy simplex tree. :rtype: SimplexTree - :note: copy constructor requires :func:`compute_persistence` to be launched again as the result is not copied. + + :note: If the `SimplexTree` is a copy, it requires :func:`compute_persistence` to be launched again as the + persistence result is not copied. """ # The real cython constructor - def __cinit__(self, other = None, copy = True): + def __cinit__(self, other = None): cdef SimplexTree ostr if other and type(other) is SimplexTree: ostr = other - if copy: - self.thisptr = (new Simplex_tree_interface_full_featured(dereference(ostr.get_ptr()))) - else: - self.thisptr = ostr.thisptr - # Avoid double free - The original is in charge of deletion - self.__thisptr_to_be_deleted = False + self.thisptr = (new Simplex_tree_interface_full_featured(dereference(ostr.get_ptr()))) else: - self.__thisptr_to_be_deleted = True self.thisptr = (new Simplex_tree_interface_full_featured()) def __dealloc__(self): cdef Simplex_tree_interface_full_featured* ptr = self.get_ptr() # Avoid double free - The original is in charge of deletion - if ptr != NULL and self.__thisptr_to_be_deleted: + if ptr != NULL: del ptr if self.pcohptr != NULL: del self.pcohptr @@ -83,33 +78,24 @@ cdef class SimplexTree: """ return self.pcohptr != NULL - def copy(self, deep=True): + def copy(self): """ - :param deep: If `True`, the copy will be deep and if `False`, the copy will be shallow. Default is `True`. - :type deep: bool - :returns: A simplex tree that is a (deep or shallow) copy of itself. + :returns: A simplex tree that is a deep copy of itself. :rtype: SimplexTree - :note: copy requires :func:`compute_persistence` to be launched again as the result is not copied. + + :note: copy requires :func:`compute_persistence` to be launched again as the persistence result is not copied. """ stree = SimplexTree() cdef Simplex_tree_interface_full_featured* stree_ptr cdef Simplex_tree_interface_full_featured* self_ptr=self.get_ptr() - if deep: - with nogil: - stree_ptr = new Simplex_tree_interface_full_featured(dereference(self_ptr)) - - stree.thisptr = (stree_ptr) - else: - stree.thisptr = self.thisptr - # Avoid double free - The original is in charge of deletion - stree.__thisptr_to_be_deleted = False - return stree + with nogil: + stree_ptr = new Simplex_tree_interface_full_featured(dereference(self_ptr)) - def __copy__(self): - return self.copy(deep=False) + stree.thisptr = (stree_ptr) + return stree def __deepcopy__(self): - return self.copy(deep=True) + return self.copy() def filtration(self, simplex): """This function returns the filtration value for a given N-simplex in diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index 6db6d8fb..62dcc865 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -454,7 +454,7 @@ def test_simplex_tree_deep_copy(): # persistence is not copied st.compute_persistence() - st_copy = st.copy(deep=True) + st_copy = st.copy() # TODO(VR): when #463 is merged, replace with # assert st_copy == st assert st_copy.num_vertices() == st.num_vertices() @@ -476,36 +476,13 @@ def test_simplex_tree_deep_copy(): del st del st_copy -def test_simplex_tree_shallow_copy(): - st = SimplexTree() - st.insert([1, 2, 3], 0.) - # persistence is not copied - st.compute_persistence() - - st_copy = st.copy(deep=False) - # TODO(VR): when #463 is merged, replace with - # assert st_copy == st - assert st_copy.num_vertices() == st.num_vertices() - assert st_copy.num_simplices() == st.num_simplices() - assert list(st_copy.get_filtration()) == list(st.get_filtration()) - - assert st.__is_persistence_defined() == True - assert st_copy.__is_persistence_defined() == False - - st_copy.assign_filtration([1, 2, 3], 2.) - assert list(st_copy.get_filtration()) == list(st.get_filtration()) - - # test double free - del st - del st_copy - def test_simplex_tree_deep_copy_constructor(): st = SimplexTree() st.insert([1, 2, 3], 0.) # persistence is not copied st.compute_persistence() - st_copy = SimplexTree(st, copy = True) + st_copy = SimplexTree(st) # TODO(VR): when #463 is merged, replace with # assert st_copy == st assert st_copy.num_vertices() == st.num_vertices() @@ -526,26 +503,3 @@ def test_simplex_tree_deep_copy_constructor(): # test double free del st del st_copy - -def test_simplex_tree_shallow_copy(): - st = SimplexTree() - st.insert([1, 2, 3], 0.) - # persistence is not copied - st.compute_persistence() - - st_copy = SimplexTree(st, copy = False) - # TODO(VR): when #463 is merged, replace with - # assert st_copy == st - assert st_copy.num_vertices() == st.num_vertices() - assert st_copy.num_simplices() == st.num_simplices() - assert list(st_copy.get_filtration()) == list(st.get_filtration()) - - assert st.__is_persistence_defined() == True - assert st_copy.__is_persistence_defined() == False - - st_copy.assign_filtration([1, 2, 3], 2.) - assert list(st_copy.get_filtration()) == list(st.get_filtration()) - - # test double free - del st - del st_copy -- cgit v1.2.3 From 5857c571388a4349934a266ca187b2c2ac10818c Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Thu, 21 Apr 2022 14:44:22 +0200 Subject: Make Windows compilation fails on error (#598) Use '-DEIGEN_DEFAULT_DENSE_INDEX_TYPE=int' as a workaround --- .github/workflows/pip-build-windows.yml | 8 ++++---- .github/workflows/pip-packaging-windows.yml | 8 ++++---- azure-pipelines.yml | 17 ++++++++++++----- src/cmake/modules/GUDHI_third_party_libraries.cmake | 9 +++++++++ src/python/CMakeLists.txt | 12 +++++++++++- 5 files changed, 40 insertions(+), 14 deletions(-) (limited to '.github') diff --git a/.github/workflows/pip-build-windows.yml b/.github/workflows/pip-build-windows.yml index 954b59d5..30b0bd94 100644 --- a/.github/workflows/pip-build-windows.yml +++ b/.github/workflows/pip-build-windows.yml @@ -30,14 +30,14 @@ jobs: run: | mkdir build cd ".\build\" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=c:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows .. + cmake -DCMAKE_BUILD_TYPE=Release -DFORCE_EIGEN_DEFAULT_DENSE_INDEX_TYPE_TO_INT=ON -DCMAKE_TOOLCHAIN_FILE=c:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows .. Get-Location dir cd ".\src\python\" - cp "C:\vcpkg\installed\x64-windows\bin\mpfr-6.dll" ".\gudhi\" - cp "C:\vcpkg\installed\x64-windows\bin\gmp.dll" ".\gudhi\" + cp "C:\vcpkg\installed\x64-windows\bin\mpfr*.dll" ".\gudhi\" + cp "C:\vcpkg\installed\x64-windows\bin\gmp*.dll" ".\gudhi\" python setup.py bdist_wheel - ls dist + ls ".\dist\" cd ".\dist\" Get-ChildItem *.whl | ForEach-Object{python -m pip install --user $_.Name} - name: Test python wheel diff --git a/.github/workflows/pip-packaging-windows.yml b/.github/workflows/pip-packaging-windows.yml index 962ae68a..142a114c 100644 --- a/.github/workflows/pip-packaging-windows.yml +++ b/.github/workflows/pip-packaging-windows.yml @@ -33,14 +33,14 @@ jobs: run: | mkdir build cd ".\build\" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=c:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows .. + cmake -DCMAKE_BUILD_TYPE=Release -DFORCE_EIGEN_DEFAULT_DENSE_INDEX_TYPE_TO_INT=ON -DCMAKE_TOOLCHAIN_FILE=c:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows .. Get-Location dir cd ".\src\python\" - cp "C:\vcpkg\installed\x64-windows\bin\mpfr-6.dll" ".\gudhi\" - cp "C:\vcpkg\installed\x64-windows\bin\gmp.dll" ".\gudhi\" + cp "C:\vcpkg\installed\x64-windows\bin\mpfr*.dll" ".\gudhi\" + cp "C:\vcpkg\installed\x64-windows\bin\gmp*.dll" ".\gudhi\" python setup.py bdist_wheel - ls dist + ls ".\dist\" cd ".\dist\" Get-ChildItem *.whl | ForEach-Object{python -m pip install --user $_.Name} - name: Test python wheel diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 21664244..a39f6d5c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,7 +30,7 @@ jobs: - bash: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE:STRING=$(cmakeBuildType) -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=ON .. + cmake -DCMAKE_BUILD_TYPE:STRING=$(cmakeBuildType) -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=ON .. make make doxygen ctest --output-on-failure @@ -64,20 +64,27 @@ jobs: vcpkg install boost-filesystem:x64-windows boost-test:x64-windows boost-program-options:x64-windows tbb:x64-windows eigen3:x64-windows cgal:x64-windows displayName: 'Install build dependencies' - script: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 + IF %errorlevel% NEQ 0 exit /b %errorlevel% mkdir build cd build - cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release $(cmakeVcpkgFlags) $(cmakeFlags) .. + cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFORCE_EIGEN_DEFAULT_DENSE_INDEX_TYPE_TO_INT=ON $(cmakeVcpkgFlags) $(cmakeFlags) .. + IF %errorlevel% NEQ 0 exit /b %errorlevel% MSBuild GUDHIdev.sln /m /p:Configuration=Release /p:Platform=x64 + IF %errorlevel% NEQ 0 exit /b %errorlevel% ctest --output-on-failure -C Release -E diff_files + IF %errorlevel% NEQ 0 exit /b %errorlevel% cmake -DWITH_GUDHI_PYTHON=ON . + IF %errorlevel% NEQ 0 exit /b %errorlevel% cd src\python - copy "C:\vcpkg\installed\x64-windows\bin\mpfr-6.dll" ".\gudhi\" - copy "C:\vcpkg\installed\x64-windows\bin\gmp.dll" ".\gudhi\" + copy "C:\vcpkg\installed\x64-windows\bin\mpfr*.dll" ".\gudhi\" + copy "C:\vcpkg\installed\x64-windows\bin\gmp*.dll" ".\gudhi\" copy "C:\vcpkg\installed\x64-windows\bin\tbb.dll" ".\gudhi\" copy "C:\vcpkg\installed\x64-windows\bin\tbbmalloc.dll" ".\gudhi\" python setup.py build_ext --inplace + IF %errorlevel% NEQ 0 exit /b %errorlevel% SET PYTHONPATH=%CD%;%PYTHONPATH% echo %PYTHONPATH% ctest --output-on-failure -C Release + IF %errorlevel% NEQ 0 exit /b %errorlevel% displayName: 'Build and test' diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 7c982b3b..6a94d1f5 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -19,6 +19,15 @@ if(GMP_FOUND) endif() endif() +# from windows vcpkg eigen 3.4.0#2 : build fails with +# error C2440: '': cannot convert from 'Eigen::EigenBase::Index' to '__gmp_expr' +# cf. https://gitlab.com/libeigen/eigen/-/issues/2476 +# Workaround is to compile with '-DEIGEN_DEFAULT_DENSE_INDEX_TYPE=int' +if (FORCE_EIGEN_DEFAULT_DENSE_INDEX_TYPE_TO_INT) + message("++ User explicit demand to force EIGEN_DEFAULT_DENSE_INDEX_TYPE to int") + add_definitions(-DEIGEN_DEFAULT_DENSE_INDEX_TYPE=int) +endif() + # In CMakeLists.txt, when include(${CGAL_USE_FILE}), CMAKE_CXX_FLAGS are overwritten. # cf. http://doc.cgal.org/latest/Manual/installation.html#title40 # A workaround is to include(${CGAL_USE_FILE}) before adding "-std=c++11". diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index fbfb0d1f..e31af02e 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -180,6 +180,15 @@ if(PYTHONINTERP_FOUND) set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'alpha_complex', ") endif () + # from windows vcpkg eigen 3.4.0#2 : build fails with + # error C2440: '': cannot convert from 'Eigen::EigenBase::Index' to '__gmp_expr' + # cf. https://gitlab.com/libeigen/eigen/-/issues/2476 + # Workaround is to compile with '-DEIGEN_DEFAULT_DENSE_INDEX_TYPE=int' + if (FORCE_EIGEN_DEFAULT_DENSE_INDEX_TYPE_TO_INT) + set(GUDHI_PYTHON_EXTRA_COMPILE_ARGS "${GUDHI_PYTHON_EXTRA_COMPILE_ARGS}'-DEIGEN_DEFAULT_DENSE_INDEX_TYPE=int', ") + endif() + + add_gudhi_debug_info("Boost version ${Boost_VERSION}") if(CGAL_FOUND) if(NOT CGAL_VERSION VERSION_LESS 5.3.0) @@ -215,13 +224,14 @@ if(PYTHONINTERP_FOUND) endif(NOT GMP_LIBRARIES_DIR) add_GUDHI_PYTHON_lib_dir(${GMP_LIBRARIES_DIR}) message("** Add gmp ${GMP_LIBRARIES_DIR}") + # When FORCE_CGAL_NOT_TO_BUILD_WITH_GMPXX is set, not defining CGAL_USE_GMPXX is sufficient enough if(GMPXX_FOUND) add_gudhi_debug_info("GMPXX_LIBRARIES = ${GMPXX_LIBRARIES}") set(GUDHI_PYTHON_EXTRA_COMPILE_ARGS "${GUDHI_PYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_GMPXX', ") add_GUDHI_PYTHON_lib("${GMPXX_LIBRARIES}") add_GUDHI_PYTHON_lib_dir(${GMPXX_LIBRARIES_DIR}) message("** Add gmpxx ${GMPXX_LIBRARIES_DIR}") - endif(GMPXX_FOUND) + endif() endif(GMP_FOUND) if(MPFR_FOUND) add_gudhi_debug_info("MPFR_LIBRARIES = ${MPFR_LIBRARIES}") -- cgit v1.2.3