1

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 (e.g. /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.

2
  • Do the docs help? Commented Nov 5, 2011 at 0:08
  • Those are the docs for setuptools, of which I was previously unaware. (See mac's answer below.) I was using distutils. Commented Nov 5, 2011 at 17:11

1 Answer 1

0

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!

Sign up to request clarification or add additional context in comments.

2 Comments

Excellent suggestion. This appears to be exactly what I want. Thanks!
package_data was backported to distutils in Python 2.4. You don’t need to switch to setuptools just for them. (There are good and bad things when using setuptools.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.