Makefile for python
This commit is contained in:
@@ -354,10 +354,14 @@ techtalk_scheduling: $(BIN_DIR)/techtalk_scheduling$(CLR_EXE_SUFFIX).exe
|
||||
|
||||
# Build and compile custome CP examples
|
||||
|
||||
ccs: $(BIN_DIR)/$(CLR_DLL_NAME).dll $(EX_DIR)/csharp/$(EX).cs
|
||||
|
||||
|
||||
$(BIN_DIR)$S$(EX)$(CLR_EXE_SUFFIX).exe: $(BIN_DIR)/$(CLR_DLL_NAME).dll $(EX_DIR)/csharp/$(EX).cs
|
||||
$(CSC) $(SIGNING_FLAGS) /target:exe /out:$(BIN_DIR)$S$(EX)$(CLR_EXE_SUFFIX).exe /platform:$(NETPLATFORM) /lib:$(BIN_DIR) /r:$(CLR_DLL_NAME).dll /r:Google.Protobuf.dll $(EX_DIR)$Scsharp$S$(EX).cs
|
||||
|
||||
rcs: ccs
|
||||
csc: $(BIN_DIR)$S$(EX)$(CLR_EXE_SUFFIX).exe
|
||||
|
||||
rcs: $(BIN_DIR)$S$(EX)$(CLR_EXE_SUFFIX).exe
|
||||
$(MONO) $(BIN_DIR)$S$(EX)$(CLR_EXE_SUFFIX).exe $(ARGS)
|
||||
|
||||
# C# Fz support
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Main target
|
||||
java: javaortools
|
||||
|
||||
.PHONY: java javaortools rjava cjava
|
||||
|
||||
# Clean target
|
||||
clean_java:
|
||||
-$(DEL) $(LIB_DIR)$S$(LIB_PREFIX)jni*.$(JNI_LIB_EXT)
|
||||
@@ -371,5 +373,5 @@ $(OBJ_DIR)/com/google/ortools/samples/$(EX).class: javaortools $(EX_DIR)/com/goo
|
||||
|
||||
cjava: $(OBJ_DIR)/com/google/ortools/samples/$(EX).class
|
||||
|
||||
rjava: $(OBJ_DIR)/com/google/ortools/samples/$(EX).class javaortools
|
||||
rjava: cjava javaortools
|
||||
$(JAVA_BIN) -Djava.library.path=$(LIB_DIR) -cp $(OBJ_DIR)$(CPSEP)$(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar com.google.ortools.samples.$(EX) $(ARGS)
|
||||
|
||||
@@ -204,13 +204,12 @@ endif
|
||||
|
||||
# Run a single example
|
||||
|
||||
rpy: $(LIB_DIR)/_pywraplp.$(SWIG_LIB_SUFFIX) $(LIB_DIR)/_pywrapcp.$(SWIG_LIB_SUFFIX) $(LIB_DIR)/_pywrapgraph.$(SWIG_LIB_SUFFIX) $(LIB_DIR)/_pywrapknapsack_solver.$(SWIG_LIB_SUFFIX) $(EX_DIR)/python/$(EX).py
|
||||
rpy: $(LIB_DIR)/_pywraplp.$(SWIG_LIB_SUFFIX) $(LIB_DIR)/_pywrapcp.$(SWIG_LIB_SUFFIX) $(LIB_DIR)/_pywrapgraph.$(SWIG_LIB_SUFFIX) $(LIB_DIR)/_pywrapknapsack_solver.$(SWIG_LIB_SUFFIX) $(EX)
|
||||
@echo Running $(EX)
|
||||
ifeq ($(SYSTEM),win)
|
||||
@echo Running python$S$(EX).py
|
||||
@set PYTHONPATH=$(OR_TOOLS_PYTHONPATH) && $(WINDOWS_PYTHON_PATH)$Spython $(EX_DIR)/python$S$(EX).py $(ARGS)
|
||||
@set PYTHONPATH=$(OR_TOOLS_PYTHONPATH) && $(WINDOWS_PYTHON_PATH)$Spython $(EX) $(ARGS)
|
||||
else
|
||||
@echo Running python$S$(EX).py
|
||||
@PYTHONPATH=$(OR_TOOLS_PYTHONPATH) python$(PYTHON_VERSION) $(EX_DIR)/python$S$(EX).py $(ARGS)
|
||||
@PYTHONPATH=$(OR_TOOLS_PYTHONPATH) python$(PYTHON_VERSION) $(EX) $(ARGS)
|
||||
endif
|
||||
|
||||
|
||||
@@ -225,6 +224,7 @@ python_examples_archive:
|
||||
$(MKDIR) temp$Sortools_examples$Sexamples$Sdata
|
||||
$(COPY) examples$Spython$S*.py temp$Sortools_examples$Sexamples$Spython
|
||||
$(COPY) tools$SREADME.examples.python temp$Sortools_examples$SREADME.txt
|
||||
$(COPY) tools$SMakefile.python temp$Sortools_examples$SMakefile
|
||||
$(COPY) LICENSE-2.0.txt temp$Sortools_examples
|
||||
$(COPY) tools$Ssetup_data.py temp$Sortools_examples$Ssetup.py
|
||||
$(SED) -i -e 's/VVVV/$(OR_TOOLS_VERSION)/' temp$Sortools_examples$Ssetup.py
|
||||
|
||||
@@ -23,9 +23,13 @@ or-tools/
|
||||
|
||||
|
||||
To install the package, please run:
|
||||
python setup.py install --user
|
||||
make install
|
||||
or
|
||||
python setup.py install --user
|
||||
|
||||
Then check the dependecies by running :
|
||||
This will check the ortools module dependecies. You still can do it by running:
|
||||
make check
|
||||
or
|
||||
python check_python_deps.py
|
||||
|
||||
Once this is done, you can run the samples in the examples/ directory.
|
||||
|
||||
@@ -1,26 +1,8 @@
|
||||
import sys
|
||||
from six import print_
|
||||
import inspect
|
||||
from sys import executable
|
||||
|
||||
current_ortools_version = "VVVV"
|
||||
minimum_protobuf_version = "PROTOBUF_TAG"
|
||||
print_ ("Python path : " + sys.executable)
|
||||
print_ ("Python version : " + sys.version + "\n")
|
||||
|
||||
def notinstalled(modulename):
|
||||
return modulename + """ is not installed for \"""" + sys.executable + """\"
|
||||
Please run \"easy_install --user """ + modulename + """\""""
|
||||
|
||||
def wrong_version(module, modulename, required_version):
|
||||
return """
|
||||
You're using an old version of """ + modulename + """ : """ + inspect.getfile(module) + """
|
||||
The minimum required version is : """ + required_version + """
|
||||
Please run \"""" + str(sys.executable) + """ setup.py install --user\" to upgrade
|
||||
If the problem persits, then """ + inspect.getfile(module) + """ is binding the newely installed version of """ + modulename + """
|
||||
You should either remove it, or use PYTHONPATH to manage your sys.path. If you decide to use PYTHONPATH, please do it to run the ortools examples as well.
|
||||
Please check https://docs.python.org/3/tutorial/modules.html#the-module-search-path from more information."""
|
||||
|
||||
from sys import version_info
|
||||
import logging, sys
|
||||
|
||||
#try to import setuptools
|
||||
try:
|
||||
@@ -35,37 +17,80 @@ make sure you use \"""" + sys.executable + """\" during the installation""")
|
||||
|
||||
from pkg_resources import parse_version
|
||||
|
||||
#try to import ortools
|
||||
try:
|
||||
import ortools
|
||||
except ImportError:
|
||||
print_ (notinstalled("ortools"))
|
||||
raise SystemExit
|
||||
|
||||
#try to import protobuf
|
||||
try:
|
||||
import google.protobuf
|
||||
except ImportError:
|
||||
print_ (notinstalled("protobuf"))
|
||||
raise SystemExit
|
||||
current_ortools_version = "VVVV"
|
||||
minimum_protobuf_version = "PROTOBUF_TAG"
|
||||
|
||||
def notinstalled(modulename):
|
||||
return modulename + """ is not installed for \"""" + sys.executable + """\"
|
||||
Please run \"""" + str(sys.executable) + """ setup.py install --user\""""
|
||||
|
||||
def wrong_version(module, modulename, minimum_version, installed_version):
|
||||
return """
|
||||
You are using """ + modulename + """-""" + installed_version + """ : """ + inspect.getfile(module) + """
|
||||
The minimum required version is : """ + minimum_version + """
|
||||
Please run \"""" + str(sys.executable) + """ setup.py install --user\" to upgrade
|
||||
If the problem persits, then """ + inspect.getfile(module) + """ is binding the newely installed version of """ + modulename + """
|
||||
You should either remove it, or use PYTHONPATH to manage your sys.path. If you decide to use PYTHONPATH, do it to run the ortools examples as well.
|
||||
Check https://docs.python.org/3/tutorial/modules.html#the-module-search-path from more information."""
|
||||
|
||||
if __name__ == '__main__':
|
||||
from optparse import OptionParser
|
||||
parser = OptionParser('Test logging')
|
||||
parser.add_option('-l','--log',type='string',help='Available levels are CRITICAL (3), ERROR (2), WARNING (1), INFO (0), DEBUG (-1)',default='INFO')
|
||||
options,args = parser.parse_args()
|
||||
|
||||
try:
|
||||
loglevel = getattr(logging,options.log.upper())
|
||||
except AttributeError:
|
||||
loglevel = {3:logging.CRITICAL,
|
||||
2:logging.ERROR,
|
||||
1:logging.WARNING,
|
||||
0:logging.INFO,
|
||||
-1:logging.DEBUG,
|
||||
}[int(options.log)]
|
||||
|
||||
logging.basicConfig(stream=sys.stdout, level=loglevel)
|
||||
|
||||
logging.info("Python path : " + sys.executable)
|
||||
logging.info("Python version : " + sys.version + "\n")
|
||||
|
||||
if version_info[0] >= 3:
|
||||
ortools_name = "py3-ortools"
|
||||
else:
|
||||
ortools_name = "ortools"
|
||||
#try to import ortools
|
||||
try:
|
||||
import ortools
|
||||
except ImportError:
|
||||
logging.error (notinstalled(ortools_name))
|
||||
raise SystemExit
|
||||
|
||||
#try to import protobuf
|
||||
try:
|
||||
import google.protobuf
|
||||
except ImportError:
|
||||
logging.error (notinstalled("protobuf"))
|
||||
raise SystemExit
|
||||
|
||||
#check ortools version
|
||||
try:
|
||||
if parse_version(current_ortools_version) > parse_version(ortools.__version__):
|
||||
raise Exception
|
||||
logging.info("or-tools version : " + ortools.__version__)
|
||||
logging.info(inspect.getfile(ortools) + "\n")
|
||||
except (AttributeError, Exception):
|
||||
logging.error (wrong_version(ortools, ortools_name, current_ortools_version, ortools.__version__))
|
||||
raise SystemExit
|
||||
|
||||
#check protobuf version
|
||||
try:
|
||||
if parse_version(minimum_protobuf_version) > parse_version(google.protobuf.__version__):
|
||||
raise Exception
|
||||
logging.info("protobuf version : " + google.protobuf.__version__)
|
||||
logging.info(inspect.getfile(google.protobuf) + "\n")
|
||||
except (AttributeError, Exception):
|
||||
logging.error(wrong_version(google.protobuf, "protobuf", minimum_protobuf_version, google.protobuf.__version__))
|
||||
raise SystemExit
|
||||
|
||||
#check ortools version
|
||||
try:
|
||||
if parse_version(current_ortools_version) > parse_version(ortools.__version__):
|
||||
raise Exception
|
||||
print_ ("or-tools version : " + ortools.__version__)
|
||||
print_ (inspect.getfile(ortools) + "\n")
|
||||
except (AttributeError, Exception):
|
||||
print_ (wrong_version(ortools, "ortools", current_ortools_version))
|
||||
raise SystemExit
|
||||
|
||||
#check protobuf version
|
||||
#print_(cmp(minimum_protobuf_version, google.protobuf.__version__) + "\n")
|
||||
try:
|
||||
if parse_version(minimum_protobuf_version) > parse_version(google.protobuf.__version__):
|
||||
raise Exception
|
||||
print_ ("protobuf version : " + google.protobuf.__version__)
|
||||
print_ (inspect.getfile(google.protobuf) + "\n")
|
||||
except (AttributeError, Exception):
|
||||
print_ (wrong_version(google.protobuf, "protobuf", minimum_protobuf_version))
|
||||
raise SystemExit
|
||||
|
||||
Reference in New Issue
Block a user