New port: math/py-or-tools: Google's Operations Research tools (Python binding)

This commit is contained in:
Yuri Victorovich 2020-08-03 21:11:02 +00:00
parent c58f43938c
commit 148c8fdf59
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=544109
10 changed files with 159 additions and 0 deletions

View file

@ -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

51
math/py-or-tools/Makefile Normal file
View file

@ -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 <bsd.port.mk>

View file

@ -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

View file

@ -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")

View file

@ -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':['$<TARGET_FILE_NAME:sorted_interval_list>', '*.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',

View file

@ -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

View file

@ -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 <machine/endian.h>
#elif !defined(_MSC_VER)
+#if defined(__FreeBSD__)
+#include <sys/endian.h>
+#else
#include <endian.h>
+#endif
#endif
#include <climits>
#include <cstdio>

View file

@ -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'],

View file

@ -0,0 +1,3 @@
Python bindings for Google Optimization Tools (a.k.a., OR-Tools).
WWW: https://github.com/google/or-tools

View file

@ -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