Adapted from https://docs.python.org/3/using/unix.html?highlight=openssl#custom-openssl I followed the following procedure to build python 3.10 on my centos 7 system.
first I built openssl
2022-05-22 13:57 cd /home/lking/openssl
2022-05-22 13:57 curl -O https://www.openssl.org/source/openssl-1.1.1o.tar.gz
2022-05-22 13:57 tar xzf openssl-1.1.1o.tar.gz
2022-05-24 11:27 cd /home/lking/openssl/openssl-1.1.1o
2022-05-24 11:51 sudo find /etc/ -name openssl.cnf -printf "%h\n"
/etc/pki/tls
2022-05-24 11:27 sudo ./config --prefix=/usr/local/custom-openssl --libdir=lib --openssldir=/etc/pki/tls
2022-05-24 11:28 sudo make clean
2022-05-24 11:29 sudo make -j1 depend
2022-05-24 11:29 sudo make -j > logs/build1.txt
2022-05-24 11:32 sudo make install_sw > logs/install_sw.txt
then I built python 3.10 (I'd downloaded it earlier)
2022-05-15 12:30 cd /home/lking/python
2022-05-15 12:38 wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tgz
2022-05-15 12:39 tar xvf Python-3.10.4.tgz
2022-05-27 15:00 cd /home/lking/python/Python-3.10.4
2022-05-27 15:00 ./configure -C --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto --prefix=/usr/local/python-3.10.4 > logs/configure11.txt
2022-05-27 15:01 sudo make clean
2022-05-27 15:02 sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/custom-openssl/lib make -j > logs/buildlog11.txt
2022-05-27 15:07 sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/custom-openssl/lib make altinstall > logs/altinstall11.txt
Everything seems to build ok, but when I try to import ssl I see an error
2022-05-27 15:09 $ python3.10
Python 3.10.4 (main, May 15 2022, 12:44:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
For reference
2022-05-27 15:10 $ ls /usr/local/python-3.10.4/lib/python3.10/lib-dynload/*_ssl*
/usr/local/python-3.10.4/lib/python3.10/lib-dynload/_ssl.cpython-310-x86_64-linux-gnu.so
2022-05-27 15:11 ]$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
Not sure what other information from the configure and make outputs would be useful. I'm happy to include all or part of the files.