You cannot do this with setuptools, installation inside another package is not supported.
Instead, you want to use entry points instead. Your origmodule should look for something registered as an entry point for a particular key, and your extension should register for that key.
Your extension registers the extension point:
entry_points={ 'some.opaque.string.unique.to.origmodule': ['my_extension = my.extension.package:some.entry.point', ] }
which your origmodule can detect by setting pkg_resources :
import pkg_resources for entrypoint in pkg_resources.iter_entry_points(group='some.opaque.string.unique.to.origmodule'): extension = entrypoint.load()
As an example, consider the Babylonian project . Babel can extract translated text from files; he knows how to do this for Python source code, but also supports extensions that can extract such text from other formats.
Such production methods can be recorded as expansion points. Babylon documents this in the Methods for Extracting Files section. The message retrieval code then loads these input points when extracting the text:
GROUP_NAME = 'babel.extractors' # ... for entry_point in working_set.iter_entry_points(GROUP_NAME, method): func = entry_point.load(require=True) break
Maco template language provides such a plugin; it registers an entry point that points to the actual implementation:
[babel.extractors] mako = mako.ext.babelplugin:extract
def extract(fileobj, keywords, comment_tags, options):