[Distutils] installing .py plugins to an alternate directory

Andrew Dalke dalke at dalkescientific.com
Sat Dec 5 02:27:10 CET 2009

On Dec 3, 2009, at 4:46 AM, David Cournapeau wrote:
> If you think this is insane, you are not alone :)

I think that by hooking into "data_files" I can be a bit less insane. What's wrong with this? Other than that it writes

Writing /Library/Python/2.6/site-packages/Spam_services-0.0.0-py2.6.egg-info

which isn't needed when there is no other Python code. But I can special case that and bypass the setup mechanism entirely if there are no py_modules, packages, or ext_modules given. (Am I missing something?)

from distutils.core import setup

def my_setup(**kwargs):
    if "akara_extensions" in kwargs:
        akara_extensions = kwargs["akara_extensions"]
        if not isinstance(akara_extensions, list):
            raise TypeError("akara_extensions must be a list of filenames")
        del kwargs["akara_extensions"]

        if "data_files" not in kwargs:
            kwargs["data_files"] = []
        data_files = kwargs["data_files"]
        data_files.append( ("/tmp", akara_extensions) )


my_setup(name="Spam services",
         akara_extensions = ["spam_extensions.py"],

				dalke at dalkescientific.com

More information about the Distutils-SIG mailing list