Search code examples
pythonsetuptoolsdistutils

Using setuptools to install files to arbitrary locations


Is there a way to install files to arbitrary locations with setuptools? I've used Data Files with setuptools before, but those are typically installed inside the package directory. I need to install a plugin file that will be located in the install directory of another application.


Solution

  • It seems that setuptools has purposely made it difficult to install files outside of the package directory.

    I instead included the plugin files as package data and used the Entry Points feature of setuptools to expose the install/uninstall functions for the plugin files I wanted to distribute.

    setup(
        ...
        entry_points={
            'console_scripts': [
                'mypackage_install_plugins = mypackage:install_plugins',
                'mypackage_uninstall_plugins = mypackage:uninstall_plugins',
            ],                
        }
    )
    

    I just added an additional step to the installation instructions to run the following command after installing the python package:

    $> mypackage_install_plugins