I am trying to build Python3.12 from source as a non-root user on Linux. I am aware that it need openssl (for pip) and the libffi headers, which I have attempted to build from source as well. Doing this I end up with the following errors in the make log:
[ERROR] _ctypes failed to import: libffi.so.8: cannot open shared object file: No such file or directory [ERROR] _hashlib failed to import: libcrypto.so.3: cannot open shared object file: No such file or directory [ERROR] _ssl failed to import: libssl.so.3: cannot open shared object file: No such file or directory The following modules are *disabled* in configure script: _sqlite3 The necessary bits to build these optional modules were not found: _curses _curses_panel _dbm _gdbm _lzma _tkinter nis readline To find the necessary bits, look in configure.ac and config.log. Following modules built successfully but were removed because they could not be imported: _ctypes _hashlib _ssl Could not build the ssl module! Python requires a OpenSSL 1.1.1 or newer Checked 111 modules (31 built-in, 67 shared, 1 n/a on linux-x86_64, 1 disabled, 8 missing, 3 failed on import) I would like to be able to (among other) use the ctype module, so this is sub-optimal.
The steps I took
Step 1: build libffi from source. I followed these instructions and included --prefix=$HOME/.local (since that is where I would like to install everything locally) when configuring the make file. (./configure --prefix=$HOME/.local).
Step 2: build openssl from source. I (more or less) followed these instructions. I again included --prefix=$HOME/.local during configuration.
By now, my .local folder looks something like this:
├── bin │ ├── c_rehash │ └── openssl ├── include │ ├── ffi.h │ ├── ffitarget.h │ └── openssl │ └── <loads of header files>.h ├── lib │ ├── libcrypto.so │ ├── libffi.so │ ├── libssl.so │ └── pkgconfig │ └── libffi.pc ├── lib64 │ ├── cmake │ │ └── OpenSSL │ │ ├── OpenSSLConfig.cmake │ │ └── OpenSSLConfigVersion.cmake │ ├── engines-3 │ │ ├── afalg.so │ │ ├── capi.so │ │ ├── loader_attic.so │ │ └── padlock.so │ ├── libcrypto.a │ ├── libcrypto.so │ ├── libcrypto.so.3 │ ├── libffi.a │ ├── libffi.la │ ├── libffi.so │ ├── libffi.so.8 │ ├── libffi.so.8.1.3 │ ├── libssl.a │ ├── libssl.so │ ├── libssl.so.3 │ ├── ossl-modules │ │ └── legacy.so │ └── pkgconfig │ ├── libcrypto.pc │ ├── libssl.pc │ └── openssl.pc ├── share │ ├── ... ... Step 3: build Python3.12 from source. Here I also included the take-aways from this post and tried to include all the correct flag etc. My suspicion is that it goes wrong here.
To configure:
./configure --enable-optimizations --with-lto --with-openssl=$HOME/.local \ --prefix=$HOME/.local/ \ LIBFFI_INCLUDEDIR=$HOME/.local/include \ LDFLAGS="-L$HOME/.local/lib/../lib64 -L$HOME/.local/lib64" \ CFLAGS="-I$HOME/.local/include" This resulted (after lots of tries) in some positive outputs for the checks to libiff and openssl files.
To build (for some reason repeating the include dir, see earlier link):
make LIBFFI_INCLUDEDIR=$HOME/.local/include This executing of make then results in the errors show at the start of the post.
(Note: New here, not a Linux-wizard)
man ld.so, you need to tell the dynamic loader where to find the .so file, so setLD_LIBRARY_PATH.