guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/03: gnu: trytond: Fix import of trytond modules.


From: guix-commits
Subject: 02/03: gnu: trytond: Fix import of trytond modules.
Date: Sat, 18 Dec 2021 09:20:16 -0500 (EST)

htgoebel pushed a commit to branch master
in repository guix.

commit 939e3813d0520d56440009a6efd5444a88555e2f
Author: Hartmut Goebel <h.goebel@crazy-compilers.com>
AuthorDate: Thu Dec 2 19:28:56 2021 +0100

    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
---
 gnu/local.mk                                       |  1 +
 .../patches/trytond-add-egg-modules-to-path.patch  | 22 ++++++++++++++++++++++
 gnu/packages/tryton.scm                            |  3 ++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 76403bb..0ed4dd6 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1845,6 +1845,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/tor-sandbox-i686.patch                  \
   %D%/packages/patches/transcode-ffmpeg.patch  \
   %D%/packages/patches/transmission-honor-localedir.patch      \
+  %D%/packages/patches/trytond-add-egg-modules-to-path.patch   \
   %D%/packages/patches/ttf2eot-cstddef.patch                   \
   %D%/packages/patches/tup-unbundle-dependencies.patch         \
   %D%/packages/patches/tuxpaint-stamps-path.patch              \
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 0000000..1baccfe
--- /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
+  
diff --git a/gnu/packages/tryton.scm b/gnu/packages/tryton.scm
index 6ba7539..0bd5ffc 100644
--- a/gnu/packages/tryton.scm
+++ b/gnu/packages/tryton.scm
@@ -48,7 +48,8 @@
        (method url-fetch)
        (uri (pypi-uri "trytond" version))
        (sha256
-        (base32 "1jp5cadqpwkcnml8r1hj6aak5kc8an2d5ai62p96x77nn0dp3ny4"))))
+        (base32 "1jp5cadqpwkcnml8r1hj6aak5kc8an2d5ai62p96x77nn0dp3ny4"))
+       (patches (search-patches "trytond-add-egg-modules-to-path.patch"))))
     (build-system python-build-system)
     (propagated-inputs
      (list python-dateutil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]