[Distutils] BUG: Stub loaders not created for non distutils .pyd files when using setuptools.

Jamie Kirkpatrick jkp at kirkconsulting.co.uk
Fri Apr 20 13:26:06 CEST 2007


All

I have come across what I believe is a bug in setuputils bdist_egg  
command.  According to this page http://peak.telecommunity.com/ 
DevCenter/EggFormats#zip-file-issues it is not possible for python's  
zip loader to load shared libraries directly from the zip files  
themselves therefore a special stub loader py file is generated for  
each C extension included in a package that works around this issue.

The problem I have found becomes apparent when pyd extension  
libraries are compiled using a process that lives outside of  
distutils itself (ie not using the Extension class).  The code in  
bdist_egg.py only generates stub loaders for extensions that are  
built by distutils - any pyd files included in another manner are not  
processed.  This is actually inconsistent with a method elsewhere in  
the distribution called exe_to_egg or somesuch where all resources  
are scanned and any .pyd files get a stub generated.

I've created a simple patch (attached) to fix the issue.  It checks  
all the resources found in the all_outputs list and generates stubs  
for any pyd files found - this covers off cases where you have pyd  
files included that are not generated by distutils itself.

I understand that the preferred method would be to use distutils to  
do all extension builds but in my case this is not possible or  
desirable.  I'm dynamically generating a set of extensions as the  
result of a toolchain that includes SWIG and needs to be refused  
across multiple languages so we use Ribosome to build the actual  
extension files in a portable manner instead of distutils.  I then  
copy them into the final package as datafiles.

I hope that either my patch (or a modified version) can be  
incorporated or someone can suggest another workaround that would fix  
the issue allowing externally generated pyd files to have wrappers  
auto-generated by bdist_egg.

Many thanks in advance

JKP

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bdist_egg+stub_creation.patch
Type: application/octet-stream
Size: 1003 bytes
Desc: not available
Url : http://mail.python.org/pipermail/distutils-sig/attachments/20070420/5978c5e4/attachment.obj 


More information about the Distutils-SIG mailing list