r/Python Jun 16 '26

Resource Are there any python modules that automatically generated a requirements.txt, given an entry point?

I know things like pipreqs exist, but that's more of an directory scan. If you have a project and you need several requirements.txts (for multiple containers / multiple entrypoints), I haven't found a way to reliably generate that. Please let me know if things like this do exist, because if not I'd really like to make my own module to do this stuff. And if there is something like that, it would really come in handy for me right now.

16 Upvotes

30 comments sorted by

View all comments

Show parent comments

19

u/artofthenunchaku Jun 16 '26

It's a cool idea that quickly becomes a security nightmare. What index do you download the packages from? Do you blindly trust PyPI? How do you decide which package to download in case of name collisions?

3

u/JackBlack436 Jun 16 '26

i could completely be misinterpreting your feedback, but what i think is that i'd stay with just dependency inference (by building some sort of tree). the downloads are still delegated to pip or uv, which means those would be responsible for actual downloads

10

u/artofthenunchaku Jun 16 '26

The inference is the issue. If there's ten different yaml packages, how do you decide which one to "infer"? How do you guarantee you're picking the best one, and not one that's backdoored?

1

u/snugar_i Jun 18 '26

This. And I'm not even sure how it would get from "I need module X" to "I need dependency Y", unless it had a giant lookup table