google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.82k stars 2.09k forks source link

Succeed to build but failed to pass the RUN_TESTS when compiling Python with the use of CPLEX on Windows 11 64 bit #4221

Closed lensory closed 2 months ago

lensory commented 2 months ago

What version of OR-Tools and what language are you using? Version: stable (v9.9). Language: Python

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) CPLEX

What operating system (Linux, Windows, ...) and version? Windows 11

What did you do? I'm building OR tools for Python from source to enable the use of CPLEX solver. Steps to reproduce the behavior:

  1. run x64 Native Tools Command Prompt and cd C:\or-tools-stable
  2. chcp 437 (since my system’s default language is Chinese)
  3. cmake -S . -B build -DBUILD_DEPS=ON -DUSE_CPLEX=ON -DCPLEX_ROOT="C:\Program Files\IBM\ILOG\CPLEX_Studio1210" -DBUILD_PYTHON=ON
  4. cmake --build build --config Release --target ALL_BUILD -j 4 -v
  5. The building process succeeds with no errors. However, it can't pass all the RUN_TESTS.

What did you expect to see Successfully built the project and passed all the tests.

What did you see instead? RUN_TESTS failed. Specifically, all the tests concerning Python failed, even for “python_init_version_test”. 1/458 Test #1: python_init_version_test ...................................................***Failed 0.25 sec The detailed information of Test #1, for example, is shown as follows:

1/458 Testing: python_init_version_test
1/458 Test: python_init_version_test
Command: "C:/or-tools-stable/build/python/venv/Scripts/python.exe" "C:/or-tools-stable/build/python/version_test.py"
Directory: C:/or-tools-stable/build
"python_init_version_test" start time: May 09 18:42, China
Output:
----------------------------------------------------------
Traceback (most recent call last):
  File "C:\or-tools-stable\build\python\version_test.py", line 18, in <module>
    from ortools.init.python import init
ImportError: DLL load failed while importing init: 找不到指定的模块。(ModuleNotFoundError: No module named 'init')
<end of output>
Test time =   0.25 sec
----------------------------------------------------------
Test Failed.
"python_init_version_test" end time: May 09 18:42 China
"python_init_version_test" time elapsed: 00:00:00
----------------------------------------------------------

During the compilation of python/python_package, some output information is shown as follows:

       InitializeBuildStatus:
         Creating "x64\Release\python_package\python_package.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
         Touching "x64\Release\python_package\python_package.tlog\unsuccessfulbuild".
       CustomBuild:
         "The build of 'C:\or-tools-stable\build\CMakeFiles\c8bea7353f7334139f036199b482ff55\stub_timestamp.rule' depends on 'C:\OR-TOOLS-STABLE\BUILD\PYTHON\ORTOOLS_TIMESTAMP' which is produced by the build of 'C:\or-tools-stable\ortools\python\setup.py.in'. The items cannot be built in parallel."
         "The build of 'C:\or-tools-stable\build\CMakeFiles\c8bea7353f7334139f036199b482ff55\dist_timestamp.rule' depends on 'C:\OR-TOOLS-STABLE\BUILD\PYTHON\ORTOOLS_TIMESTAMP' which is produced by the build of 'C:\or-tools-stable\ortools\python\setup.py.in'. The items cannot be built in parallel."
         "The build of 'C:\or-tools-stable\build\CMakeFiles\e96bdb2250d0d48c0914b73a8e401e1c\python_package.rule' depends on 'C:\OR-TOOLS-STABLE\BUILD\PYTHON\DIST_TIMESTAMP' which is produced by the build of 'C:\or-tools-stable\build\CMakeFiles\c8bea7353f7334139f036199b482ff55\dist_timestamp.rule'. The items cannot be built in parallel."
         Generating python/ortools_timestamp
         Generating python/pybind11_timestamp
         Building Custom Rule C:/or-tools-stable/CMakeLists.txt
         Generating python/stub_timestamp
         ortools.init. Python.init: Failed to import, skipping
         ortools.algorithms.python.knapsack_solver: Failed to import, skipping
         ortools.graph.python.linear_sum_assignment: Failed to import, skipping
         ortools.graph.python.max_flow: Failed to import, skipping
         ortools.graph.python.min_cost_flow: Failed to import, skipping
         ortools.constraint_solver.pywrapcp: Failed to import, skipping
         ortools.linear_solver.pywraplp: Failed to import, skipping
         ortools.linear_solver. Python.model_builder_helper: Failed to import, skipping
         Processed 1 modules
         Generated .\pybind11_abseil/status.pyi
         ortools.math_opt.core. Python.solver: Failed to import, skipping
         ortools.pdlp. Python.pdlp: Failed to import, skipping
         ortools.sat. Python.swig_helper: Failed to import, skipping
         ortools.scheduling.python.rcpsp: Failed to import, skipping
         ortools.util. Python.sorted_interval_list: Failed to import, skipping
         Generating python/dist_timestamp

Moreover, although Python cannot import init when executing “from ortools.init.python import init”, the obtained “ortools” package (in the directories “C:\or-tools-stable\build\python\venv\Lib\site-packages\ortools\init\python”) does contain the pyd file “init.cp310-win_amd64.pyd”

> dir
    Directory: C:\or-tools-stable\build\python\venv\Lib\site-packages\ortools\init\python

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            2024/5/9    23:17                __pycache__
-a---            2024/5/9    23:17              0 __init__.py
-a---            2024/5/9    23:17       18494976 init.cp310-win_amd64.pyd

The full output files are as follows: DebugBuildLog.txt DebugConfigureLog.txt DebugTestLog.txt

lperron commented 2 months ago

as said before, cplex is community driven only. So we will not fix it, but we will gradly accept pull requests.