[Distutils] Including DLLs in binary distributions

David Cournapeau david at ar.media.kyoto-u.ac.jp
Wed Jul 22 09:52:55 CEST 2009


P.J. Eby wrote:
> At 11:09 AM 7/21/2009 -0400, Jean-Paul Calderone wrote:
>> On Tue, 21 Jul 2009 09:47:46 -0400, Jean-Paul Calderone
>> <exarkun at divmod.com> wrote:
>>> On Tue, 21 Jul 2009 09:02:16 -0400, Jean-Paul Calderone
>>> <exarkun at divmod.com> wrote:
>>>> On Mon, 20 Jul 2009 20:22:41 -0400, "P.J. Eby"
>>>> <pje at telecommunity.com> [snip]
>>>>>
>>>>> Use package_data instead; it should do the right thing with both
>>>>> distutils and setuptools.  (It is available in the distutils as of
>>>>> Python 2.4; for 2.3 you'd have to use setuptools.)
>>>>
>>>> Can package_data include files which aren't in the source tree?  I
>>>> naively
>>>> tried
>>>>    package_data = {
>>>>        'OpenSSL': ['C:/OpenSSL/ssleay32.dll',
>>>>                    'C:/OpenSSL/libeay32.dll']}
>>>
>>> Hmm.  Actually, I then tried various other spellings, using only
>>> relative
>>> paths, and was unable to get these DLLs into the egg using any of
>>> them.  I
>>> wonder if I am missing something fundamental about how package_data is
>>> interpreted.
>>>
>>> A couple other values I tried:
>>>
>>>  package_data = {'': ['ssleay32.dll', 'libeay32.dll']}
>>>
>>>  package_data = {'OpenSSL': ['ssleay32.dll', 'libeay32.dll']}
>>>
>>> Any tips?
>>
>> I tracked down the problem to a requirement I wasn't aware of.  If no
>> value is passed for the "packages" argument to setup, it seems that the
>> package_data value is ignored.  Once I added `packages = ["OpenSSL"]´,
>> the former of the above package_data definitions worked.
>>
>> I'm still curious about whether it's possible to specify absolute paths
>> rather than relative paths.
>
> No, it's not supported by the distutils or by setuptools.  The concept
> of "package data" is data in the same directory as the package's
> Python code.  Using it to install libraries is a bit of a hack in the
> first place.

Installing libraries which are not python extensions is indeed quite
difficult ATM, I faced the same problem in numpy recently. Since in
numpy, we have our own distutils extensions, I hacked something to make
it work. A lot of code is related to our needs to be able to reuse to
libraries (with link options and all), and otherwise:
    - I patched the Distribution class to add one member which keeps
track of the installed libraries (dll in your case)
    - I added an install_clib command: this takes care of adding the
files to the record file, etc...
    - I added the in-place option for build_clib command: this is
necessary to make sure develop command works

Feel free to reuse this if you want (and can! It is butt-ugly, but not
worse than average distutils code :) ).

http://github.com/cournape/numpy/tree/install_clib

cheers,

David


More information about the Distutils-SIG mailing list