#11850 Adjust python3_fact.py for python 3.12.
Closed: Fixed by abompard. Opened by kevin.

In newer fedora vm's the library/python3_fact.py script fails unless you install python3-setuptools.

distutils is under a 'deprecated' dir... so we should move away from it?

ansible outputs:

            "failed": true,                                                                           
            "module_stderr": "Traceback (most recent call last):\n  File \"<string>\", line 3, in <mod
ule>\nModuleNotFoundError: No module named 'distutils'\nTraceback (most recent call last):\n  File \"<
stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", 
line 47, in invoke_module\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>
\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansi
ble_python3_fact_payload_esj44l0e/ansible_python3_fact_payload.zip/ansible/modules/python3_fact.py\", 
line 84, in <module>\n  File \"/tmp/ansible_python3_fact_payload_esj44l0e/ansible_python3_fact_payload
.zip/ansible/modules/python3_fact.py\", line 80, in main\n  File \"/tmp/ansible_python3_fact_payload_e
sj44l0e/ansible_python3_fact_payload.zip/ansible/modules/python3_fact.py\", line 69, in run_module\n  
File \"/usr/lib64/python3.12/subprocess.py\", line 466, in check_output\n    return run(*popenargs, st
dout=PIPE, timeout=timeout, check=True,\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^\n  File \"/usr/lib64/python3.12/subprocess.py\", line 571, in run\n    raise CalledProcessErro
r(retcode, process.args,\nsubprocess.CalledProcessError: Command '['python3', '-c', '\\nfrom json impo
rt dumps\\nfrom distutils.sysconfig import get_python_lib\\nfrom sys import version_info\\nprint(dumps
({\\n    \"sitelib\": get_python_lib(),\\n    \"sitearch\": get_python_lib(True),\\n    \"version\": f
\"{version_info.major}.{version_info.minor}\",\\n}))\\n']' returned non-zero exit status 1.\n",      
            "module_stdout": "",                                                                      
            "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",                          
            "rc": 1
        }        
    },           
    "msg": "The following modules failed to execute: python3_fact\n",
    "warnings": []                                 
}

Commit 5c88ef73 fixes this issue

Metadata