From 1dbd92ca65cd03be00045e2213a126d5e6da9efd Mon Sep 17 00:00:00 2001 From: Driss Lahlou Date: Tue, 24 Jan 2017 19:33:22 +0100 Subject: [PATCH] support multi versions of python in release --- Makefile | 2 +- makefiles/Makefile.python.mk | 106 +++++++++++++------------ tools/fix_python_libraries_on_linux.sh | 8 +- tools/fix_python_libraries_on_mac.sh | 11 +-- 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/Makefile b/Makefile index 84386fac19..c7661c4386 100755 --- a/Makefile +++ b/Makefile @@ -67,4 +67,4 @@ ifeq ($(wildcard dependencies/install/include/gflags/gflags.h),) @echo "One of the third party files was not found! did you run 'make third_party'?" && exit 1 endif -print-% : ; @echo $* = $($*) \ No newline at end of file +print-% : ; @echo $* = $($*) diff --git a/makefiles/Makefile.python.mk b/makefiles/Makefile.python.mk index b57f9c1103..dc440790d5 100755 --- a/makefiles/Makefile.python.mk +++ b/makefiles/Makefile.python.mk @@ -1,4 +1,4 @@ -.PHONY : install_python_modules +.PHONY : python install_python_modules pypi_archive pyinit pycp pyalgorithms pygraph pylp # Python support using SWIG @@ -247,63 +247,69 @@ else cd temp && tar -c -v -z --no-same-owner -f ../or-tools_python_examples_v$(OR_TOOLS_VERSION).tar.gz ortools_examples endif -pypi_archive: python $(PATCHELF) - -$(DELREC) temp - $(MKDIR) temp - $(MKDIR) temp$Sortools - $(MKDIR) temp$Sortools$Sortools - $(MKDIR) temp$Sortools$Sortools$Sconstraint_solver - $(MKDIR) temp$Sortools$Sortools$Slinear_solver - $(MKDIR) temp$Sortools$Sortools$Sgraph - $(MKDIR) temp$Sortools$Sortools$Salgorithms - $(MKDIR) temp$Sortools$Sdummy - $(COPY) src$Sgen$Sortools$Sconstraint_solver$S*.py temp$Sortools$Sortools$Sconstraint_solver - $(COPY) src$Sortools$Slinear_solver$S*.py temp$Sortools$Sortools$Slinear_solver - $(COPY) src$Sgen$Sortools$Slinear_solver$S*.py temp$Sortools$Sortools$Slinear_solver - $(COPY) src$Sgen$Sortools$Sgraph$Spywrapgraph.py temp$Sortools$Sortools$Sgraph - $(COPY) src$Sgen$Sortools$Salgorithms$Spywrapknapsack_solver.py temp$Sortools$Sortools$Salgorithms - $(COPY) $(GEN_DIR)$Sortools$S__init__.py temp$Sortools$Sortools$S__init__.py - $(SED) -i -e 's/VVVV/$(OR_TOOLS_VERSION)/' temp$Sortools$Sortools$S__init__.py - $(TOUCH) temp$Sortools$Sortools$Sconstraint_solver$S__init__.py - $(TOUCH) temp$Sortools$Sortools$Slinear_solver$S__init__.py - $(TOUCH) temp$Sortools$Sortools$Sgraph$S__init__.py - $(TOUCH) temp$Sortools$Sortools$Salgorithms$S__init__.py - $(COPY) tools$Sdummy_ortools_dependency.cc temp$Sortools$Sdummy - $(COPY) tools$SREADME.pypi temp$Sortools$SREADME.txt - $(COPY) LICENSE-2.0.txt temp$Sortools - $(COPY) tools$Ssetup.py temp$Sortools +PYPI_ARCHIVE_TEMP_DIR = temp-python$(PYTHON_VERSION) + +OR_TOOLS_PYTHON_GEN_SCRIPTS = $(wildcard src/gen/ortools/*/*) + +pypi_archive: python $(PYPI_ARCHIVE_TEMP_DIR) + +$(PYPI_ARCHIVE_TEMP_DIR) : $(OR_TOOLS_PYTHON_GEN_SCRIPTS) + -$(DELREC) $(PYPI_ARCHIVE_TEMP_DIR) + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR) + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sconstraint_solver + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Slinear_solver + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sgraph + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Salgorithms + $(MKDIR) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sdummy + $(COPY) src$Sgen$Sortools$Sconstraint_solver$S*.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sconstraint_solver + $(COPY) src$Sortools$Slinear_solver$S*.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Slinear_solver + $(COPY) src$Sgen$Sortools$Slinear_solver$S*.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Slinear_solver + $(COPY) src$Sgen$Sortools$Sgraph$Spywrapgraph.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sgraph + $(COPY) src$Sgen$Sortools$Salgorithms$Spywrapknapsack_solver.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Salgorithms + $(COPY) $(GEN_DIR)$Sortools$S__init__.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$S__init__.py + $(SED) -i -e 's/VVVV/$(OR_TOOLS_VERSION)/' $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$S__init__.py + $(TOUCH) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sconstraint_solver$S__init__.py + $(TOUCH) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Slinear_solver$S__init__.py + $(TOUCH) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sgraph$S__init__.py + $(TOUCH) $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Salgorithms$S__init__.py + $(COPY) tools$Sdummy_ortools_dependency.cc $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sdummy + $(COPY) tools$SREADME.pypi $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$SREADME.txt + $(COPY) LICENSE-2.0.txt $(PYPI_ARCHIVE_TEMP_DIR)$Sortools + $(COPY) tools$Ssetup.py $(PYPI_ARCHIVE_TEMP_DIR)$Sortools ifeq ($(PYTHON3),true) - $(SED) -i -e 's/ORTOOLS_PYTHON_VERSION/py3-ortools/' temp$Sortools$Ssetup.py + $(SED) -i -e 's/ORTOOLS_PYTHON_VERSION/py3-ortools/' $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Ssetup.py else - $(SED) -i -e 's/ORTOOLS_PYTHON_VERSION/ortools/' temp$Sortools$Ssetup.py + $(SED) -i -e 's/ORTOOLS_PYTHON_VERSION/ortools/' $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Ssetup.py endif - $(SED) -i -e 's/VVVV/$(OR_TOOLS_VERSION)/' temp$Sortools$Ssetup.py - $(SED) -i -e 's/PROTOBUF_TAG/$(PROTOBUF_TAG)/' temp$Sortools$Ssetup.py + $(SED) -i -e 's/VVVV/$(OR_TOOLS_VERSION)/' $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Ssetup.py + $(SED) -i -e 's/PROTOBUF_TAG/$(PROTOBUF_TAG)/' $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Ssetup.py ifeq ($(SYSTEM),win) - copy src\gen\ortools\constraint_solver\_pywrapcp.pyd temp$Sortools$Sortools$Sconstraint_solver - copy src\gen\ortools\linear_solver\_pywraplp.pyd temp$Sortools$Sortools$Slinear_solver - copy src\gen\ortools\graph\_pywrapgraph.pyd temp$Sortools$Sortools$Sgraph - copy src\gen\ortools\algorithms\_pywrapknapsack_solver.pyd temp$Sortools$Sortools$Salgorithms - $(SED) -i -e 's/\.dll/\.pyd/' temp/ortools/setup.py - $(SED) -i -e '/DELETEWIN/d' temp/ortools/setup.py - $(SED) -i -e 's/DELETEUNIX/ /g' temp/ortools/setup.py - -del temp\ortools\setup.py-e + copy src\gen\ortools\constraint_solver\_pywrapcp.pyd $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sconstraint_solver + copy src\gen\ortools\linear_solver\_pywraplp.pyd $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Slinear_solver + copy src\gen\ortools\graph\_pywrapgraph.pyd $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Sgraph + copy src\gen\ortools\algorithms\_pywrapknapsack_solver.pyd $(PYPI_ARCHIVE_TEMP_DIR)$Sortools$Sortools$Salgorithms + $(SED) -i -e 's/\.dll/\.pyd/' $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py + $(SED) -i -e '/DELETEWIN/d' $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py + $(SED) -i -e 's/DELETEUNIX/ /g' $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py + -del $(PYPI_ARCHIVE_TEMP_DIR)\ortools\setup.py-e else - cp lib/_pywrapcp.$(SWIG_LIB_SUFFIX) temp/ortools/ortools/constraint_solver - cp lib/_pywraplp.$(SWIG_LIB_SUFFIX) temp/ortools/ortools/linear_solver - cp lib/_pywrapgraph.$(SWIG_LIB_SUFFIX) temp/ortools/ortools/graph - cp lib/_pywrapknapsack_solver.$(SWIG_LIB_SUFFIX) temp/ortools/ortools/algorithms - cp lib/libortools.$(LIB_SUFFIX) temp/ortools/ortools - $(SED) -i -e 's/\.dll/\.so/' temp/ortools/setup.py - $(SED) -i -e 's/DELETEWIN //g' temp/ortools/setup.py - $(SED) -i -e '/DELETEUNIX/d' temp/ortools/setup.py - $(SED) -i -e 's/DLL/$(LIB_SUFFIX)/g' temp/ortools/setup.py - -rm temp/ortools/setup.py-e + cp lib/_pywrapcp.$(SWIG_LIB_SUFFIX) $(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/constraint_solver + cp lib/_pywraplp.$(SWIG_LIB_SUFFIX) $(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/linear_solver + cp lib/_pywrapgraph.$(SWIG_LIB_SUFFIX) $(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/graph + cp lib/_pywrapknapsack_solver.$(SWIG_LIB_SUFFIX) $(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/algorithms + cp lib/libortools.$(LIB_SUFFIX) $(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools + $(SED) -i -e 's/\.dll/\.so/' $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py + $(SED) -i -e 's/DELETEWIN //g' $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py + $(SED) -i -e '/DELETEUNIX/d' $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py + $(SED) -i -e 's/DLL/$(LIB_SUFFIX)/g' $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py + -rm $(PYPI_ARCHIVE_TEMP_DIR)/ortools/setup.py-e ifeq ($(PLATFORM),MACOSX) - tools/fix_python_libraries_on_mac.sh + tools/fix_python_libraries_on_mac.sh $(PYPI_ARCHIVE_TEMP_DIR) endif ifeq ($(PLATFORM),LINUX) - tools/fix_python_libraries_on_linux.sh + tools/fix_python_libraries_on_linux.sh $(PYPI_ARCHIVE_TEMP_DIR) endif endif diff --git a/tools/fix_python_libraries_on_linux.sh b/tools/fix_python_libraries_on_linux.sh index 0c35022ede..99d2893e46 100755 --- a/tools/fix_python_libraries_on_linux.sh +++ b/tools/fix_python_libraries_on_linux.sh @@ -1,4 +1,4 @@ -dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' temp/ortools/ortools/constraint_solver/_pywrapcp.so -dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' temp/ortools/ortools/linear_solver/_pywraplp.so -dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' temp/ortools/ortools/algorithms/_pywrapknapsack_solver.so -dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' temp/ortools/ortools/graph/_pywrapgraph.so +dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' $1/ortools/ortools/constraint_solver/_pywrapcp.so +dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' $1/ortools/ortools/linear_solver/_pywraplp.so +dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' $1/ortools/ortools/algorithms/_pywrapknapsack_solver.so +dependencies/install/bin/patchelf --set-rpath '$ORIGIN/../../ortools' $1/ortools/ortools/graph/_pywrapgraph.so diff --git a/tools/fix_python_libraries_on_mac.sh b/tools/fix_python_libraries_on_mac.sh index 68e9335d38..c059827d5c 100755 --- a/tools/fix_python_libraries_on_mac.sh +++ b/tools/fix_python_libraries_on_mac.sh @@ -1,6 +1,7 @@ -export P=`otool -L temp/ortools/ortools/libortools.dylib | grep -v ':' | grep libortools | cut -d '(' -f 1` +export P=`otool -L $1/ortools/ortools/libortools.dylib | grep -v ':' | grep libortools | cut -d '(' -f 1` +echo PYPI_ARCHIVE_TEMP_DIR = $1 echo path to change = $P -install_name_tool -change $P @loader_path/../libortools.dylib temp/ortools/ortools/algorithms/_pywrapknapsack_solver.so -install_name_tool -change $P @loader_path/../libortools.dylib temp/ortools/ortools/constraint_solver/_pywrapcp.so -install_name_tool -change $P @loader_path/../libortools.dylib temp/ortools/ortools/graph/_pywrapgraph.so -install_name_tool -change $P @loader_path/../libortools.dylib temp/ortools/ortools/linear_solver/_pywraplp.so +install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/algorithms/_pywrapknapsack_solver.so +install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/constraint_solver/_pywrapcp.so +install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/graph/_pywrapgraph.so +install_name_tool -change $P @loader_path/../libortools.dylib $1/ortools/ortools/linear_solver/_pywraplp.so