Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Distributing Twisted plugins with distutils
"""
Example of a way to distribute Twisted plugins with distutils. This would go in your setup.py file.
data_files would get passed to setup() through the data_files keyword.
"""
from distutils.sysconfig import get_python_lib
TWISTED_PLUGIN_PATH = os.path.join(get_python_lib(), 'twisted', 'plugins')
MODULE_PLUGIN_PATH = os.path.join('your_module', 'twisted', 'plugins')
data_files = [
(
TWISTED_PLUGIN_PATH,
[os.path.join(MODULE_PLUGIN_PATH, 'some_plugin.py')]
),
]
# Your call to distribute.setup() here
try:
# This is needed to re-generate the Twisted plugin dropin.cache after install.
from twisted.plugin import getPlugins
list(getPlugins(IPlugin))
except ImportError:
# Probably haven't installed yet. Fail silently.
pass
@fiorix

This comment has been minimized.

Copy link

commented Jun 9, 2012

pip won't uninstall the .pyc/.pyo this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.