# Create guidelines for collection python requirements

**URL:** <https://forum.ansible.com/t/create-guidelines-for-collection-python-requirements/5051>\
**Category:** Project Discussions\
**Tags:** community, documentation\
**Created:** [April 19, 2024, 7:13pm UTC](https://forum.ansible.com/t/create-guidelines-for-collection-python-requirements/5051 "2024-04-19T19:13:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![samccann](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/samccann/32/18_2.png) [@samccann](https://forum.ansible.com/u/samccann)\
**Post date:** [April 19, 2024, 7:13pm UTC](https://forum.ansible.com/t/create-guidelines-for-collection-python-requirements/5051/1 "2024-04-19T19:13:51Z")

</div>

### Summary

When packaging an ansible collection/role, there currently is no standard way of specifying python requirements, primarily the hard requirements of plugins. Some people use `requirements.txt`, but there is no standard guidelines for role and collection authors that I could find. It would be nice to have this documented and discussed somewhere.

This discussion started in [this community-topic](https://github.com/ansible-community/community-topics/issues/224) but stalled a bit I think. Please read that and then let’s continue the discussion here - how do we move forward on this one?

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 19, 2024, 7:40pm UTC](https://forum.ansible.com/t/create-guidelines-for-collection-python-requirements/5051/2 "2024-04-19T19:40:09Z")

</div>

I would presume that `requirements.txt` and `bindep.txt` should go in the root of a collection tree (same dir as `galaxy.yml`), so that they can be picked up by `ansible-builder` during EE builds.

It would be nice if that was actually part of [Collection structure — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections_structure.html).

It would also be nice if `ansible-galaxy` and maybe some other ansible tools could validate python/system requirements whenever those \*.txt files are present in collections. Then warn/fail when dependencies are missing. It would definitely be cool if there was a parameter/switch for auto-installing missing dependencies (if bindep/pip are available in $PATH at least). For e.g. AWX’s dynamic collection install feature works great for collections, but it doesn’t install missing dependencies. I’m not sure how feasible it would be to enable/allow dynamically updating dependencies in EE’s on the fly like AWX does with collections, but at least getting warnings about missing dependencies might be nice.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [April 24, 2024, 7:51pm UTC](https://forum.ansible.com/t/create-guidelines-for-collection-python-requirements/5051/3 "2024-04-24T19:51:10Z")

</div>

ansible-builder allows to configure where the requirements files are in `meta/execution-environment.yml` (see for example [community.docker/meta/execution-environment.yml at main · ansible-collections/community.docker · GitHub](https://github.com/ansible-collections/community.docker/blob/main/meta/execution-environment.yml#L7-L9)).

Generally such requirements files only work well for smaller, focussed collections, and you can quickly end up in dependency hell if collections specify too specific version requirements ([Make EE a proper EE with dependencies installed by felixfontein · Pull Request #22 · ansible-community/images · GitHub](https://github.com/ansible-community/images/pull/22) didn’t have a chance because of that).

In any case, there’s a lot of material in the linked GitHub issue, if anyone is interested in details, please read that first 🙂

---

<div class="post-metadata">

**Author:** ![Assaf\_Katz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/assaf_katz/32/7714_2.png) [@Assaf\_Katz](https://forum.ansible.com/u/Assaf_Katz)\
**Post date:** [February 25, 2025, 2:10pm UTC](https://forum.ansible.com/t/create-guidelines-for-collection-python-requirements/5051/4 "2025-02-25T14:10:25Z")

</div>

Hi,

Apologies for reopening this issue, but it’s been open for a while without much progress. I’m having trouble programmatically accessing the `requirements.txt` file for installed Ansible collections. There doesn’t seem to be a straightforward way to locate this file within an uncontrolled environment, and I haven’t been able to find a reliable solution.

I propose adding a mechanism to easily retrieve the path to a collection’s `requirements.txt` from the `ansible-galaxy collection list` command, perhaps with a new flag like `-L`. This would allow automated scripts to easily determine the correct `requirements.txt` file for dependency installation.

Thanks
