git: 224b32fffa22 - main - cad/py-ocp: Update to 7.5.2

From: Neel Chauhan <nc_at_FreeBSD.org>
Date: Fri, 29 Oct 2021 16:47:32 UTC
The branch main has been updated by nc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=224b32fffa22fc1abd54938df081c92210b539ba

commit 224b32fffa22fc1abd54938df081c92210b539ba
Author:     Neal Nelson <ports@nicandneal.net>
AuthorDate: 2021-10-29 16:45:41 +0000
Commit:     Neel Chauhan <nc@FreeBSD.org>
CommitDate: 2021-10-29 16:46:34 +0000

    cad/py-ocp: Update to 7.5.2
    
    PR:     259503
---
 cad/py-ocp/Makefile                                | 62 ++++++++++++++--------
 cad/py-ocp/distinfo                                |  6 +--
 .../files/cpatch-OCCT_OpenGl__HaltonSampler.hxx    | 11 ++++
 cad/py-ocp/files/patch-FindOpenCascade.cmake       | 12 ++---
 cad/py-ocp/files/patch-Standard.cpp                | 17 ------
 cad/py-ocp/files/patch-dump__symbols.py            | 29 ++++++++++
 cad/py-ocp/files/patch-ocp.toml                    | 30 +++++++++++
 .../files/patch-opencascade_Standard__Time.hxx     | 19 +++++++
 cad/py-ocp/files/patch-templates_CMakeLists.j2     | 19 +++++++
 cad/py-ocp/pkg-message                             |  4 ++
 10 files changed, 159 insertions(+), 50 deletions(-)

diff --git a/cad/py-ocp/Makefile b/cad/py-ocp/Makefile
index f216d98fb5f5..93cef6cffc4d 100644
--- a/cad/py-ocp/Makefile
+++ b/cad/py-ocp/Makefile
@@ -1,42 +1,60 @@
 PORTNAME=	ocp
-DISTVERSION=	7.4-RC2
-PORTREVISION=	3
-CATEGORIES=	cad
-# Direct access to github is needed because the release added an extra archive which
-# we need to build from, rather than the initial release.
-MASTER_SITES=	https://github.com/CadQuery/OCP/releases/download/${DISTVERSION}/
+DISTVERSION=	7.5.2
+CATEGORIES=	cad python
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
-DISTNAME=	OCP_src_Linux
 
 MAINTAINER=	ports@nicandneal.net
 COMMENT=	Python wrapper for OCCT generated using pywrap
 
-BROKEN=		Mismatch between OpenCascase (7.5) and py-ocp (7.4)
-
 LICENSE=	APACHE20
 
-PATCH_DEPENDS=	${LOCALBASE}/include/OpenCASCADE/OpenGl_HaltonSampler.hxx:cad/opencascade
-LIB_DEPENDS=	libTKernel.so:cad/opencascade
-BUILD_DEPENDS=	${LOCALBASE}/share/cmake/pybind11/pybind11Config.cmake:devel/pybind11 \
-		${PYTHON_SITELIBDIR}/pybind11:devel/py-pybind11@${PY_FLAVOR}
+EXTRACT_DEPENDS=	${PYTHON_PKGNAMEPREFIX}cadquery-pywrap>0:devel/py-cadquery-pywrap@${PY_FLAVOR}
+LIB_DEPENDS=	libTKernel.so:cad/opencascade \
+		libvtksys-${VTKVER}.so:math/vtk9
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pybind11>0:devel/py-pybind11@${PY_FLAVOR} \
+		pybind11>0:devel/pybind11 \
+		rapidjson>0:devel/rapidjson \
+		${PYTHON_PKGNAMEPREFIX}path>0:devel/py-path@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}lief>0:devel/py-lief@${PY_FLAVOR}
 
-USES=		cmake compiler:c++11-lang gl python:3.6+ zip
+USES=		python:3.6+ cmake gl compiler:c++11-lang
 USE_GL=		gl glu glut
 
-WRKSRC=		${WRKDIR}/OCP_src_Ubuntu-16.04
+USE_GITHUB=	yes
+GH_ACCOUNT=	CadQuery
+GH_PROJECT=	OCP
+GH_TAGNAME=	52c15d8
+
+VTKVER=         9.0
+
+CONFIG_FILE=	${WRKSRC}/ocp.toml
+
+OCCT=           ${LOCALBASE}/include/OpenCASCADE
+
+CMAKE_ARGS+=	-DPYTHON_EXECUTABLE=${PYTHON_CMD} \
+		-DOPENCASCADE_INCLUDE_DIR=${OCCT} \
+		-DVTK_DIR:PATH=${LOCALBASE}/lib/vtk-${VTKVER}/cmake/vtk-${VTKVER}
+CMAKE_SOURCE_PATH=	${WRKSRC}/OCP
 
-OCCT=		${LOCALBASE}/include/OpenCASCADE
-OCCT_LOCAL=	${WRKSRC}/OCCT
+PLIST_FILES=    ${PYTHON_SITELIBDIR}/OCP.so
 
-CMAKE_ARGS=	-DOPENCASCADE_INCLUDE_DIR=${OCCT} \
-		-DPYTHON_EXECUTABLE=${PYTHON_CMD}
+export CONDA_PREFIX=	${LOCALBASE}
 
-USE_PYTHON=	flavors
+post-patch:
+	@${REINPLACE_CMD} -e 's|input_folder = "./opencascade"|input_folder = "${OCCT}"|g' ${WRKSRC}/ocp.toml
 
-PLIST_FILES=	${PYTHON_SITELIBDIR}/OCP.so
+pre-configure:
+	# Generate the header files.
+	(cd ${WRKSRC} && ${PYTHON_CMD} dump_symbols.py ${LOCALBASE})
+	(cd ${WRKSRC} && CONDA_PREFIX=${LOCALBASE}; \
+	 ${PYTHON_CMD} -m bindgen -n ${MAKE_JOBS_NUMBER} \
+	 --libclang=${LOCALBASE}/llvm90/lib/libclang.so \
+	 --include=${LOCALBASE}/include \
+	 --include=${LOCALBASE}/include/vtk-${VTKVER} \
+	 all ${CONFIG_FILE})
 
 do-install:
 	@${MKDIR} ${STAGEDIR}${PYTHON_SITELIBDIR}/
-	${INSTALL_LIB} ${BUILD_WRKSRC}/OCP.so ${STAGEDIR}${PYTHON_SITELIBDIR}
+	${INSTALL_LIB} ${BUILD_WRKSRC}/OCP.cpython-${PYTHON_VER:S/.//}.so ${STAGEDIR}${PYTHON_SITELIBDIR}/OCP.so
 
 .include <bsd.port.mk>
diff --git a/cad/py-ocp/distinfo b/cad/py-ocp/distinfo
index 01fc842b7de9..0447d9128285 100644
--- a/cad/py-ocp/distinfo
+++ b/cad/py-ocp/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1595488164
-SHA256 (OCP_src_Linux.zip) = 126953106d7e52d3ec6c606ff3a34ecde5c6598899ab0c31279e185771304192
-SIZE (OCP_src_Linux.zip) = 50341316
+TIMESTAMP = 1635415821
+SHA256 (CadQuery-OCP-7.5.2-52c15d8_GH0.tar.gz) = 9919ebcad16077d311e3be2b943e1290e05ac66e0aa992fa5a8836b39d03187a
+SIZE (CadQuery-OCP-7.5.2-52c15d8_GH0.tar.gz) = 5571420
diff --git a/cad/py-ocp/files/cpatch-OCCT_OpenGl__HaltonSampler.hxx b/cad/py-ocp/files/cpatch-OCCT_OpenGl__HaltonSampler.hxx
new file mode 100644
index 000000000000..7fe4fee18e03
--- /dev/null
+++ b/cad/py-ocp/files/cpatch-OCCT_OpenGl__HaltonSampler.hxx
@@ -0,0 +1,11 @@
+--- OCCT/OpenGl_HaltonSampler.hxx.orig	2020-06-15 08:29:45 UTC
++++ OCCT/OpenGl_HaltonSampler.hxx
+@@ -180,7 +180,7 @@ void OpenGl_HaltonSampler::initRandom (Random_number_g
+     {
+       aPerms[aBase][i] = i;
+     }
+-    std::random_shuffle (aPerms[aBase].begin(), aPerms[aBase].end(), theRand);
++    std::shuffle (aPerms[aBase].begin(), aPerms[aBase].end(), theRand);
+   }
+   initTables (aPerms);
+ }
diff --git a/cad/py-ocp/files/patch-FindOpenCascade.cmake b/cad/py-ocp/files/patch-FindOpenCascade.cmake
index 4010ac534ad6..f8f959dd11ec 100644
--- a/cad/py-ocp/files/patch-FindOpenCascade.cmake
+++ b/cad/py-ocp/files/patch-FindOpenCascade.cmake
@@ -1,12 +1,8 @@
---- FindOpenCascade.cmake.orig	2020-06-12 09:48:04 UTC
+--- FindOpenCascade.cmake.orig	2021-04-19 17:00:03 UTC
 +++ FindOpenCascade.cmake
-@@ -69,6 +69,6 @@ foreach( MOD ${OCCT_MODULES})
+@@ -76,4 +76,4 @@ endforeach()
  
- endforeach()
- 
--target_include_directories( OPENCASCADE INTERFACE ${OPENCASCADE_INCLUDE_DIR})
-+target_include_directories( OPENCASCADE INTERFACE OCCT ${OPENCASCADE_INCLUDE_DIR})
+ target_include_directories( OPENCASCADE INTERFACE ${OPENCASCADE_INCLUDE_DIR})
  
 -find_package_handle_standard_args( OPENCASCADE DEFAULT_MSG OPENCASCADE_LIBRARIES OPENCASCADE_INCLUDE_DIR )
-\ No newline at end of file
-+find_package_handle_standard_args( OPENCASCADE DEFAULT_MSG OPENCASCADE_LIBRARIES OPENCASCADE_INCLUDE_DIR )
++find_package_handle_standard_args( OpenCascade DEFAULT_MSG OPENCASCADE_LIBRARIES OPENCASCADE_INCLUDE_DIR )
diff --git a/cad/py-ocp/files/patch-Standard.cpp b/cad/py-ocp/files/patch-Standard.cpp
deleted file mode 100644
index 1d228622f44b..000000000000
--- a/cad/py-ocp/files/patch-Standard.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
---- Standard.cpp.orig	2020-05-29 13:26:32 UTC
-+++ Standard.cpp
-@@ -902,10 +902,10 @@ py::module m = static_cast<py::module>(main_module.att
-           R"#(None)#"  , py::arg("theOne"),  py::arg("theTwo")
-           );
- // ./opencascade/Standard_Time.hxx
--    m.def("IsEqual",
--          (Standard_Boolean (*)( const Standard_Time ,  const Standard_Time  ))  static_cast<Standard_Boolean (*)( const Standard_Time ,  const Standard_Time  )>(&IsEqual),
--          R"#(None)#"  , py::arg("theOne"),  py::arg("theTwo")
--          );
-+//    m.def("IsEqual",
-+//          (Standard_Boolean (*)( const Standard_Time ,  const Standard_Time  ))  static_cast<Standard_Boolean (*)( const Standard_Time ,  const Standard_Time  )>(&IsEqual),
-+//          R"#(None)#"  , py::arg("theOne"),  py::arg("theTwo")
-+//          );
- // ./opencascade/Standard_NullValue.hxx
- // ./opencascade/Standard_DefineHandle.hxx
- // ./opencascade/Standard_Mutex.hxx
diff --git a/cad/py-ocp/files/patch-dump__symbols.py b/cad/py-ocp/files/patch-dump__symbols.py
new file mode 100644
index 000000000000..e0adfcee12f8
--- /dev/null
+++ b/cad/py-ocp/files/patch-dump__symbols.py
@@ -0,0 +1,29 @@
+--- dump_symbols.py.orig	2021-05-24 10:47:30 UTC
++++ dump_symbols.py
+@@ -4,22 +4,15 @@ from path import Path
+ 
+ prefix = sys.argv[1]
+ 
+-prefix_mac = (Path(prefix) / 'lib_mac').expand()
+-libs_mac = prefix_mac.glob('**/libTK*.7.5.1.dylib')
++prefix_freebsd = (Path(prefix) / 'lib').expand()
++libs_freebsd = prefix_freebsd.glob('libTK*.so')
+ 
+-prefix_linux = (Path(prefix) / 'lib_linux').expand()
+-libs_linux = prefix_linux.glob('**/libTK*.so.7.5.1')
++for name,libs in {'freebsd' : libs_freebsd}.items():
+ 
+-prefix_win = (Path(prefix) / 'lib_win').expand()
+-libs_win = prefix_win.glob('**/**/TK*.dll')
+-
+-
+-for name,libs in {'linux' : libs_linux,'mac' : libs_mac, 'win' : libs_win}.items():
+-
+     exported_symbols = []
+     
+     for lib in libs:
+-        p = lief.parse(lib)
++        p = lief.parse(str(lib))
+         
+         if name=='linux':
+             for s in p.exported_symbols:
diff --git a/cad/py-ocp/files/patch-ocp.toml b/cad/py-ocp/files/patch-ocp.toml
new file mode 100644
index 000000000000..dab4dac4ad4d
--- /dev/null
+++ b/cad/py-ocp/files/patch-ocp.toml
@@ -0,0 +1,30 @@
+--- ocp.toml.orig	2021-05-24 10:47:30 UTC
++++ ocp.toml
+@@ -361,6 +361,10 @@ parsing_header = '''#pragma clang diagnostic ignored "
+     modules = ["Xw"]
+     symbols = "symbols_mangled_linux.dat"
+ 
++[FreeBSD]
++    modules = ["Xw"]
++    symbols = "symbols_mangled_freebsd.dat"
++
+ [Windows]
+     modules = ["WNT"]
+     exclude_classes = ["Handle_*"]
+@@ -632,7 +636,8 @@ parsing_header = '''#pragma clang diagnostic ignored "
+ struct NSOpenGLContext {};"""
+         include_body_pre = 'py::class_<NSOpenGLContext>(m, "NSOpenGLContext");'
+         exclude_methods = ["OpenGl_GlCore11::glGetPointerv","OpenGl_RaytraceGeometry::Clear",
+-                           "OpenGl_View::ChangeGraduatedTrihedron","OpenGl_View::LayerList"]
++                           "OpenGl_View::ChangeGraduatedTrihedron","OpenGl_View::LayerList",
++                           "OpenGl_VertexBuffer::unbindFixedColor"]
+         exclude_typedefs = ["OpenGl_SequenceOfLayers","OpenGl_SetterList","OpenGl_MapOfHatchStylesAndIds","OpenGl_MapOfZLayerSettings","OpenGl_IndexedMapOfStructure","OpenGl_MapOfShaderPrograms","OpenGl_IndexedMapOfStructure","OpenGl_LayerSeqIds"]
+         exclude_classes = ["OpenGl_GraduatedTrihedron","OpenGl_LayerList","OpenGl_VariableSetterSelector","OpenGl_RaytraceGeometry"]
+         
+@@ -1089,4 +1094,4 @@ using rapidjson::BasicOStreamWrapper;"""
+         
+     [Modules.IVtkOCC]
+ 
+-        exclude_methods = ["IVtkOCC_ShapePickerAlgo::Pick", "IVtkOCC_ViewerSelector::Pick"]
+\ No newline at end of file
++        exclude_methods = ["IVtkOCC_ShapePickerAlgo::Pick", "IVtkOCC_ViewerSelector::Pick"]
diff --git a/cad/py-ocp/files/patch-opencascade_Standard__Time.hxx b/cad/py-ocp/files/patch-opencascade_Standard__Time.hxx
new file mode 100644
index 000000000000..dcef759748e9
--- /dev/null
+++ b/cad/py-ocp/files/patch-opencascade_Standard__Time.hxx
@@ -0,0 +1,19 @@
+--- opencascade/Standard_Time.hxx.orig	2021-04-14 15:24:46 UTC
++++ opencascade/Standard_Time.hxx
+@@ -26,11 +26,11 @@
+ // ------------------------------------------------------------------
+ // IsEqual : Returns Standard_True if two time values are equal
+ // ------------------------------------------------------------------
+-inline Standard_Boolean IsEqual (const Standard_Time theOne,
+-                                 const Standard_Time theTwo)
+-{
+-  return theOne == theTwo;
+-}
++//inline Standard_Boolean IsEqual (const Standard_Time theOne,
++//                                 const Standard_Time theTwo)
++//{
++//  return theOne == theTwo;
++//}
+ 
+ #endif
+ 
diff --git a/cad/py-ocp/files/patch-templates_CMakeLists.j2 b/cad/py-ocp/files/patch-templates_CMakeLists.j2
new file mode 100644
index 000000000000..48a175effe63
--- /dev/null
+++ b/cad/py-ocp/files/patch-templates_CMakeLists.j2
@@ -0,0 +1,19 @@
+--- templates/CMakeLists.j2.orig	2021-03-03 18:11:14 UTC
++++ templates/CMakeLists.j2
+@@ -17,7 +17,8 @@ endif()
+ 
+ find_package( pybind11 REQUIRED )
+ find_package( OpenCascade REQUIRED COMPONENTS OPENCASCADE )
+ find_package( VTK 9.0 REQUIRED COMPONENTS WrappingPythonCore RenderingCore CommonDataModel CommonExecutionModel)
++find_package(OpenGL REQUIRED COMPONENTS OpenGL )
+ 
+ #clang-cl related workaround
+ if(WIN32)
+@@ -30,6 +31,7 @@ file( GLOB CPP_FILES ${PROJECT_SOURCE_DIR}/*.cpp )
+ add_library( {{ name }} MODULE ${CPP_FILES} )
+ 
+ target_link_libraries( {{ name }} PRIVATE OPENCASCADE pybind11::pybind11 VTK::WrappingPythonCore VTK::RenderingCore VTK::CommonDataModel VTK::CommonExecutionModel)
++target_link_libraries( {{ name }} PRIVATE ${OPENGL_gl_LIBRARY} )
+ set_target_properties( {{ name }}
+                        PROPERTIES
+                        CXX_STANDARD 17
diff --git a/cad/py-ocp/pkg-message b/cad/py-ocp/pkg-message
new file mode 100644
index 000000000000..7600ab2eba83
--- /dev/null
+++ b/cad/py-ocp/pkg-message
@@ -0,0 +1,4 @@
+It is essential for the correct operation of this library for the
+cad/opencascade port to be built with the VIS option disabled. Unfortunately
+the current default is enabled, so if missing symbols are encounted, then
+it will be necessary to rebuild cad/opencascade without the VIS option.