google / or-tools

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

Python binding fails to build: error: invalid command 'bdist_wheel' #2812

Closed yurivict closed 2 years ago

yurivict commented 2 years ago

What version of OR-Tools and what language are you using? Version: 9.1 Language: Python

===>  Building for py38-or-tools-9.1
[  2% 6/39] cd /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/python && /usr/local/bin/cmake -E copy ./Release/setup.py setup.py && /usr/local/bin/cmake -E remove_directory dist && /usr/local/bin/cmake -E make_directory ortools/.libs && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/libortools.so.9 ortools/.libs && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapinit.so ortools/init && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapknapsack_solver.so ortools/algorithms && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapgraph.so ortools/graph && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapcp.so ortools/constraint_solver && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywraplp.so ortools/linear_solver && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapsat.so ortools/sat && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywraprcpsp.so ortools/scheduling && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_sorted_interval_list.so ortools/util && /usr/local/bin/python3.10 setup.py bdist_wheel
FAILED: CMakeFiles/python_package python/ortools python/build python/dist python/ortools.egg-info 
cd /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/python && /usr/local/bin/cmake -E copy ./Release/setup.py setup.py && /usr/local/bin/cmake -E remove_directory dist && /usr/local/bin/cmake -E make_directory ortools/.libs && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/libortools.so.9 ortools/.libs && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapinit.so ortools/init && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapknapsack_solver.so ortools/algorithms && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapgraph.so ortools/graph && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapcp.so ortools/constraint_solver && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywraplp.so ortools/linear_solver && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywrapsat.so ortools/sat && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_pywraprcpsp.so ortools/scheduling && /usr/local/bin/cmake -E copy /disk-samsung/freebsd-ports/math/py-or-tools/work-py38/or-tools-9.1/lib/_sorted_interval_list.so ortools/util && /usr/local/bin/python3.10 setup.py bdist_wheel
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'bdist_wheel'

OS: FreeBSD 13

lperron commented 2 years ago

The wheel package must be installed.

Mizux commented 2 years ago

https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/cmake/python.cmake#L159-L161 and https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/cmake/python.cmake#L29-L48

notice the install --user so your user site package must be in path etc... python -m site --user-site

Mizux commented 2 years ago

Also In your trace I can see py38-or-tools-9.1 so I suppose you want use python3.8 ? but the end of the command line we could see /usr/local/bin/python3.10 setup.py bdist_wheel

note1: To find Python 3 we use the cmake built-in module FindPython3 -> https://cmake.org/cmake/help/latest/module/FindPython3.html (which search for the most recent version)

Python3_FIND_STRATEGY New in version 3.15. This variable defines how lookup will be done. The Python3_FIND_STRATEGY variable can be set to one of the following: VERSION: Try to find the most recent version in all specified locations. This is the default if policy CMP0094 is undefined or set to OLD. LOCATION: Stops lookup as soon as a version satisfying version constraints is founded. This is the default if policy CMP0094 is set to NEW.

you should take a look at: https://cmake.org/cmake/help/latest/module/FindPython3.html#artifacts-specification

note2: on manylinux each python install is separated so we use -DPython3_ROOT_DIR="$1" https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/tools/docker/python/build-manylinux.sh#L40-L47 ... https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/tools/docker/python/build-manylinux.sh#L65-L66

yurivict commented 2 years ago

There was confusion with multiple python versions. wheel was installed for python-3.8 and or-tools was discovering python-3.10.