CentOS/8/Python 3.14: Difference between revisions

From Omnia
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 211: Line 211:


sudo alternatives --set python /opt/python3.14/bin/python3.14
sudo alternatives --set python /opt/python3.14/bin/python3.14
sudo alternatives --install \
    /usr/bin/python3 \
    python3 \
    /opt/python3.14/bin/python3.14 \
    314
sudo alternatives --set python3 /opt/python3.14/bin/python3.14


sudo ln -s /usr/bin/unversioned-python /usr/bin/python
sudo ln -s /usr/bin/unversioned-python /usr/bin/python
sudo alternatives --display pip3
sudo alternatives --display pip
sudo alternatives --config pip3
sudo alternatives --config pip
sudo alternatives --install /usr/bin/pip3 pip3 /opt/python3.14/bin/pip3.14 314
sudo alternatives --set pip3 /opt/python3.14/bin/pip3.14
sudo alternatives --install /usr/bin/pip pip /opt/python3.14/bin/pip3.14 314
sudo alternatives --set pip /opt/python3.14/bin/pip3.14


python --version
python --version

Latest revision as of 02:59, 3 August 2026

Python 3.14 with OpenSSL 3

<markdown>

  1. Python 3.14 + OpenSSL 3.x on CentOS 8

This guide installs:

- OpenSSL 3.x in `/opt/openssl-3` - Python 3.14 in `/opt/python3.14` - Modern TLS support for Python `ssl`, `urllib`, `requests`, and `aiohttp` - Isolation from the OS Python and OpenSSL versions

This approach is recommended for environments that use:

- Corporate TLS inspection appliances - Internal Artifactory servers - Self-signed enterprise CAs - Modern TLS requirements

Python 3.14 requires OpenSSL 1.1.1 or newer for SSL support. [1](https://www.python.org/downloads/release/python-3140/)

---

  1. 1. Install Build Dependencies

```bash dnf groupinstall -y "Development Tools"

dnf install -y \

   gcc \
   gcc-c++ \
   make \
   wget \
   perl \
   perl-IPC-Cmd \
   zlib-devel \
   bzip2-devel \
   libffi-devel \
   readline-devel \
   sqlite-devel \
   xz-devel \
   tk-devel \
   gdbm-devel \
   ncurses-devel

```

---

  1. 2. Download and Build OpenSSL 3.x

```bash

mkdir ~/.src ; cd ~/.src

cd /usr/src

wget https://www.openssl.org/source/openssl-3.5.1.tar.gz

tar xf openssl-3.5.1.tar.gz

cd openssl-3.5.1 ```

Configure:

```bash ./Configure \

   --prefix=/opt/openssl-3 \
   --openssldir=/opt/openssl-3 \
   shared \
   linux-x86_64

```

Build:

```bash make -j$(nproc) ```

Install:

```bash make install ```

Verify:

```bash /opt/openssl-3/bin/openssl version ```

Actually Needs:

``` LD_LIBRARY_PATH=/opt/openssl-3/lib64 /opt/openssl-3/bin/openssl version ```

Expected:

```text OpenSSL 3.5.x

OpenSSL 3.5.1 1 Jul 2025 (Library: OpenSSL 3.5.1 1 Jul 2025) ```

---

  1. 3. Configure Runtime Linker

Create:

```bash cat >/etc/ld.so.conf.d/openssl3.conf <<EOF /opt/openssl-3/lib64 EOF ```

Refresh:

```bash ldconfig ```

Verify:

```bash ldconfig -p | grep ssl ```

Expected output should include:

```text libssl.so.3 libcrypto.so.3 ```

---

  1. 4. Download Python 3.14

```bash mkdir ~/.src ; cd ~/.src

cd /usr/src

wget https://www.python.org/ftp/python/3.14.6/Python-3.14.6.tgz

tar xf Python-3.14.6.tgz

cd Python-3.14.6 ```

Configure:

```bash LDFLAGS="-Wl,-rpath,/opt/openssl-3/lib64" \ ./configure \

   --prefix=/opt/python3.14 \
   --with-openssl=/opt/openssl-3 \
   --enable-optimizations \
   --with-ensurepip=install

```

fix:

```bash make distclean

CPPFLAGS="-I/opt/openssl-3/include" \ LDFLAGS="-L/opt/openssl-3/lib64 -Wl,-rpath,/opt/openssl-3/lib64" \ PKG_CONFIG_PATH="/opt/openssl-3/lib64/pkgconfig" \ ./configure \

   --prefix=/opt/python3.14 \
   --with-openssl=/opt/openssl-3 \
   --with-openssl-rpath=auto \
   --with-ensurepip=install

```

Make

```bash make -j$(nproc) ```

---

  1. 7. Install Python

```bash make install ```

Local links ```bash ln -sfn /opt/python3.14/bin/python3.14 /usr/local/bin/python3.14 ln -sfn /opt/python3.14/bin/pip3.14 /usr/local/bin/pip3.14

ln -sfn /opt/python3.14/bin/python3.14 /usr/local/bin/python ln -sfn /opt/python3.14/bin/pip3.14 /usr/local/bin/pip

ln -sfn /opt/python3.14/bin/python3.14 /usr/bin/python3.14 ln -sfn /opt/python3.14/bin/pip3.14 /usr/bin/pip3.14

sudo alternatives --install \

   /usr/bin/unversioned-python \
   python \
   /opt/python3.14/bin/python3.14 \
   314
  1. sudo alternatives --set python /usr/bin/python3.14

sudo alternatives --set python /opt/python3.14/bin/python3.14

sudo alternatives --install \

   /usr/bin/python3 \
   python3 \
   /opt/python3.14/bin/python3.14 \
   314

sudo alternatives --set python3 /opt/python3.14/bin/python3.14

sudo ln -s /usr/bin/unversioned-python /usr/bin/python

sudo alternatives --display pip3 sudo alternatives --display pip sudo alternatives --config pip3 sudo alternatives --config pip

sudo alternatives --install /usr/bin/pip3 pip3 /opt/python3.14/bin/pip3.14 314 sudo alternatives --set pip3 /opt/python3.14/bin/pip3.14 sudo alternatives --install /usr/bin/pip pip /opt/python3.14/bin/pip3.14 314 sudo alternatives --set pip /opt/python3.14/bin/pip3.14


python --version ```

Verify:

```bash /opt/python3.14/bin/python3.14 --version ```

Expected:

```text Python 3.14.6 ```

---

  1. 8. Verify OpenSSL Integration

```bash /opt/python3.14/bin/python3.14 -c " import ssl print(ssl.OPENSSL_VERSION) " ```

Expected:

```text OpenSSL 3.5.x ```

---

  1. 9. Verify HTTPS Works

```bash /opt/python3.14/bin/python3.14 -c " import ssl import urllib.request

print(ssl.OPENSSL_VERSION) print(urllib.request.urlopen('https://www.python.org').status) " ```

Expected:

```text OpenSSL 3.5.x 200 ```

---

  1. 10. Install Common Packages

```bash /opt/python3.14/bin/pip3.14 install \

   requests \
   aiohttp \
   certifi \
   truststore

```

Verify:

```bash /opt/python3.14/bin/pip3.14 list ```

---

  1. 11. Verify Requests

```python import ssl import requests

print("OpenSSL:", ssl.OPENSSL_VERSION)

r = requests.get(

   "https://www.python.org",
   timeout=30

)

print(r.status_code) ```

Expected:

```text OpenSSL: OpenSSL 3.x.x 200 ```

---

  1. 12. Check Python Trust Stores

Show OpenSSL trust path:

```python import ssl

print(ssl.get_default_verify_paths()) ```

Show Certifi path:

```python import certifi

print(certifi.where()) ```

This helps troubleshoot situations where:

- `curl` works - Browser works - Python Requests fails

because Requests typically uses Certifi rather than the OS trust store.

---

  1. 13. Force Requests to Use the OS Trust Store

For enterprise environments this is often recommended.

```python import truststore

truststore.inject_into_ssl() ```

Example:

```python import truststore

truststore.inject_into_ssl()

import requests

r = requests.get(

   "https://artifactory.company.com",
   timeout=30

)

print(r.status_code) ```

---

  1. 14. Verify Corporate Certificates

Check the complete certificate chain:

```bash echo | \ /opt/openssl-3/bin/openssl s_client \ -connect artifactory.company.com:443 \ -showcerts ```

Look for:

```text Verify return code: 0 (ok) ```

---

  1. 15. Verify Which OpenSSL Python Is Actually Using

```bash ldd /opt/python3.14/bin/python3.14 | grep ssl ```

Expected:

```text libssl.so.3 => /opt/openssl-3/lib64/libssl.so.3 libcrypto.so.3 => /opt/openssl-3/lib64/libcrypto.so.3 ```

---

  1. Optional: Create Convenience Symlinks

```bash ln -s /opt/python3.14/bin/python3.14 /usr/local/bin/python3.14

ln -s /opt/python3.14/bin/pip3.14 /usr/local/bin/pip3.14 ```

Verify:

```bash python3.14 --version pip3.14 --version ```

---

  1. Troubleshooting
    1. SSL module missing

```python import ssl ```

fails with:

```text ModuleNotFoundError: No module named '_ssl' ```

Rebuild Python and verify the configure output detects:

```text checking for OpenSSL ... ```

and:

```text _ssl module... yes ```

---

    1. Requests certificate errors

Enable debugging:

```python import ssl

print(ssl.OPENSSL_VERSION) print(ssl.get_default_verify_paths()) ```

Check Certifi:

```python import certifi

print(certifi.where()) ```

Test with OS trust store:

```python import truststore

truststore.inject_into_ssl() ```

---

  1. Final Installed Layout

```text /opt/openssl-3 /opt/python3.14 ```

Benefits:

- Does not interfere with system Python - Does not interfere with DNF - Uses OpenSSL 3.x - Fully supports Python 3.14 TLS features - Easier troubleshooting of enterprise certificate issues </markdown>