Install ansible4.10.0 on custom python3.12.5 on redhat8

I did build a python3.12.5 underneath a custom location on a server without direct internet access. So i downloaded several modules and transferred them onto the server. But it complains about setuptools not being available, whereas python states them being fine (even recent version).

$ python3 -m pip install --no-index --find-links=. ansible
Looking in links: .
Processing ./ansible-4.10.0.tar.gz

  • Preparing metadata (setup.py) … error*

  • error: subprocess-exited-with-error*

  • × python setup.py egg_info did not run successfully.*

  • │ exit code: 1*

  • ╰─> [1 lines of output]*

  •  ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.*
    
  •  [end of output]*
    
  • note: This error originates from a subprocess, and is likely not a problem with pip.*
    error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
$ python3 -m pip install --no-index --find-links=. setuptools
Looking in links: .
Requirement already satisfied: setuptools in /opt/SP/deploydata/tools/lib/python3.12/site-packages (59.6.0)
$ which python3
/opt/SP/deploydata/tools/bin/python3
$ which python
/opt/SP/deploydata/tools/bin/python
$ python3 --version
Python 3.12.5
$ python --version
Python 3.12.5
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.10 (Ootpa)

When i gunzip/untar the ansible-4.10.0.tar.gz and go into the ansible-4.10.0 directory, i receive following error instead:
$ python3 setup.py install
Traceback (most recent call last):

  • File “/var/SP/data/tools/.build/Python-3.12.5/download/ansible-4.10.0/setup.py”, line 5, in *
  • from setuptools import setup*
  • File “/opt/SP/deploydata/tools/lib/python3.12/site-packages/setuptools/init.py”, line 10, in *
  • import distutils.core*
    ModuleNotFoundError: No module named ‘distutils’

Where distutils has been removed from the python distribution and should not been used at all.

Therefore i would appreciate all hints on how to get it up and running!
Thanks for your support :slight_smile:

PS: i am not in the position to exchange the servers OS level or connect to internet :frowning:

Ansible 4 is very old. It was released 2 years before python3.12. Its likely that it does not support python3.12, for reasons like this:

Where distutils has been removed from the python distribution and should not been used at all.

RHEL8 with its related Python and in turn Ansible is old.
If you’re not in the position to exchange the servers OS level (I assume you can’t upgrade to RHEL9) or connect to internet, then my suggestion is that you use the latest possible version, even if it’s very old.

Interpreter discovery broken for rhel 8 based distros on 2.17 · Issue #83357 · ansible/ansible (github.com)
SyntaxError: future feature annotations is not defined · Issue #82068 · ansible/ansible (github.com)