Is there a standard/accepted/useful way of setting up a package such that other packages can be inserted into the (namespace of) the original package.
For example suppose I have a package that has functionality to work with some cool data. Then I might want to have separate packages for displaying that data in Matplotlib and a third package for displaying those data using Plotly. I would like to set things up so that:
- The Matplotlib and Plotly functionality can be included/excluded separately from one another.
- The framework is extensible so that if new plotting capabilities come along, they can be plugged into the framework
- The modules for the plotting functionality live inside the namespace defined by the "main"
- I am not requiring that the Matplotlib or Plotly functionality conform to a common interface — their related in that they both use the
cool_datafunctionality, but are independent (and different) from one another.
The design goals I’m trying to achieve are:
- Limit the scope and dependencies of the main
- Allow package user to "select-in" additional functionality.
What I’m imagining is:
$> pip install cool-data cool-matplotlib
>>> data = cool_data.obtain_data(...) >>> cool_data.matplot.plot(data, 'rv-') # uses matplotlib idomatic arguments >>> #cool_data.plotly.iplot(data, ...) if were using plotly instead
I think in part I’m just not remembering the correct terminology for things that I’ve seen that relate to
entry_points or the use of packages that do not include
__init__.py, so just pointers on the correct terminology might be helpful.
Source: Python Questions