From 148c8fdf5957ee5ebdc252fbd45bb798d9d312b3 Mon Sep 17 00:00:00 2001 From: Yuri Victorovich Date: Mon, 3 Aug 2020 21:11:02 +0000 Subject: [PATCH] New port: math/py-or-tools: Google's Operations Research tools (Python binding) --- math/Makefile | 1 + math/py-or-tools/Makefile | 51 +++++++++++++++++++ math/py-or-tools/distinfo | 3 ++ .../files/patch-cmake_python.cmake | 11 ++++ .../files/patch-ortools_python_setup.py.in | 12 +++++ .../files/patch-ortools_util_fp__utils.h | 11 ++++ .../files/patch-ortools_util_zvector.h | 14 +++++ .../py-or-tools/files/patch-tools_setup.py.in | 13 +++++ math/py-or-tools/pkg-descr | 3 ++ math/py-or-tools/pkg-plist | 40 +++++++++++++++ 10 files changed, 159 insertions(+) create mode 100644 math/py-or-tools/Makefile create mode 100644 math/py-or-tools/distinfo create mode 100644 math/py-or-tools/files/patch-cmake_python.cmake create mode 100644 math/py-or-tools/files/patch-ortools_python_setup.py.in create mode 100644 math/py-or-tools/files/patch-ortools_util_fp__utils.h create mode 100644 math/py-or-tools/files/patch-ortools_util_zvector.h create mode 100644 math/py-or-tools/files/patch-tools_setup.py.in create mode 100644 math/py-or-tools/pkg-descr create mode 100644 math/py-or-tools/pkg-plist diff --git a/math/Makefile b/math/Makefile index 77372a89b1b9..7db541319b20 100644 --- a/math/Makefile +++ b/math/Makefile @@ -789,6 +789,7 @@ SUBDIR += py-numpy SUBDIR += py-nzmath SUBDIR += py-opt-einsum + SUBDIR += py-or-tools SUBDIR += py-osqp SUBDIR += py-pandas SUBDIR += py-pandas-datareader diff --git a/math/py-or-tools/Makefile b/math/py-or-tools/Makefile new file mode 100644 index 000000000000..bff538d4ac30 --- /dev/null +++ b/math/py-or-tools/Makefile @@ -0,0 +1,51 @@ +# $FreeBSD$ + +PORTNAME= or-tools +DISTVERSIONPREFIX= v +DISTVERSION= 7.7 +CATEGORIES= math +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} + +MAINTAINER= yuri@FreeBSD.org +COMMENT= Google's Operations Research tools (Python binding) + +LICENSE= APACHE20 +LICENSE_FILE= ${WRKSRC}/LICENSE-2.0.txt + +PY_DEPENDS= ${PYTHON_PKGNAMEPREFIX}protobuf>0:devel/py-protobuf@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}six>0:devel/py-six@${PY_FLAVOR} +BUILD_DEPENDS= ${PY_DEPENDS} \ + ${PYTHON_PKGNAMEPREFIX}pip>0:devel/py-pip@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}virtualenv>0:devel/py-virtualenv@${PY_FLAVOR} \ + swig:devel/swig +LIB_DEPENDS= libabsl_base.so:devel/abseil \ + libCbc.so:math/cbc \ + libCgl.so:math/cgl \ + libOsiClp.so:math/clp \ + libgflags.so:devel/gflags \ + libglog.so:devel/glog \ + libprotobuf.so:devel/protobuf +RUN_DEPENDS= ${PY_DEPENDS} + +USES= blaslapack cmake compiler:c++11-lang pkgconfig python +USE_GITHUB= yes +GH_ACCOUNT= google + +CMAKE_OFF= BUILD_DEPS INSTALL_BUILD_DEPS BUILD_EXAMPLES +CMAKE_ON= BUILD_PYTHON +CMAKE_ARGS= -DSWIG_EXECUTABLE=${LOCALBASE}/bin/swig -DFREEBSD_PYTHON_VER=${PYTHON_VER} +CONFIGURE_ENV= UNIX_CBC_DIR=${LOCALBASE} UNIX_CLP_DIR=${LOCALBASE} +BUILD_ENV= UNIX_CBC_DIR=${LOCALBASE} UNIX_CLP_DIR=${LOCALBASE} + +post-configure: # https://github.com/google/or-tools/issues/2109 + @${REINPLACE_CMD} -e 's|protobuf::protoc|protoc -I${LOCALBASE}/include| ; s|protobuf$$:$$:protoc||' ${BUILD_WRKSRC}/build.ninja + +do-install: # by default cmake installs the whole or-tools project without the python part, so extract the wheel and install python files manually here + ${MKDIR} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} + cd ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} && \ + unzip ${BUILD_WRKSRC}/python/dist/ortools-${DISTVERSION}.9999-cp${PYTHON_SUFFIX}-cp${PYTHON_SUFFIX}m-freebsd_*.whl && \ + ${RM} -rf ortools-*.dist-info + ${FIND} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} -name "*.so" -o -name "*.so.*" | ${XARGS} ${STRIP_CMD} + +.include diff --git a/math/py-or-tools/distinfo b/math/py-or-tools/distinfo new file mode 100644 index 000000000000..2e3f6de0eaa5 --- /dev/null +++ b/math/py-or-tools/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1596476022 +SHA256 (google-or-tools-v7.7_GH0.tar.gz) = d20eb031ea3f1b75e55e44ae6acdb674ee6fb31e7a56498be32dc83ba9bc13bd +SIZE (google-or-tools-v7.7_GH0.tar.gz) = 184809285 diff --git a/math/py-or-tools/files/patch-cmake_python.cmake b/math/py-or-tools/files/patch-cmake_python.cmake new file mode 100644 index 000000000000..9354ff701736 --- /dev/null +++ b/math/py-or-tools/files/patch-cmake_python.cmake @@ -0,0 +1,11 @@ +--- cmake/python.cmake.orig 2020-08-03 18:30:02 UTC ++++ cmake/python.cmake +@@ -23,7 +23,7 @@ if(UNIX AND NOT APPLE) + endif() + + # Find Python +-find_package(Python REQUIRED COMPONENTS Interpreter Development) ++find_package(Python ${FREEBSD_PYTHON_VER} EXACT REQUIRED COMPONENTS Interpreter Development) + + if(Python_VERSION VERSION_GREATER_EQUAL 3) + list(APPEND CMAKE_SWIG_FLAGS "-py3") diff --git a/math/py-or-tools/files/patch-ortools_python_setup.py.in b/math/py-or-tools/files/patch-ortools_python_setup.py.in new file mode 100644 index 000000000000..3ce7d19f6a76 --- /dev/null +++ b/math/py-or-tools/files/patch-ortools_python_setup.py.in @@ -0,0 +1,12 @@ +--- ortools/python/setup.py.in.orig 2020-08-03 20:33:34 UTC ++++ ortools/python/setup.py.in +@@ -41,7 +41,8 @@ setup( + '@PROJECT_NAME@.util':['$', '*.pyi'], + }, + include_package_data=True, +- install_requires=['protobuf >= 3.12.2', 'six >= 1.10'], ++ #install_requires=['protobuf >= 3.12.2', 'six >= 1.10'], ++ install_requires=[], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', diff --git a/math/py-or-tools/files/patch-ortools_util_fp__utils.h b/math/py-or-tools/files/patch-ortools_util_fp__utils.h new file mode 100644 index 000000000000..d05dce9351ea --- /dev/null +++ b/math/py-or-tools/files/patch-ortools_util_fp__utils.h @@ -0,0 +1,11 @@ +--- ortools/util/fp_utils.h.orig 2020-07-20 23:21:30 UTC ++++ ortools/util/fp_utils.h +@@ -83,6 +83,8 @@ class ScopedFloatingPointEnv { + excepts &= FE_ALL_EXCEPT; + #ifdef __APPLE__ + fenv_.__control &= ~excepts; ++#elif defined(__FreeBSD__) ++ //fesetexceptflag(&fenv_, excepts); + #else // Linux + fenv_.__control_word &= ~excepts; + #endif diff --git a/math/py-or-tools/files/patch-ortools_util_zvector.h b/math/py-or-tools/files/patch-ortools_util_zvector.h new file mode 100644 index 000000000000..d1dcb998caf8 --- /dev/null +++ b/math/py-or-tools/files/patch-ortools_util_zvector.h @@ -0,0 +1,14 @@ +--- ortools/util/zvector.h.orig 2020-07-20 23:36:37 UTC ++++ ortools/util/zvector.h +@@ -17,7 +17,11 @@ + #if defined(__APPLE__) && defined(__GNUC__) + #include + #elif !defined(_MSC_VER) ++#if defined(__FreeBSD__) ++#include ++#else + #include ++#endif + #endif + #include + #include diff --git a/math/py-or-tools/files/patch-tools_setup.py.in b/math/py-or-tools/files/patch-tools_setup.py.in new file mode 100644 index 000000000000..0a2314a73f4f --- /dev/null +++ b/math/py-or-tools/files/patch-tools_setup.py.in @@ -0,0 +1,13 @@ +--- tools/setup.py.in.orig 2020-08-03 20:20:27 UTC ++++ tools/setup.py.in +@@ -46,8 +46,8 @@ setup( + 'ortools.util', + ], + install_requires=[ +- 'protobuf >= 3.12.2', +- 'six >= 1.10', ++ #'protobuf >= 3.12.2', ++ #'six >= 1.10', + ], + package_data={ + 'ortools.constraint_solver' : ['_pywrapcp.dll'], diff --git a/math/py-or-tools/pkg-descr b/math/py-or-tools/pkg-descr new file mode 100644 index 000000000000..129a7b556bbf --- /dev/null +++ b/math/py-or-tools/pkg-descr @@ -0,0 +1,3 @@ +Python bindings for Google Optimization Tools (a.k.a., OR-Tools). + +WWW: https://github.com/google/or-tools diff --git a/math/py-or-tools/pkg-plist b/math/py-or-tools/pkg-plist new file mode 100644 index 000000000000..02e6b366b92e --- /dev/null +++ b/math/py-or-tools/pkg-plist @@ -0,0 +1,40 @@ +%%PYTHON_SITELIBDIR%%/ortools/.libs/libortools.so.7 +%%PYTHON_SITELIBDIR%%/ortools/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/algorithms/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/algorithms/_pywrapknapsack_solver.so +%%PYTHON_SITELIBDIR%%/ortools/algorithms/pywrapknapsack_solver.py +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/_pywrapcp.so +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/assignment_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/pywrapcp.py +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/routing_enums_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/routing_parameters_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/search_limit_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/constraint_solver/solver_parameters_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/data/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/data/_pywraprcpsp.so +%%PYTHON_SITELIBDIR%%/ortools/data/jobshop_scheduling_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/data/pywraprcpsp.py +%%PYTHON_SITELIBDIR%%/ortools/data/rcpsp_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/graph/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/graph/_pywrapgraph.so +%%PYTHON_SITELIBDIR%%/ortools/graph/pywrapgraph.py +%%PYTHON_SITELIBDIR%%/ortools/linear_solver/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/linear_solver/_pywraplp.so +%%PYTHON_SITELIBDIR%%/ortools/linear_solver/linear_solver_natural_api.py +%%PYTHON_SITELIBDIR%%/ortools/linear_solver/linear_solver_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/linear_solver/pywraplp.py +%%PYTHON_SITELIBDIR%%/ortools/sat/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/sat/_pywrapsat.so +%%PYTHON_SITELIBDIR%%/ortools/sat/boolean_problem_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/sat/cp_model_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/sat/python/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/sat/python/cp_model.py +%%PYTHON_SITELIBDIR%%/ortools/sat/python/cp_model_helper.py +%%PYTHON_SITELIBDIR%%/ortools/sat/python/visualization.py +%%PYTHON_SITELIBDIR%%/ortools/sat/pywrapsat.py +%%PYTHON_SITELIBDIR%%/ortools/sat/sat_parameters_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/util/__init__.py +%%PYTHON_SITELIBDIR%%/ortools/util/_sorted_interval_list.so +%%PYTHON_SITELIBDIR%%/ortools/util/optional_boolean_pb2.py +%%PYTHON_SITELIBDIR%%/ortools/util/sorted_interval_list.py