Saturday, May 28, 2005

EasyInstall - A new era in Python package management?

Okay, maybe that's a bit bold. But the new EasyInstall command-line tool can take any number of distutils source package URLs (or local filenames), download them, build them, and install them with or without a .pth file. Better yet, you can also easily upgrade, downgrade, and/or uninstall packages, as well as select desired package versions at runtime.

This is the very first alpha release, so there might be some rough edges. I plan to start systematically working my way through PyPI to test it with different packages. (Well, first I plan to try cases that are likely to be tough.)

EasyInstall doesn't absolve you from needing to have a C compiler, though, if you're installing a package that includes extensions. However, if someone has packaged a Python Egg for that package for your platform, you can simply run EasyInstall on the .egg file's URL (or local filename) to download and install it on your system. So, perhaps we'll soon see people packaging eggs for various platforms, and making those download URLs available.

EasyInstall is at this point still something of a sketch. An ideal version would probably let you search PyPI for the desired packages, without needing to know an exact download URL. Maybe it would have a GUI, too. Who knows? But it's open source, so feel free to create your own extensions. In the meantime, I'll continue to add features to both EasyInstall and the underlying "setuptools" package as I need them.

I also hope that package authors will consider making their packages more "egg-friendly" by using the 'pkg_resources' module supplied by setuptools, and especially by including dependency information in their source distributions (in a 'PackageName.egg-info/depends.txt' file) so that the pkg_resources dependency manager can automatically activate the right package versions at runtime. This is where things will start to get really different, because it will then be a lot easier for people to break up large packages into smaller packages with dependencies.

But before that can start happening, I really need to finish the Python Eggs developer documentation, which is still lacking a bit, contentwise. However, given the widespread interest in "CPAN clones" of late, I felt it was important to get a real package management solution out there right away, before people started trying to implement package managers based on PEP 262 or similar approaches that don't work -- at least, not as well as Python Eggs do -- for applications, multiple version support, or any number of other scenarios.

So, here's hoping that those of you who are working on CPAN clones will take a look at EasyInstall, and see whether you can save some work by importing a few classes from the easy_install and pkg_resources modules. But, if you find that what's there isn't helpful, I'd really like to hear from you. Similarly, if you've found a package that EasyInstall won't build correctly, please let me know via the Distutils-SIG mailing list.

Update: There was a problem with the original EasyInstall "eggsecutable" for Python 2.4 that I uploaded; it seems that the "-m" option to Python will only work with modules that are actual .py files, which means you can't use it inside of eggs. Darn. Oh well, the "eggsecutable" recipe for Python 2.3 also works with 2.4, so I just rebuilt the Python 2.4 egg to work the same way.