5

I recently wrote and released a python package - it's the first time I've ever released something to PyPi so I'm still learning.

I always thought it seemed crazy to store your requirements in both the setup.py and the requirements.txt, so instead I got my setup.py to just read the requirements.txt file instead: https://github.com/big-o/cherrypicker/blob/bf7382cbdabfc6608e3aec388903db32a917314c/setup.py#L32. I've never seen any other project do this though, which leads me to suggest that there's a good reason not to do it.

Can anyone explain to me why I shouldn't do this (or why it isn't a problem)?

I've seen other explanations that say setup.py is for installing your package whereas requirements.txt is for setting up your environment. But I fail to see what the difference is - the dependencies are the same and always will be. If I need a different set of packages, e.g. extra test packages for development, I can specify this separately in the extras_require part of setup.py.

EDIT: I get what the two different roles of setup.py and requirements.txt are, my question is why do the two need to be independent rather than sharing a common list of dependencies across both?

big-o
  • 445
  • 4
  • 7
  • https://stackoverflow.com/questions/43658870/requirements-txt-vs-setup-py – user202729 Aug 03 '19 at 09:35
  • 1
    I've updated my post to clarify that I get the point being answered by questions like this: I understand the roles of the two files, what I don't get is for the need to maintain two lists of dependencies independently, rather than linking the two files to share a common list. – big-o Aug 03 '19 at 10:33
  • you have to think that not always development dependencies are the same with distribution dependencies – kederrac Aug 03 '19 at 10:44
  • Can you give an example? One that shouldn't be handled by extra_requires in the way I mentioned in the OP? – big-o Aug 03 '19 at 11:46
  • 1
    https://caremad.io/posts/2013/07/setup-vs-requirement/ – phd Aug 03 '19 at 12:10
  • @phd that's a really nice explanation, thanks. Do you want to put it in an answer? I can mark that as correct then. – big-o Aug 03 '19 at 17:33

0 Answers0