From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mLODDXVQO2E7VgEAgWs5BA (envelope-from ) for ; Fri, 10 Sep 2021 14:32:53 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KKZGCXVQO2HlWwAA1q6Kng (envelope-from ) for ; Fri, 10 Sep 2021 12:32:53 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B05A9B678 for ; Fri, 10 Sep 2021 14:32:52 +0200 (CEST) Received: from localhost ([::1]:51736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOfi7-0007wZ-Ol for larch@yhetil.org; Fri, 10 Sep 2021 08:32:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOefX-0001lJ-NH for guix-patches@gnu.org; Fri, 10 Sep 2021 07:26:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOefX-0001Ht-Ef for guix-patches@gnu.org; Fri, 10 Sep 2021 07:26:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mOefX-0007xs-C6 for guix-patches@gnu.org; Fri, 10 Sep 2021 07:26:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50505] [PATCH 10/12] gnu: Add python-manimpango. Resent-From: Daniel =?UTF-8?Q?Mei=C3=9Fner?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 10 Sep 2021 11:26:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50505 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50505@debbugs.gnu.org Cc: Daniel =?UTF-8?Q?Mei=C3=9Fner?= Received: via spool by 50505-submit@debbugs.gnu.org id=B50505.163127314530506 (code B ref 50505); Fri, 10 Sep 2021 11:26:07 +0000 Received: (at 50505) by debbugs.gnu.org; 10 Sep 2021 11:25:45 +0000 Received: from localhost ([127.0.0.1]:37068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOefA-0007vy-Ox for submit@debbugs.gnu.org; Fri, 10 Sep 2021 07:25:45 -0400 Received: from out3.mail.ruhr-uni-bochum.de ([134.147.53.155]:35794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOeew-0007tc-LJ for 50505@debbugs.gnu.org; Fri, 10 Sep 2021 07:25:42 -0400 Received: from mx3.mail.ruhr-uni-bochum.de (localhost [127.0.0.1]) by out3.mail.ruhr-uni-bochum.de (Postfix mo-ext) with ESMTP id 4H5YT11hv5z8SLF for <50505@debbugs.gnu.org>; Fri, 10 Sep 2021 13:25:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ruhr-uni-bochum.de; s=mail-2017; t=1631273125; bh=rhKcr/q6nNDzhelvlpbRtiRq7DKzxO38tfkHMwnSsWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k31GHyxBvpV+arftAltbVWg0xV9yPTuuyRIWTb2xFZ3hrfPepIDchjzuS3iQobPA0 6V/FlbF9eF2TGUKtW4RD5fLOfCqSszVkUsMThQZA+3cNZ1fqNLdKttjjACumkmh/xW qmAZBFbhuSASv+y2fF+XUrtKYcAzgbQtXS4OeyC4= Received: from out3.mail.ruhr-uni-bochum.de (localhost [127.0.0.1]) by mx3.mail.ruhr-uni-bochum.de (Postfix idis) with ESMTP id 4H5YT112L4z8SJk; Fri, 10 Sep 2021 13:25:25 +0200 (CEST) X-Envelope-Sender: X-RUB-Notes: Internal origin=IPv6:2a05:3e00:c:1001::8693:2aec Received: from mail2.mail.ruhr-uni-bochum.de (mail2.mail.ruhr-uni-bochum.de [IPv6:2a05:3e00:c:1001::8693:2aec]) by out3.mail.ruhr-uni-bochum.de (Postfix mi-int) with ESMTP id 4H5YT06vFqz8SKc; Fri, 10 Sep 2021 13:25:24 +0200 (CEST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.1 at mx3.mail.ruhr-uni-bochum.de Received: from xii-04.mg07.ruhr-uni-bochum.de (pm26.mg07.ruhr-uni-bochum.de [10.150.49.41]) by mail2.mail.ruhr-uni-bochum.de (Postfix) with ESMTPSA id 4H5YT05GWWzDgyd; Fri, 10 Sep 2021 13:25:24 +0200 (CEST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.0 at mail2.mail.ruhr-uni-bochum.de Date: Fri, 10 Sep 2021 13:25:00 +0200 Message-Id: <20210910112502.6466-10-daniel.meissner-i4k@ruhr-uni-bochum.de> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210910112502.6466-1-daniel.meissner-i4k@ruhr-uni-bochum.de> References: <20210910112231.6411-1-daniel.meissner-i4k@ruhr-uni-bochum.de> <20210910112502.6466-1-daniel.meissner-i4k@ruhr-uni-bochum.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Fri, 10 Sep 2021 08:32:06 -0400 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Daniel =?UTF-8?Q?Mei=C3=9Fner?= X-ACL-Warn: , Daniel =?UTF-8?Q?Mei=C3=9Fner?= via Guix-patches From: Daniel =?UTF-8?Q?Mei=C3=9Fner?= via Guix-patches via X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631277172; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=nOxpUm2F0mIuipzzId8baKjnVmA1Dr+kCX3MR9LASNU=; b=Yrbj9X69KDr6gSpX0FNkheW8HT1FnszwfTdVPa8HZ+cRHoSghbhEpeMvWqojPKDeR+aAQr pW5s271LlZDqQ4gxP6EhBVnTxnKu2i3UBMOdyn78uMakZcShQY234NCujrUH4jaHRPeStY pC0lDtPR0xKxnpjZqwqPuxLz0g3hDoerLmGflKADNiXrnZtq2aheVBAVk/Ta0zHkeuRPwa 51lt1ZzV91+BusqNVh92KxOlLvK/8J20DcDc6xREx3QsNXmuCxENEaidl/WExryTHUfQ60 pJ/k+A4vOrxs/uZvEWUYzOAJ4u8wG5KF8FnAHb6gef5CA+Hi9z7JOW1QfyH55g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631277172; a=rsa-sha256; cv=none; b=OX8OT9g9GjNr67+Vr/7J0Njj47l9kqgpYD5Sd+UUe6XUCvbm6bn8dJsYvz9GaajjtdLRQb BGKTcd3sWj0okVXNsLAgeO6DfodMBWJK6ZxatWVjD2rtw3OcYYx6hgMgK/3F7+uwovwkud w6NCH3niilmoXwXGzbXY7lzxLVvsWiued9b4zSZGXP3EeNE/4mm7OzSQUMwUmH7KAzLM/x H+8u0S0u4+6Xx5Zyoh5UneKGX1XXxC0eeIoS4K8o0Mx+m3rm4HakWDbtNA94ARsTexoK6a RztHO9nPEfvvgiETKGbjbPEFtZ9NlaaQSNYa1+UogQRdQz/91F5zQw1ZUlX6qA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=ruhr-uni-bochum.de header.s=mail-2017 header.b=k31GHyxB; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.41 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=ruhr-uni-bochum.de header.s=mail-2017 header.b=k31GHyxB; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: B05A9B678 X-Spam-Score: -1.41 X-Migadu-Scanner: scn0.migadu.com X-TUID: kq5B6noTSfzk * 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 175e691a63..87be4a1b0a 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -44,6 +44,7 @@ # Copyright © 2021 Arun Isaac # Copyright © 2021 Sharlatan Hellseher # Copyright © 2021 Dmitry Polyakov +# Copyright © 2021 Daniel Meißner # # 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-mox3-python3.6-compat.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