all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Daniel Meißner via Guix-patches via" <guix-patches@gnu.org>
To: 50505@debbugs.gnu.org
Cc: "Daniel Meißner" <daniel.meissner-i4k@ruhr-uni-bochum.de>
Subject: [bug#50505] [PATCH v2 10/13] gnu: Add python-manimpango.
Date: Wed, 15 Sep 2021 17:25:16 +0200	[thread overview]
Message-ID: <20210915152519.25572-11-daniel.meissner-i4k@ruhr-uni-bochum.de> (raw)
In-Reply-To: <20210910112231.6411-1-daniel.meissner-i4k@ruhr-uni-bochum.de>

* gnu/packages/python-science.scm (python-manimpango): New variable.
---
 gnu/local.mk                                  |   2 +
 .../python-manimpango-remove-manim-dep.patch  | 172 ++++++++++++++++++
 gnu/packages/python-science.scm               |  28 +++
 3 files changed, 202 insertions(+)
 create mode 100644 gnu/packages/patches/python-manimpango-remove-manim-dep.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d738f97ca8..640b9e3b95 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -44,6 +44,7 @@
 # Copyright © 2021 Arun Isaac <arunisaac@systemreboot.net>
 # Copyright © 2021 Sharlatan Hellseher <sharlatanus@gmail.com>
 # Copyright © 2021 Dmitry Polyakov <polyakov@liltechdude.xyz>
+# Copyright © 2021 Daniel Meißner <daniel.meissner-i4k@ruhr-uni-bochum.de>
 #
 # This file is part of GNU Guix.
 #
@@ -1646,6 +1647,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/python-pyfakefs-remove-bad-test.patch	\
   %D%/packages/patches/python-flint-includes.patch		\
   %D%/packages/patches/python-libxml2-utf8.patch		\
+  %D%/packages/patches/python-manimpango-remove-manim-dep.patch \
   %D%/packages/patches/python-matplotlib-run-under-wayland-gtk3.patch	\
   %D%/packages/patches/python-memcached-syntax-warnings.patch	\
   %D%/packages/patches/python-moderngl-window-skip-tests.patch  \
diff --git a/gnu/packages/patches/python-manimpango-remove-manim-dep.patch b/gnu/packages/patches/python-manimpango-remove-manim-dep.patch
new file mode 100644
index 0000000000..579c2302d8
--- /dev/null
+++ b/gnu/packages/patches/python-manimpango-remove-manim-dep.patch
@@ -0,0 +1,172 @@
+Fix dependency on manim for tests
+
+This fixes a circular dependency between manim and manimpango.
+
+Extracted from upstream:
+https://github.com/ManimCommunity/ManimPango/commit/7e2b17aa14b10bd58af0598cc2de51a406682797
+
+diff --git a/tests/_manim.py b/tests/_manim.py
+index 3ea4676..b11d3e9 100644
+--- a/tests/_manim.py
++++ b/tests/_manim.py
+@@ -2,11 +2,12 @@
+ """This file contains helpers for the tests copied and modified
+ from Manim.
+ """
+-
++import copy
+ import os
++import re
+ from pathlib import Path
+
+-from manimpango import Alignment, MarkupUtils
++from manimpango import Alignment, MarkupUtils, TextSetting, text2svg
+
+
+ class MarkupText:
+@@ -104,3 +105,115 @@ class MarkupText:
+
+     def __repr__(self):
+         return f"MarkupText({repr(self.original_text)})"
++
++
++class Text:
++    def __init__(
++        self,
++        text: str,
++        fill_opacity: float = 1.0,
++        stroke_width: int = 0,
++        size: int = 1,
++        line_spacing: int = -1,
++        font: str = "",
++        slant: str = "NORMAL",
++        weight: str = "NORMAL",
++        gradient: tuple = None,
++        tab_width: int = 4,
++        disable_ligatures: bool = False,
++        filename: str = "text.svg",
++        **kwargs,
++    ) -> None:
++        self.size = size
++        self.filename = filename
++        self.line_spacing = line_spacing
++        self.font = font
++        self.slant = slant
++        self.weight = weight
++        self.gradient = gradient
++        self.tab_width = tab_width
++        self.original_text = text
++        self.disable_ligatures = disable_ligatures
++        text_without_tabs = text
++        self.t2f = self.t2s = self.t2w = {}
++        if text.find("\t") != -1:
++            text_without_tabs = text.replace("\t", " " * self.tab_width)
++        self.text = text_without_tabs
++        if self.line_spacing == -1:
++            self.line_spacing = self.size + self.size * 0.3
++        else:
++            self.line_spacing = self.size + self.size * self.line_spacing
++        self.text2svg()
++
++    def text2settings(self):
++        """Internally used function. Converts the texts and styles
++        to a setting for parsing."""
++        settings = []
++        t2x = [self.t2f, self.t2s, self.t2w]
++        for i in range(len(t2x)):
++            fsw = [self.font, self.slant, self.weight]
++            if t2x[i]:
++                for word, x in list(t2x[i].items()):
++                    for start, end in self.find_indexes(word, self.text):
++                        fsw[i] = x
++                        settings.append(TextSetting(start, end, *fsw))
++        # Set all text settings (default font, slant, weight)
++        fsw = [self.font, self.slant, self.weight]
++        settings.sort(key=lambda setting: setting.start)
++        temp_settings = settings.copy()
++        start = 0
++        for setting in settings:
++            if setting.start != start:
++                temp_settings.append(TextSetting(start, setting.start, *fsw))
++            start = setting.end
++        if start != len(self.text):
++            temp_settings.append(TextSetting(start, len(self.text), *fsw))
++        settings = sorted(temp_settings, key=lambda setting: setting.start)
++
++        if re.search(r"\n", self.text):
++            line_num = 0
++            for start, end in self.find_indexes("\n", self.text):
++                for setting in settings:
++                    if setting.line_num == -1:
++                        setting.line_num = line_num
++                    if start < setting.end:
++                        line_num += 1
++                        new_setting = copy.copy(setting)
++                        setting.end = end
++                        new_setting.start = end
++                        new_setting.line_num = line_num
++                        settings.append(new_setting)
++                        settings.sort(key=lambda setting: setting.start)
++                        break
++        for setting in settings:
++            if setting.line_num == -1:
++                setting.line_num = 0
++        return settings
++
++    def text2svg(self):
++        """Internally used function.
++        Convert the text to SVG using Pango
++        """
++        size = self.size * 10
++        line_spacing = self.line_spacing * 10
++        dir_name = Path(self.filename).parent
++        disable_liga = self.disable_ligatures
++        if not os.path.exists(dir_name):
++            os.makedirs(dir_name)
++        file_name = self.filename
++        settings = self.text2settings()
++        width = 600
++        height = 400
++
++        return text2svg(
++            settings,
++            size,
++            line_spacing,
++            disable_liga,
++            file_name,
++            30,
++            30,
++            width,
++            height,
++            self.text,
++        )
+diff --git a/tests/test_fonts.py b/tests/test_fonts.py
+index 51e7eb4..da42895 100644
+--- a/tests/test_fonts.py
++++ b/tests/test_fonts.py
+@@ -3,13 +3,12 @@ import sys
+ from pathlib import Path
+ from shutil import copyfile
+
+-import manim
+ import pytest
+
+ import manimpango
+
+ from . import FONT_DIR
+-from ._manim import MarkupText
++from ._manim import MarkupText, Text
+
+ font_lists = {
+     (FONT_DIR / "AdobeVFPrototype.ttf").absolute(): "Adobe Variable Font Prototype",
+@@ -38,7 +37,7 @@ def test_register_font(font_name):
+ @pytest.mark.parametrize("font_name", font_lists.values())
+ def test_warning(capfd, font_name):
+     print(font_name)
+-    manim.Text("Testing", font=font_name)
++    Text("Testing", font=font_name)
+     captured = capfd.readouterr()
+     assert "Pango-WARNING **" not in captured.err, "Looks like pango raised a warning?"
+
+--
+2.32.0
diff --git a/gnu/packages/python-science.scm b/gnu/packages/python-science.scm
index d3730fadcc..fcd983520c 100644
--- a/gnu/packages/python-science.scm
+++ b/gnu/packages/python-science.scm
@@ -38,6 +38,7 @@
   #:use-module (gnu packages check)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages image-processing)
   #:use-module (gnu packages machine-learning)
   #:use-module (gnu packages maths)
@@ -982,3 +983,30 @@ pandas notebooks, scripts, and libraries.  Unlike other distributed DataFrame
 libraries, Modin provides seamless integration and compatibility with existing
 pandas code.")
     (license license:asl2.0)))
+
+(define-public python-manimpango
+  (package
+    (name "python-manimpango")
+    (version "0.3.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "ManimPango" version))
+       (sha256
+        (base32
+         "1j2mbhf7d82718nkc0r8x7cf35hlh13b67qkczjbbys3w24nyfsw"))
+       (patches (search-patches "python-manimpango-remove-manim-dep.patch"))))
+    (build-system python-build-system)
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("Cython" ,python-cython)
+       ("python-pytest" ,python-pytest)))
+    (inputs
+     `(("pango" ,pango)))
+    (home-page "https://manimpango.manim.community/")
+    (synopsis
+     "Bindings for pango for use with Manim")
+    (description
+     "These are Python bindings for Pango to be used with the mathematical
+animation software Manim.")
+    (license license:gpl3+)))
-- 
2.33.0





  parent reply	other threads:[~2021-09-15 15:29 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 11:22 [bug#50505] [PATCH 00/12] gnu: Add python-manim Daniel Meißner via Guix-patches via
2021-09-10 11:24 ` [bug#50505] [PATCH 01/12] gnu: Add python-cloup Daniel Meißner via Guix-patches via
2021-09-10 11:24   ` [bug#50505] [PATCH 02/12] gnu: Add python-cloup-0.7 Daniel Meißner via Guix-patches via
2021-09-10 11:24   ` [bug#50505] [PATCH 03/12] gnu: Add python-glcontext Daniel Meißner via Guix-patches via
2021-09-11 19:42     ` Xinglu Chen
2021-09-10 11:24   ` [bug#50505] [PATCH 04/12] gnu: Add python-moderngl Daniel Meißner via Guix-patches via
2021-09-11 19:46     ` Xinglu Chen
2021-09-10 11:24   ` [bug#50505] [PATCH 05/12] gnu: Add python-pyglet Daniel Meißner via Guix-patches via
2021-09-11 19:49     ` Xinglu Chen
2021-09-10 11:24   ` [bug#50505] [PATCH 06/12] gnu: Add python-multipledispatch Daniel Meißner via Guix-patches via
2021-09-11 19:52     ` Xinglu Chen
2021-09-10 11:24   ` [bug#50505] [PATCH 07/12] gnu: Add python-pyrr Daniel Meißner via Guix-patches via
2021-09-11 19:58     ` Xinglu Chen
2021-09-10 11:24   ` [bug#50505] [PATCH 08/12] gnu: Add python-screeninfo Daniel Meißner via Guix-patches via
2021-09-10 11:24   ` [bug#50505] [PATCH 09/12] gnu: Add python-moderngl-window Daniel Meißner via Guix-patches via
2021-09-10 11:25   ` [bug#50505] [PATCH 10/12] gnu: Add python-manimpango Daniel Meißner via Guix-patches via
2021-09-10 11:25   ` [bug#50505] [PATCH 11/12] gnu: Add python-mapbox-earcut Daniel Meißner via Guix-patches via
2021-09-10 11:25   ` [bug#50505] [PATCH 12/12] gnu: Add python-manim 0.9.0 Daniel Meißner via Guix-patches via
2021-09-11 19:33   ` [bug#50505] [PATCH 01/12] gnu: Add python-cloup Xinglu Chen
2021-09-15 14:54     ` Daniel Meißner via Guix-patches via
2021-09-10 14:40 ` [bug#50505] [PATCH 00/12] gnu: Add python-manim Liliana Marie Prikler
2021-09-13 14:30   ` Daniel Meißner via Guix-patches via
2021-09-13 14:46     ` Liliana Marie Prikler
2021-09-13 14:49       ` Liliana Marie Prikler
2021-09-15 14:32         ` Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 00/13] " Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 01/13] gnu: Add python-cloup Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 02/13] gnu: Add python-cloup-0.7 Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 03/13] gnu: Add python-glcontext Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 04/13] gnu: Add python-moderngl Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 05/13] gnu: Add python-pyglet Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 06/13] gnu: Add python-multipledispatch Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 07/13] gnu: Add python-pyrr Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 08/13] gnu: Add python-screeninfo Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 09/13] gnu: Add python-moderngl-window Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` Daniel Meißner via Guix-patches via [this message]
2021-09-15 15:25 ` [bug#50505] [PATCH v2 11/13] gnu: Add python-mapbox-earcut Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 12/13] gnu: Add python-screeninfo-0.6 Daniel Meißner via Guix-patches via
2021-09-15 15:25 ` [bug#50505] [PATCH v2 13/13] gnu: Add python-manim 0.9.0 Daniel Meißner via Guix-patches via
2022-01-01 23:51 ` [bug#50505] [PATCH v3 00/13] Add python-manim and its missing dependencies Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 01/12] gnu: Add python-cloup Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 02/12] gnu: Add python-cloup-0.7 Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 03/12] gnu: Add python-glcontext Daniel Meißner via Guix-patches via
2022-01-02  0:31     ` Liliana Marie Prikler
2022-01-01 23:51   ` [bug#50505] [PATCH v3 04/12] gnu: Add python-moderngl Daniel Meißner via Guix-patches via
2022-01-02  0:33     ` Liliana Marie Prikler
2022-01-01 23:51   ` [bug#50505] [PATCH v3 05/12] gnu: Add python-pyglet Daniel Meißner via Guix-patches via
2022-01-02  0:36     ` Liliana Marie Prikler
2022-01-01 23:51   ` [bug#50505] [PATCH v3 06/12] gnu: Add python-pyrr Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 07/12] gnu: Add python-screeninfo Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 08/12] gnu: Add python-moderngl-window Daniel Meißner via Guix-patches via
2022-01-02  0:47     ` Liliana Marie Prikler
2022-01-10  8:40       ` Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 09/12] gnu: Add python-manimpango Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 10/12] gnu: Add python-mapbox-earcut Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 11/12] gnu: Add python-screeninfo-0.6 Daniel Meißner via Guix-patches via
2022-01-01 23:51   ` [bug#50505] [PATCH v3 12/12] gnu: Add python-manim 0.9.0 Daniel Meißner via Guix-patches via
2022-01-02  0:52     ` Liliana Marie Prikler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210915152519.25572-11-daniel.meissner-i4k@ruhr-uni-bochum.de \
    --to=guix-patches@gnu.org \
    --cc=50505@debbugs.gnu.org \
    --cc=daniel.meissner-i4k@ruhr-uni-bochum.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.