23

I would like to release a python module I wrote which depends on several packages. What's the easiest way to make it so these packages are programmatically downloaded just in case they are not available on the system that's being run? Most of these modules should be available by easy_install or pip or something like that. I simply want to avoid having the user install each module separately.

thanks.

1
  • Most package management systems have a way to specify the dependencies of a package so that dependencies are automatically installed. I don't know how to do it with the setuptools / Python Package Index, but I assume there is a mechanism to similarly specify dependencies. Commented Apr 14, 2010 at 4:39

2 Answers 2

21

pip uses requirements files, which have a very straightforward format.

For more Python packaging tooling recommendations, see the latest from the Python Packaging Authority (PyPA).

Sign up to request clarification or add additional context in comments.

5 Comments

@J.F. I would guess Idan Gazit is responsible for the first image; I'm not sure who's responsible for the second. Both are hosted on Amazon S3; the image locations point to their S3 locations, so you can just copy the image locations and use those here and elsewhere. I saw the "Python Comrades" one at Titus Brown's PyCon 2010 talk; the "New Hotness" has been around for maybe a year now. Perhaps some sleuthing on the Python mailing lists can turn up the original source(s).
Although this is currently the highest voted answer, it doesn't really offer much of a solution (cool graphic though). I currently found this recent post on the subject. Might help others on this search.
@fabian789 correct. I have updated the answer. setuptools is the new library of choice. We were always at war with distribute. ;-)
@bnjmn the hyperlink in your post is no longer active
Thanks @Hector Here's an updated link to the post
4

See the setuptools docs on how to declare your dependencies -- this will allow easy_install to find, download and install all of them (and transitive closure thereof) if everything's available in PyPi, or otherwise if you specify the dependencies' URLs.

3 Comments

What do you think about pip? The pip comparisons to setuptools seem very strongly worded... is there really a consensus in the Python community that pip is better?
Also, can pip handle non-PyPi dependencies like setuptools can?
@user, unfortunately I don't have much direct experience with pip, but my impression is that it can do what easy_install can, and more. As b-list.org/weblog/2008/dec/15/pip says, "pip does not change your packaging workflow in any way. You just make your package the way you’ve always made it, and then put it up on the Web somewhere (preferably listing it in the Python package index, but you don’t have to if you don’t want to) and people using pip can grab it and install it.".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.