Today taurus uses some external libraries that need local customization.
This customization may be required for different reasons:
Local customizations are being made inline. This has some weakenesses.
For example, Qt is being wrapped inside taurus/qt/. It is not possible to extend
the wrapping for the PyQt4.uic package because before the Qt wrapping concept
was added to taurus, an internal taurus sub-package called taurus/qt/uic already
existed to help handle code generation in taurusuic4 tool. It is therefore not
possible to wrap PyQt4.uic inside taurus.
This is a request to clearly isolate dependencies in a taurus sub package.
I propose to make a taurus.external which isolates the management of these
dependencies.
Here is the list of packages that need to be "externalized" and the reason:
In practice, the import statements in taurus should be changed from:
try: import argparse except ImportError: import optparse as argparse
to:
from taurus.external import argparse
and from:
from taurus.qt import Qt from taurus.qt import QtCore from taurus.qt import QtGui
to:
from taurus.external.qt import Qt from taurus.external.qt import QtCore from taurus.external.qt import QtGui
Since many taurus applications are relying on taurus.qt.Qt[Core|Gui], the implementation must take into account backward compatibility.
The PyQt4.Qt sub-package is a helper for the following packages:
QtDBus
QtHelp
QtNetwork
QtOpenGL
QtScriptTools
QtScript
QtDeclarative
QtCore
QtGui
Today taurus uses Qt to address only QtCore and QtGui symbols. When taurus imports PyQt4.Qt indirectly a waste of ~25Mb of RAM (depends on implementation) is made by process which only needs QtCore and QtGui.
This package doesn't exist in PySide. The QtNetwork was only added in PyQt4 4.4.
Because of these problems it is proposed that an implementation of taurus.external.qt.Qt includes only symbols from QtCore and QtGui.
Taurus Qt usage should depend on the private taurus qt configuration. The configuration describes the policy for using a specific Qt implementation. The usage of a specific Qt implementation should correspond to the following algorithm:
if a Qt is already in memory: if config.[use specific Qt implementation]: if config.[specific Qt implementation] != Qt in memory: <raise Failed to use Qt X because Qt Y is already in use> else: <find best Qt according to config.[prefered Qts] and installed Qts> if no Qt found: <raise no Qt implementation found> if Qt as not been initialized: <initialize Qt implementation>
the Qt configuration could be based on taurus.tauruscustomsettings. Example:
# ---------------------------------------------------------------------------- # Qt configuration # ---------------------------------------------------------------------------- #: Auto initialize Qt DEFAULT_QT_AUTO_INIT = True #: Set preffered API if not is already loaded DEFAULT_QT_AUTO_API = 'PyQt4' #: Whether or not should be strict in choosing Qt API DEFAULT_QT_AUTO_STRICT = False #: Auto initialize Qt logging to python logging DEFAULT_QT_AUTO_INIT_LOG = True #: Auto initialize taurus resources (icons) DEFAULT_QT_AUTO_INIT_RES = True #: Remove input hook (only valid for PyQt4) DEFAULT_QT_AUTO_REMOVE_INPUTHOOK = True #: Auto initialize Qt QT_AUTO_INIT = DEFAULT_QT_AUTO_INIT #: Set preffered API if not is already loaded QT_AUTO_API = DEFAULT_QT_AUTO_API #: Whether or not should be strict in choosing Qt API QT_AUTO_STRICT = DEFAULT_QT_AUTO_STRICT #: Auto initialize Qt logging to python logging QT_AUTO_INIT_LOG = DEFAULT_QT_AUTO_INIT_LOG #: Auto initialize taurus resources (icons) QT_AUTO_INIT_RES = DEFAULT_QT_AUTO_INIT_RES #: Remove input hook (only valid for PyQt4) QT_AUTO_REMOVE_INPUTHOOK = DEFAULT_QT_AUTO_REMOVE_INPUTHOOK
The implementation I propose is based on the success story of IPython management
of external dependencies through the usage of IPython.external pattern.
This implementation has also proved to work before on the Qarbon project with a similar External pattern
Sardana: Wiki: SEP12
Sardana: Wiki: SEP3
Diff:
A patch has been sent to implement this feature
After quite some troubles, I finally managed to apply the patch.
The feature is now immplemented in the develop branch.
I also changed some more imports that were not covered in tiago's patch, mostly in docs and in sardana
Thanks Carlos. You're the best!
Ticket moved from /p/sardana/tickets/113/
Can't be converted: