emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#49543: closed ([PATCH] python-pycryptodome: Build HTML and info docu


From: GNU bug Tracking System
Subject: bug#49543: closed ([PATCH] python-pycryptodome: Build HTML and info documentation and unbundle sphinx-rtd-theme and libtomcrypt)
Date: Wed, 01 Sep 2021 21:29:02 +0000

Your message dated Wed, 01 Sep 2021 23:28:21 +0200
with message-id <8735qo6l56.fsf_-_@gnu.org>
and subject line Re: bug#49543: [PATCH] python-pycryptodome: Build HTML and 
info documentation and unbundle sphinx-rtd-theme and libtomcrypt
has caused the debbugs.gnu.org bug report #49543,
regarding [PATCH] python-pycryptodome: Build HTML and info documentation and 
unbundle sphinx-rtd-theme and libtomcrypt
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
49543: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=49543
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] python-pycryptodome: Build HTML and info documentation and unbundle sphinx-rtd-theme and libtomcrypt Date: Tue, 13 Jul 2021 14:31:29 +0200 User-agent: Evolution 3.34.2
X-Debbugs-CC: slg <0x2d@disroot.org>

Hi guix,

These two patches fix <https://issues.guix.gnu.org/49530>.
The dependencies of python-pycryptodome (found with "guix refresh -l")
still build succesfully.

I performed the unbundling in build phases as I'm not sure
what is the proper way to use 'tar' from a snippet, and whether
the unbundling is done in a build phase or an 'origin' snippet
doesn't seem to matter much, as the bundled code is free software.

Greetings,
Maxime.
From e9b497cbb8f04490b6c835c8b5ed9b92d2765781 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Mon, 12 Jul 2021 17:52:39 +0200
Subject: [PATCH 1/2] gnu: python-pycryptodome: Unbundle libtomcrypt.

* gnu/packages/python-crypto.scm
  (pycryptodome)[arguments]<#:phases>{replace-libtomcrypt}:
  New phase.
  (pycryptodome)[native-inputs]{tomcrypt-source}: Add source
  code of 'libtomcrypt'.
---
 gnu/packages/python-crypto.scm | 35 ++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/python-crypto.scm b/gnu/packages/python-crypto.scm
index 733a87cd2f..5eb990b5ba 100644
--- a/gnu/packages/python-crypto.scm
+++ b/gnu/packages/python-crypto.scm
@@ -24,6 +24,7 @@
 ;;; Copyright © 2020 Alexandros Theodotou <alex@zrythm.org>
 ;;; Copyright © 2020 Justus Winter <justus@sequoia-pgp.org>
 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -43,6 +44,7 @@
 (define-module (gnu packages python-crypto)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix build-system python)
   #:use-module (gnu packages)
@@ -1001,6 +1003,39 @@ protocol (Javascript Object Signing and Encryption).")
         (base32
          "1i4m74f88qj9ci8rpyzrbk2slmsdj5ipmwdkq6qk24byalm203li"))))
     (build-system python-build-system)
+    (arguments
+     `(#:modules ((srfi srfi-26)
+                  (guix build python-build-system)
+                  (guix build utils))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'replace-libtomcrypt
+           (lambda* (#:key native-inputs inputs #:allow-other-keys)
+             (with-directory-excursion "src/libtom"
+               ;; Delete bundled code.
+               (for-each delete-file (find-files "."))
+               ;; Extract tomcrypt source code into "untarred".
+               (mkdir "untarred")
+               (invoke "tar" "xf"
+                       (assoc-ref (or native-inputs inputs) "tomcrypt-source")
+                       "--strip-components=1"
+                       "-Cuntarred")
+               ;; Use source code from "untarred".
+               (rename-file "untarred/src/ciphers/des.c" "tomcrypt_des.c")
+               (for-each (cut install-file <> ".")
+                         (find-files "untarred/src/headers"))
+               (delete-file-recursively "untarred"))))
+         ;; The code bundled in pycryptdome has been modified
+         ;; to make some variables and functions 'static'.
+         (add-after 'replace-libtomcrypt 'make-des-static
+           (lambda _
+             (substitute* (find-files "src/libtom")
+               (("^extern const struct") "static const struct")
+               (("^const struct") "static const struct")
+               (("^int des") "static int des")
+               (("^void des") "static void des")))))))
+    (native-inputs
+     `(("tomcrypt-source" ,(package-source libtomcrypt))))
     (home-page "https://www.pycryptodome.org";)
     (synopsis "Low-level cryptographic Python library")
     (description
-- 
2.32.0

From 5e11b738571167dbb5ba59d9cfb3204dd81ca855 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Mon, 12 Jul 2021 20:30:06 +0200
Subject: [PATCH 2/2] gnu: python-pycryptodome: Build documentation.

* gnu/packages/python-crypto.scm
  (python-pycryptodome)[outputs]: Add "doc" output.
  (python-pycryptodome)[arguments]<#:phases>{build-documentation}:
  New phase, removing images loaded from the Internet, unbundling
  sphinx-rtd-theme and building HTML and Info documentation.
  (python-pycryptodome)[arguments]<#:phases>{build-documentation}:
  New phase.
---
 gnu/packages/python-crypto.scm | 35 ++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python-crypto.scm b/gnu/packages/python-crypto.scm
index 5eb990b5ba..cb3d0f9609 100644
--- a/gnu/packages/python-crypto.scm
+++ b/gnu/packages/python-crypto.scm
@@ -52,6 +52,7 @@
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages kerberos)
   #:use-module (gnu packages libffi)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages password-utils)
   #:use-module (gnu packages protobuf)
@@ -62,6 +63,7 @@
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages swig)
+  #:use-module (gnu packages texinfo)
   #:use-module (gnu packages time)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages xml)
@@ -1003,6 +1005,8 @@ protocol (Javascript Object Signing and Encryption).")
         (base32
          "1i4m74f88qj9ci8rpyzrbk2slmsdj5ipmwdkq6qk24byalm203li"))))
     (build-system python-build-system)
+    ;; "doc" has HTML documentation weighing 4.9 MB
+    (outputs '("out" "doc"))
     (arguments
      `(#:modules ((srfi srfi-26)
                   (guix build python-build-system)
@@ -1033,9 +1037,36 @@ protocol (Javascript Object Signing and Encryption).")
                (("^extern const struct") "static const struct")
                (("^const struct") "static const struct")
                (("^int des") "static int des")
-               (("^void des") "static void des")))))))
+               (("^void des") "static void des"))))
+         (add-after 'build 'build-documentation
+           (lambda _
+             ;; Prevent offline documentation from loading
+             ;; images from the Internet.
+             (substitute* "README.rst"
+               (("^(.*)travis-ci.org(.*)\n") "")
+               (("^(.*)ci.appveyor.com(.*)\n") ""))
+             ;; Unbundle sphinx-rtd-theme.
+             (delete-file-recursively "Doc/sphinx_rtd_theme")
+             (invoke "make" "-C" "Doc" "html" "info")))
+         (add-after 'install 'install-documentation
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((doc (string-append (assoc-ref outputs "doc")
+                                        "/share/doc/" ,name "-" ,version))
+                    (html (string-append doc "/html"))
+                    ;; The 'info' manual only weighs 72 KB
+                    (info (string-append (assoc-ref outputs "out")
+                                         "/share/info")))
+               (mkdir-p info)
+               (mkdir-p html)
+               (copy-recursively "Doc/_build/html" html)
+               (copy-recursively "Doc/_build/texinfo" info)
+               (delete-file (string-append info "/Makefile"))
+               (delete-file (string-append info "/PyCryptodome.texi"))))))))
     (native-inputs
-     `(("tomcrypt-source" ,(package-source libtomcrypt))))
+     `(("python-sphinx" ,python-sphinx)
+       ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
+       ("texinfo" ,texinfo)
+       ("tomcrypt-source" ,(package-source libtomcrypt))))
     (home-page "https://www.pycryptodome.org";)
     (synopsis "Low-level cryptographic Python library")
     (description
-- 
2.32.0

Attachment: signature.asc
Description: This is a digitally signed message part


--- End Message ---
--- Begin Message --- Subject: Re: bug#49543: [PATCH] python-pycryptodome: Build HTML and info documentation and unbundle sphinx-rtd-theme and libtomcrypt Date: Wed, 01 Sep 2021 23:28:21 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Hi!

Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op wo 11-08-2021 om 16:35 [+0200]:

[...]

>> Usually, bundled software is removed from a snippet.
>> 
>> Also, when unbundling, it’s better if we can actually reuse the package
>> in question (libtomcrypt here) as opposed to reusing its source, as you
>> did here.
>
> I have attached two new patches for unbundling libtomcrypt this way.
> I left the documentation out for now, as I would prefer some kind of
> generic solution that could be used by other packages using Sphinx
> as well.

Makes sense to me.

> I had some trouble telling python to link to libtomcrypt.
> I tried adding "tomcrypt" to "libraries" in ‘Extension’ forms in setup.py
> but that doesn't seem to do anything, so I added
> extra_link_args=['-ltomcrypt', '-ltommath'].  Do you know what's up with that?

No idea!

> From a41b086246a5b59aab2d16eaeb91e0caafa706cc Mon Sep 17 00:00:00 2001
> From: Maxime Devos <maximedevos@telenet.be>
> Date: Wed, 18 Aug 2021 00:43:16 +0200
> Subject: [PATCH 1/2] gnu: python-pycryptodome: Unbundle libtomcrypt.
>
> * gnu/packages/python-crypto.scm
>   (pycryptodome-unbundle-tomcrypt-snippet): New variable.
>   (python-pycryptodome)[source]{snippet}: Unbundle libtomcrypt.
>   (python-pycryptodome)[source]{modules}: Add (guix build utils).

[...]

> From 5b3366c9ebead99f0c22d612552063189bd0551c Mon Sep 17 00:00:00 2001
> From: Maxime Devos <maximedevos@telenet.be>
> Date: Wed, 18 Aug 2021 12:46:51 +0200
> Subject: [PATCH 2/2] gnu: python-pycryptodomex: Unbundle libtomcrypt.
>
> * gnu/packages/python-crypto.scm
>   (python-pycryptodomex)[source]{snippet}: Unbundle libtomcrypt.
>   (python-pycryptodomex)[source]{modules}: Add (guix build utils).

Finally applied, thanks!

Ludo’.


--- End Message ---

reply via email to

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