all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#52259] [PATCH 1/3] gnu: python-stdnum: Update to 1.17.
@ 2021-12-03 13:39 Hartmut Goebel
  2021-12-03 13:41 ` [bug#52259] [PATCH 2/3] gnu: trytond: Fix import of trytond modules Hartmut Goebel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Hartmut Goebel @ 2021-12-03 13:39 UTC (permalink / raw)
  To: 52259

* gnu/packages/finance.scm (python-stdnum): Update to 1.17.
---
 gnu/packages/finance.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index 0bb9c79520..191529ce40 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -1157,13 +1157,13 @@ agent.")
 (define-public python-stdnum
   (package
     (name "python-stdnum")
-    (version "1.14")
+    (version "1.17")
     (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "python-stdnum" version))
        (sha256
-        (base32 "070vd9zgvq0jchs4xc4j1h4r1l1lg4wwb8xs3p25k8c2xjw94fpx"))))
+        (base32 "0h4369b7gws5w5s2vhq590bk219y5k53zcmha2zwsb4i2dg2nkip"))))
     (build-system python-build-system)
     (arguments
      '(#:phases (modify-phases %standard-phases
-- 
2.30.2





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#52259] [PATCH 2/3] gnu: trytond: Fix import of trytond modules.
  2021-12-03 13:39 [bug#52259] [PATCH 1/3] gnu: python-stdnum: Update to 1.17 Hartmut Goebel
@ 2021-12-03 13:41 ` Hartmut Goebel
  2021-12-03 13:41 ` [bug#52259] [PATCH 3/3] gnu: trytond: Ensure all modules are found Hartmut Goebel
       [not found] ` <handler.52259.B.16385387683881.ack@debbugs.gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Hartmut Goebel @ 2021-12-03 13:41 UTC (permalink / raw)
  To: 52259

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

diff --git a/gnu/local.mk b/gnu/local.mk
index 604c6cf151..a8b9bcac21 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1816,6 +1816,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 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
+  
diff --git a/gnu/packages/tryton.scm b/gnu/packages/tryton.scm
index 0ac0a5a5cd..212d6593ad 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
      `(("python-dateutil" ,python-dateutil)
-- 
2.30.2





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#52259] [PATCH 3/3] gnu: trytond: Ensure all modules are found.
  2021-12-03 13:39 [bug#52259] [PATCH 1/3] gnu: python-stdnum: Update to 1.17 Hartmut Goebel
  2021-12-03 13:41 ` [bug#52259] [PATCH 2/3] gnu: trytond: Fix import of trytond modules Hartmut Goebel
@ 2021-12-03 13:41 ` Hartmut Goebel
  2021-12-14  8:15   ` zimoun
       [not found] ` <handler.52259.B.16385387683881.ack@debbugs.gnu.org>
  2 siblings, 1 reply; 7+ messages in thread
From: Hartmut Goebel @ 2021-12-03 13:41 UTC (permalink / raw)
  To: 52259

If the python package matching tryton is not installed alongside to trytond,
PYTHONPATH ist not set (or pointing to a wring version) and trytond (and the
trytond tools) would not find the trytond modules.

This change introduces a new native-search-path GUIX_TRYTOND_MODULES_PATH.
Trytond gets patched to honor this environment variable.

Thanks to Maxim Cournoyer, who's code for guix-pythonpath-search-path
was the template for guix-trytonpath-search-path.

* gnu/packages/patches/trytond-add-guix_trytond_path.patch: New file.
* gnu/local.mk: (dist_patch_DATA): Add it.
* gnu/packages/tryton.scm (trytond): Use it.
  [native-search-paths]: New element.
  (guix-trytonpath-search-path): New function.
---
 gnu/local.mk                                  |  1 +
 .../trytond-add-guix_trytond_path.patch       | 26 +++++++++++++++++++
 gnu/packages/tryton.scm                       | 19 +++++++++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/trytond-add-guix_trytond_path.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a8b9bcac21..cac9079325 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1817,6 +1817,7 @@ dist_patch_DATA =						\
   %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/trytond-add-guix_trytond_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-guix_trytond_path.patch b/gnu/packages/patches/trytond-add-guix_trytond_path.patch
new file mode 100644
index 0000000000..7dc136ec46
--- /dev/null
+++ b/gnu/packages/patches/trytond-add-guix_trytond_path.patch
@@ -0,0 +1,26 @@
+Make trytond add all paths listed in GUIX_TRYTOND_MODULES_PATH to sys.path.
+
+*** a/trytond/modules/__init__.py	1970-01-01 01:00:01.000000000 +0100
+--- b/trytond/modules/__init__.py	2021-12-02 22:17:28.014612267 +0100
+***************
+*** 31,36 ****
+--- 31,48 ----
+  
+  EGG_MODULES = {}
+  
++ def __extend_python_path__():
++     tryton_python_path = os.environ.get("GUIX_TRYTOND_MODULES_PATH")
++     if tryton_python_path:
++         paths = [path[:-16]  # remove "/trytond/modules"
++                  for path in tryton_python_path.split(os.pathsep)]
++         sys.path.extend(paths)
++         # ensure new paths are in the pkg_resources WorkingSet
++         import pkg_resources
++         list(map(pkg_resources.working_set.add_entry, paths))
++ 
++ __extend_python_path__()
++ 
+  
+  def update_egg_modules():
+      global EGG_MODULES
+l
diff --git a/gnu/packages/tryton.scm b/gnu/packages/tryton.scm
index 212d6593ad..f8cd2b4c9d 100644
--- a/gnu/packages/tryton.scm
+++ b/gnu/packages/tryton.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;; Copyright © 2021 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -39,6 +40,19 @@
   #:use-module (guix utils)
   #:use-module (guix build-system python))
 
+(define (guix-trytonpath-search-path version)
+  "Generate a GUIX_TRYTOND_MODULES_PATH search path specification, using
+VERSION.
+
+Do not use PYTHHONPATH not avoid interfering with any different Python package
+installed in the same environments.  Collecting only paths actually containing
+/tryton/modules reduces the number of paths."
+  (search-path-specification (variable "GUIX_TRYTOND_MODULES_PATH")
+                             (files (list (string-append
+                                           "lib/python"
+                                           (version-major+minor version)
+                                           "/site-packages/trytond/modules")))))
+
 (define-public trytond
   (package
     (name "trytond")
@@ -49,7 +63,8 @@
        (uri (pypi-uri "trytond" version))
        (sha256
         (base32 "1jp5cadqpwkcnml8r1hj6aak5kc8an2d5ai62p96x77nn0dp3ny4"))
-       (patches (search-patches "trytond-add-egg-modules-to-path.patch"))))
+       (patches (search-patches "trytond-add-egg-modules-to-path.patch"
+                                "trytond-add-guix_trytond_path.patch"))))
     (build-system python-build-system)
     (propagated-inputs
      `(("python-dateutil" ,python-dateutil)
@@ -66,6 +81,8 @@
     (native-inputs
      `(("python-mock" ,python-mock)
        ("python-pillow" ,python-pillow)))
+    (native-search-paths
+     (list (guix-trytonpath-search-path (package-version python))))
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-- 
2.30.2





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#52259] [PATCH 3/3] gnu: trytond: Ensure all modules are found.
  2021-12-03 13:41 ` [bug#52259] [PATCH 3/3] gnu: trytond: Ensure all modules are found Hartmut Goebel
@ 2021-12-14  8:15   ` zimoun
  2021-12-18 14:21     ` Hartmut Goebel
  0 siblings, 1 reply; 7+ messages in thread
From: zimoun @ 2021-12-14  8:15 UTC (permalink / raw)
  To: Hartmut Goebel, 52259

Hi,

On Fri, 03 Dec 2021 at 14:41, Hartmut Goebel <h.goebel@crazy-compilers.com> wrote:
> If the python package matching tryton is not installed alongside to trytond,
> PYTHONPATH ist not set (or pointing to a wring version) and trytond (and the
              ^
              typo

> trytond tools) would not find the trytond modules.
>
> This change introduces a new native-search-path GUIX_TRYTOND_MODULES_PATH.
> Trytond gets patched to honor this environment variable.
>
> Thanks to Maxim Cournoyer, who's code for guix-pythonpath-search-path
> was the template for guix-trytonpath-search-path.

The wording appears to me weird, but I am not native.


> * gnu/packages/patches/trytond-add-guix_trytond_path.patch: New file.

Without being picky, why underscore?     ^       ^  Otherwise,

gnu/packages/patches/trytond-add_extend_python_path.patch

Well, it does not matter.


Cheers,
simon





^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#52259] [PATCH 3/3] gnu: trytond: Ensure all modules are found.
  2021-12-14  8:15   ` zimoun
@ 2021-12-18 14:21     ` Hartmut Goebel
  2021-12-18 15:17       ` zimoun
  0 siblings, 1 reply; 7+ messages in thread
From: Hartmut Goebel @ 2021-12-18 14:21 UTC (permalink / raw)
  To: zimoun, 52259

Hi,

thanks for the review. I fixed and pushed as 
d4ecdc3328d998c787cbdad6d02e1a74d2fc7ac4


>> Thanks to Maxim Cournoyer, who's code for guix-pythonpath-search-path
>> was the template for guix-trytonpath-search-path.
> The wording appears to me weird, but I am not native.

"whose" is the correct spelling - anyhow I'm not native, too.


>> * gnu/packages/patches/trytond-add-guix_trytond_path.patch: New file.
> Without being picky, why underscore?     ^       ^  Otherwise,

Underscores since this is the name of the functions added. Other patch 
files do the same, "agg-am_c_prototype.patch" - thus I kept the name.


-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#52259: Acknowledgement ([PATCH 1/3] gnu: python-stdnum: Update to 1.17.)
       [not found] ` <handler.52259.B.16385387683881.ack@debbugs.gnu.org>
@ 2021-12-18 14:21   ` Hartmut Goebel
  0 siblings, 0 replies; 7+ messages in thread
From: Hartmut Goebel @ 2021-12-18 14:21 UTC (permalink / raw)
  To: 52259-close






^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#52259] [PATCH 3/3] gnu: trytond: Ensure all modules are found.
  2021-12-18 14:21     ` Hartmut Goebel
@ 2021-12-18 15:17       ` zimoun
  0 siblings, 0 replies; 7+ messages in thread
From: zimoun @ 2021-12-18 15:17 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: 52259

Hi Hartmut,

On Sat, 18 Dec 2021 at 15:21, Hartmut Goebel
<h.goebel@crazy-compilers.com> wrote:

> thanks for the review. I fixed and pushed as
> d4ecdc3328d998c787cbdad6d02e1a74d2fc7ac4

Thanks!

> >> * gnu/packages/patches/trytond-add-guix_trytond_path.patch: New file.
> > Without being picky, why underscore?     ^       ^  Otherwise,
>
> Underscores since this is the name of the functions added. Other patch
> files do the same, "agg-am_c_prototype.patch" - thus I kept the name.

In this consistency case, as I suggested, it should be:

    gnu/packages/patches/trytond-add_extend_python_path.patch

Anyway. :-)

Cheers,
simon




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-18 15:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 13:39 [bug#52259] [PATCH 1/3] gnu: python-stdnum: Update to 1.17 Hartmut Goebel
2021-12-03 13:41 ` [bug#52259] [PATCH 2/3] gnu: trytond: Fix import of trytond modules Hartmut Goebel
2021-12-03 13:41 ` [bug#52259] [PATCH 3/3] gnu: trytond: Ensure all modules are found Hartmut Goebel
2021-12-14  8:15   ` zimoun
2021-12-18 14:21     ` Hartmut Goebel
2021-12-18 15:17       ` zimoun
     [not found] ` <handler.52259.B.16385387683881.ack@debbugs.gnu.org>
2021-12-18 14:21   ` bug#52259: Acknowledgement ([PATCH 1/3] gnu: python-stdnum: Update to 1.17.) Hartmut Goebel

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.