diff options
author | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2021-12-02 19:28:56 +0100 |
---|---|---|
committer | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2021-12-18 15:13:56 +0100 |
commit | 939e3813d0520d56440009a6efd5444a88555e2f (patch) | |
tree | 5bbae3ddaf201c2c204d85c585b6c29e82a854a3 /gnu/packages/patches | |
parent | 6eba17043a9eb01d04bf411fddc1f1699853ec8c (diff) | |
download | guix-939e3813d0520d56440009a6efd5444a88555e2f.tar.gz guix-939e3813d0520d56440009a6efd5444a88555e2f.zip |
gnu: trytond: Fix import of trytond modules.
For adding modules, trytond uses entry-points, anyhow relying on the
modules being named "trytond.modules.xxx" and being placed in the same
filesystem path as "trytond.modules".
The package "trytond.modules" is not a namespace module, anyhow trytond
modules must be sub-modules of "trytond.modules". This works well if all
packages are installed into the same filesystem path "…/trytond/modules":
The Python importer will find all sub_modules at this place.
Anyhow, in Guix, modules don't share the same filesystem path and the
Python importer will not find them.
Solution is to add all trytond module's locations to
"trytond.modules._path__". This will make "trytond.module" behave much
like a namespace module and the importer pick up the module.
* gnu/packages/patches/trytond-add-egg-modules-to-path.patch: New file.
* gnu/packages/tryton.scm (trytond): Use it.
* gnu/local.mk (dist_patch_DATA): Add it
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r-- | gnu/packages/patches/trytond-add-egg-modules-to-path.patch | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gnu/packages/patches/trytond-add-egg-modules-to-path.patch b/gnu/packages/patches/trytond-add-egg-modules-to-path.patch new file mode 100644 index 0000000000..1baccfee1c --- /dev/null +++ b/gnu/packages/patches/trytond-add-egg-modules-to-path.patch @@ -0,0 +1,22 @@ +Work around trytond.module not being a real namespace module. + +Solution is to add all trytond module's locations to +trytond.modules._path__. This will make trytond.module behave much +like a namespace module. +Adding to __path__ is done in update_egg_modules() to ensure __path__ +is updated whenever the list of egg modules is updated. + +*** a/trytond/modules/__init__.py 1970-01-01 01:00:01.000000000 +0100 +--- b/trytond/modules/__init__.py 2021-12-02 18:12:15.385101986 +0100 +*************** +*** 38,43 **** +--- 38,46 ---- + import pkg_resources + for ep in pkg_resources.iter_entry_points('trytond.modules'): + EGG_MODULES[ep.name] = ep ++ path = os.path.join(ep.dist.location, 'trytond', 'modules') ++ if not path in __path__ and os.path.isdir(path): ++ __path__.append(path) + except ImportError: + pass + |