Try to get python3.10.12

Ubuntu 22.04
There is /usr/bin/openssl file

I want to test locally not in container python 3.10.12
I didn’t find the way to install it. I tried through deadsnakes but it’s not shown in their repository

$apt search 3.10.12
$apt search python3.10 | grep 12

Though there is something on their page but I don’t understand how to use it. To install all deb packages? amd64 build of python3.10 3.10.12-1+focal1 : New Python Versions : “deadsnakes” team

Now I’m trying to compile python from sources. There is a problem with openssl
when I run

$ ./configure -C --with-openssl=/usr/bin/openssl --enable-optimizations --prefix=/usr/bin/python3.10.12
and then

I receive logs with Could not build the ssl module!

Rebuilding with profile guided optimizations:
rm -f profile-clean-stamp
make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction" LDFLAGS_NODIST=""
make[1]: Entering directory '/home/evgeny/Downloads/Python-3.10.12'
gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -fno-semantic-interposition -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-use -fprofile-correction -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE \
	-DABIFLAGS='""' \
	-DMULTIARCH=\"x86_64-linux-gnu\" \
	-o Python/sysmodule.o ./Python/sysmodule.c
gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -fno-semantic-interposition -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-use -fprofile-correction -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE \
	-DSOABI='"cpython-310-x86_64-linux-gnu"' \
	-o Python/dynload_shlib.o ./Python/dynload_shlib.c
gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -fno-semantic-interposition -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-use -fprofile-correction -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Modules/config.o Modules/config.c
gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -fno-semantic-interposition -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-use -fprofile-correction -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -DPYTHONPATH='""' \
	-DPREFIX='"/usr/bin/python3.10.12"' \
	-DEXEC_PREFIX='"/usr/bin/python3.10.12"' \
	-DVERSION='"3.10"' \
	-DVPATH='""' \
	-o Modules/getpath.o ./Modules/getpath.c
gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -fno-semantic-interposition -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-use -fprofile-correction -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE \
      -DGITVERSION="\"`LC_ALL=C `\"" \
      -DGITTAG="\"`LC_ALL=C `\"" \
      -DGITBRANCH="\"`LC_ALL=C `\"" \
      -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
rm -f libpython3.10.a
ar rcs libpython3.10.a Modules/getbuildinfo.o Parser/token.o  Parser/pegen.o Parser/parser.o Parser/string_parser.o Parser/peg_api.o Parser/myreadline.o Parser/tokenizer.o Objects/abstract.o Objects/accu.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/call.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genericaliasobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/interpreteridobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/picklebufobject.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/unionobject.o Objects/weakrefobject.o Python/_warnings.o Python/Python-ast.o Python/asdl.o Python/ast.o Python/ast_opt.o Python/ast_unparse.o Python/bltinmodule.o Python/ceval.o Python/codecs.o Python/compile.o Python/context.o Python/dynamic_annotations.o Python/errors.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/hamt.o Python/hashtable.o Python/import.o Python/importdl.o Python/initconfig.o Python/marshal.o Python/modsupport.o Python/mysnprintf.o Python/mystrtoul.o Python/pathconfig.o Python/preconfig.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/bootstrap_hash.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/thread.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/suggestions.o Python/dynload_shlib.o    Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/_weakref.o  Modules/_functoolsmodule.o  Modules/_operator.o  Modules/_collectionsmodule.o  Modules/_abc.o  Modules/itertoolsmodule.o  Modules/atexitmodule.o  Modules/signalmodule.o  Modules/_stat.o  Modules/timemodule.o  Modules/_threadmodule.o  Modules/_localemodule.o  Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o  Modules/faulthandler.o  Modules/_tracemalloc.o  Modules/symtablemodule.o  Modules/xxsubtype.o Python/frozen.o
gcc   -fno-semantic-interposition  -Xlinker -export-dynamic -o python Programs/python.o libpython3.10.a -lcrypt -ldl  -lm   -lm 
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
	echo "generate-posix-vars failed" ; \
	rm -f ./pybuilddir.txt ; \
	exit 1 ; \
 CC='gcc' LDSHARED='gcc -shared   -fno-semantic-interposition ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall' 	_TCLTK_INCLUDES='' _TCLTK_LIBS='' 	./python -E ./  build
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers

The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel      
_dbm                  _gdbm                 _hashlib           
_lzma                 _sqlite3              _ssl               
_tkinter              _uuid                 readline           
To find the necessary bits, look in in detect_modules() for the module's name.

The following modules found by detect_modules() in, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time               

Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer

running build_scripts
copying and adjusting /home/evgeny/Downloads/Python-3.10.12/Tools/scripts/pydoc3 -> build/scripts-3.10
copying and adjusting /home/evgeny/Downloads/Python-3.10.12/Tools/scripts/idle3 -> build/scripts-3.10
copying and adjusting /home/evgeny/Downloads/Python-3.10.12/Tools/scripts/2to3 -> build/scripts-3.10
changing mode of build/scripts-3.10/pydoc3 from 664 to 775
changing mode of build/scripts-3.10/idle3 from 664 to 775
changing mode of build/scripts-3.10/2to3 from 664 to 775
renaming build/scripts-3.10/pydoc3 to build/scripts-3.10/pydoc3.10
renaming build/scripts-3.10/idle3 to build/scripts-3.10/idle3.10
renaming build/scripts-3.10/2to3 to build/scripts-3.10/2to3-3.10
gcc   -fno-semantic-interposition  -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o libpython3.10.a -lcrypt -ldl  -lm   -lm 
sed -e "s,@EXENAME@,/usr/bin/python3.10.12/bin/python3.10," < ./Misc/ >
LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/ >python-config
make[1]: Leaving directory '/home/koperfild/Downloads/Python-3.10.12'

As I understood there is openssl - executable file and also libssl-dev - shared library for development/building.
with ldconfig -p | grep ssl I found and tried to put its path to --with-openssl key
$ ./configure -C --with-openssl=/lib/x86_x64-linux-gnu --enable-optimizations --prefix=/usr/bin/python3.10.12
Also tried full path like /lib/x86_x64-linux-gnu/

This is supposed to be where the dev headers and libraries are not the openssl program.
You must install the openssl-dev package (i think that is that name) to get the files that python’s build needs.

Why can’t you use the python3 that is shipped in 22.04?

Because I want to test it locally before deploying images with python3.10.12 to production. And I’ll need it during development to have the same to prod environment

Got it, I do the same.
I my case its a production system on oracle linux 8.
We do not build python to test on a specific version we run the production environment in a VM so that we have exactly the right set of python versions and libraries.

Will you put into production you build of python? Is this the first time you have done this?

Evgentually I’ve managed to compile Python.
Just used ./configure without any parameters.
make test
make altinstall

But you first need to install Linux packages like libssl-dev, sqlite-dev (don’t remember exact name) and maybe other.
Now I use pyenv to do the same but easier
pyenv install -v 3.10.12
-v is needed to see if all is ok. Pyenv also requires that you preinstalled all needed OS packages before running pyenv install. It can compile without some libraries like ssl or sqlite. It will work until you’ll need to import this packages in python.