cubicweb #13001466 cubes: distribution, installation. namespace, python3... [validation pending]

There has already been some discussions about this (see the CWEP 004 thread in particular).

On the road towards Python 3 compatibility (which 3.23 would apparently achieve for cubicweb itself), it seems that the current distribution and installation layout of cubes would pose problems; for instance, how would python2 and python3 versions of the same cube would install things in <prefix>/share/cubicweb?

Should I draw some (subjective?) conclusions from the CWEP 004 thread (and some other, probably more informal, discussions here and there), I'd say that there is a consensus that we should move away from the cubes namespace and install cubes as standard python packages.

One idea from the CWEP 004 thread would be to name cubes' packages as cubicweb_<cubename> instead of cubes.<cubename>

Another idea (from CWEP 004) is to rely on setuptools entry-points for some details. The benefits of this are unclear to me at the moment...

Anyhow, I had a look a the flask project which recently handled a similar transition (appart from the installation is <prefix>/share that's specific to cubicweb). Basically, they had (legacy) namespaces flaskext.<name> or flask.ext.<name> and transitioned to flask_<name> packages. They introduced a custom module importer (see https://github.com/pallets/flask/blob/0.10.1/flask/exthook.py for the code) to handleboth the legacy and new layouts, documented that the new layout was preferred for a couple of releases and then deprecated the old layout (see this commit https://github.com/pallets/flask/commit/d3d8a46). It seems to me that a similar plan could be followed for cubes. This would imply at short term to:

  • update skeleton to put files in cubicweb_<NAME> and adjust setup.py accordingly

  • implement a transition import mecanism

priorityimportant
typetask
done in3.24.0
load left0.000
closed by#bc04039acd2e [config] Make available_cubes aware of cubes installed as packages
patch[skeleton] Remove override_dh_python2 [applied][skeleton] Have setuptools install data files [applied][skeleton] Update MANIFEST.in following new "package" layout [applied][skeleton] Add python-setuptools to Debian Build-Depends [applied][skeleton] Add dh-python to Debian Build-Depends [applied]Use pkgutil.ImpLoader instead of a custom loader for cubes import redirection [applied][config] Make available_cubes aware of cubes installed as packages [applied][config] One warn about legacy cubes in available_cubes when called from "list" command [rejected][devtools] Handle i18ncube command for "cubes as packages" [applied]Handle cubes as packages in cwconfig [applied]Add an import redirect hook from "cubes.<name>" to "cubicweb_<name>" [applied][devtools] Update skeleton's setup.py to install cube as a package [applied][devtools] Adjust skeleton setup.py to have it read information from __pkginfo__.py [applied][devtools] Update skeleton and newcube command to cube as package layout [applied][cwconfig] Extend cubes.__path__ rather than overriding it [rejected]