简体   繁体   中英

Install precompiled python extension with distutils

How can I specify an arbitrary set of files (non necessarily .py files) so that they are distributed and installed just like normal Python modules?

Some background

I am using distutils to distribute and install my Python library. One of the modules in this library imports a 3rd-party Python extension called bpy.so (this is a Blender module). The bpy.so extension requires some other files, as well. I want to distribute and install bpy.so and the additional required files with my library.

One way to do this is by specifying all of the extra files as data_files to setup(). However, I don't know how to reliably specify the same installation directory as is used for my pure python modules (eg /usr/local/lib/python3.2/dist-packages). I can distribute the extra files by creating a MANIFEST.in file (see this question ), but I also want to install the files.

I would suggest to use setuptools on top of distutils.

This is a good reference document to get started with it. The advantage of using setuptools is that it has a few nice features like the possibility to include all files under a given directory (package) automatically or according to filters. This is the section of the above document dealing with this specific aspect.

HTH!

PS: distutils' current situation/limitations are the source of much complain from most of its users. It seems a new generation of the library is on its way though!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM