[Solved] Build fail, python version

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [Solved] Build fail, python version

Post by looo »

@chennes Today I saw that the conda build for osx-arm is failing because a wrong python version was found:

Code: Select all

-- Found PythonInterp: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 (found suitable version "3.9.6", minimum required is "3")
-- Found PythonLibs: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/libpython3.9.dylib (found suitable version "3.9.6", minimum required is "3")
CMake Error at /Users/lo/mambaforge/conda-bld/debug_1674297974137/_h_env/lib/cmake/Shiboken2-5.15.8/shiboken_helpers.cmake:468 (message):
  The detected Python minor version is not compatible with the Python minor
  version which was used when Shiboken was built.  Consider building shiboken
  with FORCE_LIMITED_API set to '1', so that only the Python major version
  matters.

  Built with: '3.11' Detected: '3.9'
Call Stack (most recent call first):
  /Users/lo/mambaforge/conda-bld/debug_1674297974137/_h_env/lib/cmake/Shiboken2-5.15.8/Shiboken2Config.cpython-311-darwin.cmake:45 (shiboken_check_if_built_and_target_python_are_compatible)
  /Users/lo/mambaforge/conda-bld/debug_1674297974137/_h_env/lib/cmake/Shiboken2-5.15.8/Shiboken2Config.cmake:5 (include)
  cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake:22 (find_package)
  CMakeLists.txt:76 (SetupShibokenAndPyside)
Maybe you can explain what has changed so I can fix the build.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [Solved] Build fail, python version

Post by looo »

ok I found a way that works:
using

-D Python3_EXECUTABLE:FILEPATH="$PYTHON" \

instead of

-D Python_EXECUTABLE:FILEPATH="$PYTHON" \

worked.
drmacro
Veteran
Posts: 8864
Joined: Sun Mar 02, 2014 4:35 pm

Re: [Solved] Build fail, python version

Post by drmacro »

chennes wrote: Fri Jan 27, 2023 1:33 pm
drmacro wrote: Fri Jan 27, 2023 1:06 pm Do you mean when the make directive specified? This is a good question. I would have expected that to override, but I suspect the new merged check doesn't take the directive into account?
The recent tweaks to cMake should move the Python detection to use the standardized find_package architecture. To set the Python location manually, you should set "Python_ROOT_DIR" to the path to your Python installation.
Set Python_ROOT_DIR? as a make directive?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Solved] Build fail, python version

Post by chennes »

Yes - though per @looo's suggestion above, it might by Python3_, rather than Python_.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8864
Joined: Sun Mar 02, 2014 4:35 pm

Re: [Solved] Build fail, python version

Post by drmacro »

Following instructions found in several places about how to install Python 3.10 on Debian 11 I now have the standard system setup for Python 3.9 (i.e 3.9 is found correctly in /usr/...

The system uses 3.9.

After the instructions for 3.10, I now have a complete directory /home/mac/Python-3.10.8

I modified my usual FC build script as follows:

Code: Select all

#!/bin/bash
...
cd ~/freecad-source
git pull
...

cd ~/freecad-daily-base-Py3p10
cmake -DCMAKE_BUILD_TYPE=Release -D Python_EXECUTABLE:FILEPATH=/home/mac/Python-3.10.8 -DBUILD_FLAT_MESH=ON -DOCCT_CMAKE_FALLBACK=1 -DFREECAD_USE_OCC_VARIANT="Official Version" ../freecad-source | tee ~/freecad-daily-base-Py3p10-termout.log

make -j5 | tee -a ~/freecad-daily-base-Py3p10-termout.log
cd ~
...
This does not result in the build using 3.10, it uses the system default 3.9.

The log file indicates:

Code: Select all

==============
Summary report
==============

-- BuildType:           Release
-- Compiler:            /usr/bin/c++ (10.2.1)
-- Flags:               -Wall -Wextra -Wno-write-strings 
-- Standard:            Requires C++17
-- Python:              3.9.2 [/usr/bin/python3.9] [.cpython-39-x86_64-linux-gnu]
...
Are there further make directives required? Or is this just not the way to produce an alternate version of FC that uses Python 3.10?

Hmm...thinking about it, are there also Python modules that aren't going to be found in /home/mac/Python-3.10.8?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Solved] Build fail, python version

Post by chennes »

Try using Python3_EXECUTABLE instead of Python_EXECUTABLE -- we may be explicitly asking for Python 3 in the cmake files, and I don't know how those two variables interact.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
drmacro
Veteran
Posts: 8864
Joined: Sun Mar 02, 2014 4:35 pm

Re: [Solved] Build fail, python version

Post by drmacro »

chennes wrote: Mon Jan 30, 2023 7:40 pm Try using Python3_EXECUTABLE instead of Python_EXECUTABLE -- we may be explicitly asking for Python 3 in the cmake files, and I don't know how those two variables interact.
Phooey, I meant to do that and C-n-P'd the wrong things. :oops:

Well that makes it not handle 3.9, but, still doesn't do 3.10...
I went through a couple iterations, currently the cmake line is:

Code: Select all

cmake -DCMAKE_BUILD_TYPE=Release -D Python3_EXECUTABLE:FILEPATH=/home/mac/Python-3.10.8/python -D Python3_INCLUDE_DIR=/home/mac/Python-3.10.8/Include -DBUILD_FLAT_MESH=ON -DOCCT_CMAKE_FALLBACK=1 -DFREECAD_USE_OCC_VARIANT="Official Version" ../freecad-source | tee ~/freecad-daily-base-Py3p10-termout.log
And the output is:

Code: Select all

CMake Error at /usr/share/cmake-3.18/Modules/FindPython/Support.cmake:606 (file):
  file STRINGS file "/home/mac/Python-3.10.8/Include/pyconfig.h" cannot be
  read.
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPython/Support.cmake:2756 (_python_get_version)
  /usr/share/cmake-3.18/Modules/FindPython3.cmake:389 (include)
  cMake/FreeCAD_Helpers/SetupPython.cmake:117 (find_package)
  CMakeLists.txt:46 (SetupPython)

...
CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find Python3 (missing: Python3_LIBRARIES Development
  Development.Embed) (found version "3.10.8")
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.18/Modules/FindPython/Support.cmake:2984 (find_package_handle_standard_args)
  /usr/share/cmake-3.18/Modules/FindPython3.cmake:389 (include)
  cMake/FreeCAD_Helpers/SetupPython.cmake:117 (find_package)
  CMakeLists.txt:46 (SetupPython)
...
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Solved] Build fail, python version

Post by chennes »

Did you try setting ROOT_DIR instead of EXECUTABLE?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Solved] Build fail, python version

Post by chennes »

drmacro wrote: Mon Jan 30, 2023 8:09 pm

Code: Select all

CMake Error at /usr/share/cmake-3.18/Modules/FindPython/Support.cmake:606 (file):
  file STRINGS file "/home/mac/Python-3.10.8/Include/pyconfig.h" cannot be
  read.
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPython/Support.cmake:2756 (_python_get_version)
  /usr/share/cmake-3.18/Modules/FindPython3.cmake:389 (include)
  cMake/FreeCAD_Helpers/SetupPython.cmake:117 (find_package)
  CMakeLists.txt:46 (SetupPython)
That looks like a broken cMake installation --

Code: Select all

file STRINGS file "/home/mac/Python-3.10.8/Include/pyconfig.h"
seems like it's expecting a file with the literal name

Code: Select all

STRINGS file "/home/mac/Python-3.10.8/Include/pyconfig.h"
which is obviously wrong. Maybe try a newer version of cMake?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply