Dependency management is usually a pain in most environments so a lot of effort goes into solving the problem. It is usually interesting to see how different communities solve the problem, and how many alternatives are available solving it. In the .NET world the main solution is NuGet. In Ruby it is RubyGems. There are alternatives, but those are the dominate ones.
Python Package Index is similar to RubyGems.org. It is a big collection of all the python packages you can download, install, and start using. I started using RssLib in my termnews application which I found on PyPI. So it is a great resource for finding stuff others have written so you don’t have to write it. The question is how you do you install it? Well read on.
From what I have been seeing while learning about python, and the available frameworks. PIP is pretty much becoming the defacto standard now for package/dependency management. It is similar to RubyGems which installs everything from source instead of pre-made packages like python eggs. It also allows you to uninstall what you installed so it isn’t a one-way ride when you install the libraries. PIP was created as a replacement to easy_install.
Python Enterprise Application Kit
Before pip you would use easy_install which is part of the Python Enterprise Application Kit, and for a long time was the way you install packages outside of manually. You would create an egg, which is a single file meant for distribution, and easy_install was used to do all the necessary things to install the egg on your system.
PIP Mostly Solves easy_install(s) Inherit Problems
So what is the problem with the easy_install? Well it would be simpler to show you what pip solves than try to explain it, this is from their documentation.
- All packages are downloaded before installation. Partially-completed installation doesn’t occur as a result.
- Care is taken to present useful output on the console.
- The reasons for actions are kept track of. For instance, if a package is being installed, pip keeps track of why that package was required.
- Error messages should be useful.
- The code is relatively concise and cohesive, making it easier to use programmatically.
- Packages don’t have to be installed as egg archives, they can be installed flat (while keeping the egg metadata).
- Native support for other version control systems (Git, Mercurial and Bazaar)
- Uninstallation of packages.
- Simple to define fixed sets of requirements and reliably reproduce a set of packages.
There are a couple of things pip can’t do:
- It cannot install from eggs. It only installs from source.
- It doesn’t understand Setuptools extras (like package[test]). This should be added eventually.
- It is incompatible with some packages that extensively customize distutils or setuptools in their setup.py files.
I am still scratching the surface here on python. There is a lot more to everything than what I have posted here, but it is generally a good start in my investigation of using 3rd party packages/code/libraries. Next I need to figure out how to make and distribute code via pip.
For another look at package management in python I recommend this: So You Want to Install a Python Package