Chris Nyland <> writes:
> We have several internal modules we have developed that are used mostly to
> read different types of data files. Most of the time the different data
> file formats come with some sort of DLL or SO files that gives a standard
> interface to read the files. Our design pattern is to create a python
> library that uses ctypes to interface with the shared library.
> To be clear we are not building the shared libraries these are usually
> provided by another group or distributed by a  third party.
> So the issue is I want to bundle these share libraries with the module into
> a wheel or sdist package to server off our local PyPiServer.

I am not yet familiar with the newer "wheel" concept but
with "older" technology you could approach it as follows.

I am using "setuptools", thus I use this for the presentation below.
But "setuptools" is based on the standard "distutils" package
and this has the same facilities.

With "setuptools", you describe how to handle (especially install)
a distribution by providing describing arguments to a "setup"
function. The "ext_modules" parameter is responsible to
describe extensions, i.e. things corresponding to shared objects/DLLs.
The value of "ext_modules" is a sequence of "setuptools.Extension"

The standard "setuptools.Extension" class can handle C/C++
compilation (and various other generation types). It
supports standard parameters decribing sources, macros, includes,
libraries -- things typically involved in C/C++ compilation).
For your case, you would need your own "Extension" class: as
source it would use the precreated shared object[s]; as additional
parameter, it would have the target platform supported by those
shared object[s]. On installation, it would check for platform compatibility
and then put the shared object[s] at the correct place.

If I would need to implement such an "Extension" class, I would
look at the implementation of "setuptools.Extension" (likely,
I would also have to look at its base "distutils.Extension")
and derive my "Extention" by simplification (the shared object[s]
are already build and available; they need just get installed).


Reply via email to