[Distutils] Are egg files needed when building/installing via --root?

zooko zooko at zooko.com
Mon Dec 1 04:17:14 CET 2008

On Nov 30, 2008, at 17:39 PM, Josselin Mouette wrote:

> When stripping .egg-info files, you run into problems with useless  
> code that checks for dependencies (while the packaging system  
> already checks for them), so you have to strip such code as well.

Let's put it like this: as the author of an application and some  
libraries written in Python, I would like it if my code could run on  
$operating_system_distribution even before someone has gotten around  
to packaging it for $operating_system_distribution.  Therefore, I  
need a way to tell whether some dependency is already installed.  I  
could write a giant switch statement for all known package management  

if platform.dist()[0] == 'debian':
	os.system("dpkg --list...")
elif platform.dist()[0] == 'redhat':
	os.system("rpm -q...")
elif platform.system() == 'windows':
	import win32api
	# probe registry ???
... etc

My code currently runs on nine operating systems and I hope to  
support a lot more before I'm through, so this switch statement would  
be a significant undertaking to support my users on various platforms.

Fortunately, pkg_resources does this for me in a generic, cross- 
platform way so that my workload is substantially reduced:

pkg_resources.require('my_dependency >= 1.0')

Note, this didn't use to work so well on some Linux distributions  
back in the bad old days when they removed .egg-info files, but  
nowadays it works very well on all of the aforementioned nine  
operating system distributions that I am aware of.

Now, you as a Debian developer may feel that you would have developed  
my application differently than me, such as perhaps step 1: make the  
code run on $operating_system_distribution even before it has been  
packaged for $operating_system_distribution, or you may not, but  
either way I truly appreciate that nowadays you preserve the .egg- 
info files so that I have the option of doing it this way.



More information about the Distutils-SIG mailing list