ansible / ansible-builder

An Ansible execution environment builder
Other
287 stars 93 forks source link

requirements-parser breaks on 3.12+ default venvs #644

Closed nitzmahone closed 2 months ago

nitzmahone commented 7 months ago

ansible-builder fails to run in "stock" Python 3.12+ venvs/environments. The requirements-parser Python dep used by introspect.py has an undeclared dependency on setuptools, since it relies on pkg_resources being present. This has arguably been broken for a long time, but is exacerbated by Python 3.12+ venvs explicitly excluding setuptools by default.

We don't really want a runtime dep on setuptools anyway, so this is another nail in the coffin of requirements-parser. We might be able to get what we need from packaging instead, but the way we inject and run introspect inside the container env makes me consider vendoring the needed bits instead (possibly requirements-parser itself).

mdavis@mdavis-p1:~/.virtualenvs$ python3.12 -m venv ~/.virtualenvs/tmp-312
mdavis@mdavis-p1:~/.virtualenvs$ source ~/.virtualenvs/tmp-312/bin/activate
(tmp-312) mdavis@mdavis-p1:~/.virtualenvs$ pip list

# NOTE LACK OF SETUPTOOLS

Package Version
------- -------
pip     23.2.1

[notice] A new release of pip is available: 23.2.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
(tmp-312) mdavis@mdavis-p1:~/.virtualenvs$ pip install ansible-builder
Collecting ansible-builder
...
(tmp-312) mdavis@mdavis-p1:~/.virtualenvs$ ansible-builder
ModuleNotFoundError: No module named 'pkg_resources'
DorBreger commented 3 months ago

problem for me on arch linux

DorBreger commented 3 months ago

workaround if installed through pipx is pipx inject ansible-builder setuptools

ssbarnea commented 2 months ago

IMHO, the "we do not want" as something for the future, for the moment I hotfix would be to add setuptools as a dependency at least for py312.

The fix https://github.com/ansible/ansible-builder/pull/659 was merged 3 months ago but no release was made since, so users will still face it.