[Distutils] How to build python-packages depends on the output of other project

Ionel Cristian Mărieș contact at ionelmc.ro
Fri Jun 3 09:46:56 EDT 2016


On Fri, Jun 3, 2016 at 5:35 AM, Young Yang <afe.young at gmail.com> wrote:

> my_install is a subclass of `from setuptools.command.install import
> install`
> ```
> class my_install(install):
>     def run(self):
>         # DO something I want. Such as compiling the code of project A and
> copy the output of it (i.e. the .so file) to my binding folder
>         install.run(self)
> ```
>
> At last I  add these options in my setup function in setup.py to include
> the shared library  in the install package.
> ```
>       package_dir={'my_binding_package': 'my_binding_folder'},
>       package_data={
>           'my_binding_package': ['Shared_lib.so'],
>       },
>       include_package_data=True,
> ```
>
> But I think there should be better ways to achieve these.
>

​Overriding only the `install` will make bdist_wheel​ produce the wrong
result. There's also the `develop` command. Some ideas about what commands
you might need to override:
https://github.com/pytest-dev/pytest-cov/blob/master/setup.py#L30-L63

An alternative approach would be to create a custom Extension class, check
this https://github.com/cython/cython/tree/master/Cython/Distutils for
ideas.

Unfortunately the internals of distutils/setuptools aren't really well
documented so you'll have to rely on examples, simply reading distutils
code, coffee or even painkillers :-)
​


Thanks,
-- Ionel Cristian Mărieș, http://blog.ionelmc.ro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20160603/15bb7cae/attachment.html>


More information about the Distutils-SIG mailing list