pythonlinuxmeson-buildmesa

Meson ERROR: ['/usr/local/bin/python3']> is not a valid python or it is missing distutils


Here's the full log of the meson log: Link to Google Drive

My copy of python3 Python 3.12.0 (main, Oct 16 2023, 16:36:20) [GCC 11.4.0] on linux was compiled by myself (i followed the instructions), but it didn't had the ssl and distutils (python3-distutils, python3-openssl, libssl and openssl is installed from apt) modules. (I'm not sure whether or not is this the problem with my bad luck, because none of compilations i've done were successful nor without an error)

I tried to compile Mesa (the 3D Rendering library) but this is what i've got:

sudo meson setup builddir/

The Meson build system
Version: 0.61.2
Source dir: /home/MyName/PycharmProjects/Rooms3D/mesa-23.3.0-rc1
Build dir: /home/MyName/PycharmProjects/Rooms3D/mesa-23.3.0-rc1/builddir
Build type: native build
Project name: mesa
Project version: 23.3.0-rc1
C compiler for the host machine: ccache cc (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C linker for the host machine: cc ld.bfd 2.38
C++ compiler for the host machine: ccache c++ (gcc 11.4.0 "c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C++ linker for the host machine: c++ ld.bfd 2.38
Host machine cpu family: x86_64
Host machine cpu: x86_64
Checking if "-mtls-dialect=gnu2" runs: YES
Checking if "split TLSDESC" : links: YES 
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Found CMake: /usr/bin/cmake (3.22.1)
Run-time dependency vdpau found: NO (tried pkgconfig and cmake)
Program glslangValidator found: YES (/usr/bin/glslangValidator)
Run-time dependency libomxil-bellagio found: NO (tried pkgconfig and cmake)
Run-time dependency libtizonia found: NO (tried pkgconfig and cmake)
Run-time dependency libtizplatform found: NO (tried pkgconfig and cmake)
Run-time dependency tizilheaders found: NO (tried pkgconfig and cmake)
Run-time dependency libva found: NO (tried pkgconfig and cmake)
Program python3 found: YES (/usr/local/bin/python3)

meson.build:869:0: ERROR: <PythonExternalProgram 'python3' -> ['/usr/local/bin/python3']> is not a valid python or it is missing distutils

After seeing this error, i remembered that this might be because of my compiled python3 because it didn't had distutils in order for meson to work. I tried to reinstall python3 and components through Synaptic, but it didn't do it.
I also tried to reinstall it through apt reinstall python3 from which i instantly regretted, because it deleted every dependencies.


Solution

  • Fixing Python3

    To fix python3, you need to download and compile OpenSSL, make sure the configurator knows where is OpenSSL (our compiled one) at, and then compile it. Source: Building Python 3.7.1 - SSL module failed

    Fixing Meson error

    That won't help with Meson error though. To fix the problem with meson, we don't install distutils (If our python3 (not a typo) version is higher than 3.11, instead, we need to go to meson.build file and find (CTRL + F)

    import('python').find_installation('python3

    and replace python3 with python3.11 (The exclusion of space between python and 3.11 is not a typo) or whatever the version you want to use (Before you execute the meson again, make sure you installed the desired version through a terminal command:

    sudo apt install python3.11

    Now, we can run Meson. Make sure you installed the packages needed to compile.