manimpango 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {manimpango-0.2.0/manimpango.egg-info → ManimPango-0.2.2/ManimPango.egg-info}/PKG-INFO +8 -4
- ManimPango-0.2.2/ManimPango.egg-info/SOURCES.txt +15 -0
- {manimpango-0.2.0 → ManimPango-0.2.2}/PKG-INFO +8 -4
- {manimpango-0.2.0 → ManimPango-0.2.2}/manimpango/__init__.py +2 -0
- ManimPango-0.2.2/manimpango/_version.py +2 -0
- {manimpango-0.2.0 → ManimPango-0.2.2}/manimpango/cmanimpango.pxd +6 -5
- {manimpango-0.2.0 → ManimPango-0.2.2}/manimpango/cmanimpango.pyx +8 -12
- ManimPango-0.2.2/pyproject.toml +2 -0
- ManimPango-0.2.2/setup.py +254 -0
- manimpango-0.2.0/manimpango/cmanimpango.c +0 -11483
- manimpango-0.2.0/manimpango.egg-info/SOURCES.txt +0 -14
- manimpango-0.2.0/setup.py +0 -120
- {manimpango-0.2.0 → ManimPango-0.2.2}/LICENSE +0 -0
- {manimpango-0.2.0 → ManimPango-0.2.2}/MANIFEST.in +0 -0
- {manimpango-0.2.0/manimpango.egg-info → ManimPango-0.2.2/ManimPango.egg-info}/dependency_links.txt +0 -0
- {manimpango-0.2.0/manimpango.egg-info → ManimPango-0.2.2/ManimPango.egg-info}/not-zip-safe +0 -0
- {manimpango-0.2.0/manimpango.egg-info → ManimPango-0.2.2/ManimPango.egg-info}/top_level.txt +0 -0
- {manimpango-0.2.0 → ManimPango-0.2.2}/README.md +0 -0
- {manimpango-0.2.0 → ManimPango-0.2.2}/setup.cfg +0 -0
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.2.
|
|
2
|
+
Name: ManimPango
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Bindings for Pango for using with Manim.
|
|
5
|
-
Home-page: https://
|
|
6
|
-
Author:
|
|
5
|
+
Home-page: https://manimpango.manim.community/
|
|
6
|
+
Author: Naveen M K
|
|
7
|
+
Author-email: naveen@syrusdark.website
|
|
7
8
|
Maintainer: The Manim Community Developers
|
|
8
9
|
License: UNKNOWN
|
|
10
|
+
Project-URL: Documentation, https://manimpango.manim.community/
|
|
11
|
+
Project-URL: Source, https://github.com/ManimCommunity/manimpango
|
|
12
|
+
Project-URL: Release notes, https://github.com/ManimCommunity/ManimPango/releases/
|
|
9
13
|
Description: # ManimPango
|
|
10
14
|
|
|
11
15
|
<p align="center">
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.cfg
|
|
6
|
+
setup.py
|
|
7
|
+
ManimPango.egg-info/PKG-INFO
|
|
8
|
+
ManimPango.egg-info/SOURCES.txt
|
|
9
|
+
ManimPango.egg-info/dependency_links.txt
|
|
10
|
+
ManimPango.egg-info/not-zip-safe
|
|
11
|
+
ManimPango.egg-info/top_level.txt
|
|
12
|
+
manimpango/__init__.py
|
|
13
|
+
manimpango/_version.py
|
|
14
|
+
manimpango/cmanimpango.pxd
|
|
15
|
+
manimpango/cmanimpango.pyx
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.2.
|
|
2
|
+
Name: ManimPango
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Bindings for Pango for using with Manim.
|
|
5
|
-
Home-page: https://
|
|
6
|
-
Author:
|
|
5
|
+
Home-page: https://manimpango.manim.community/
|
|
6
|
+
Author: Naveen M K
|
|
7
|
+
Author-email: naveen@syrusdark.website
|
|
7
8
|
Maintainer: The Manim Community Developers
|
|
8
9
|
License: UNKNOWN
|
|
10
|
+
Project-URL: Documentation, https://manimpango.manim.community/
|
|
11
|
+
Project-URL: Source, https://github.com/ManimCommunity/manimpango
|
|
12
|
+
Project-URL: Release notes, https://github.com/ManimCommunity/ManimPango/releases/
|
|
9
13
|
Description: # ManimPango
|
|
10
14
|
|
|
11
15
|
<p align="center">
|
|
@@ -169,16 +169,17 @@ IF UNAME_SYSNAME == "Linux":
|
|
|
169
169
|
void FcConfigAppFontClear(void*)
|
|
170
170
|
ELIF UNAME_SYSNAME == "Windows":
|
|
171
171
|
cdef extern from "windows.h":
|
|
172
|
-
ctypedef
|
|
172
|
+
ctypedef Py_UNICODE WCHAR
|
|
173
|
+
ctypedef const WCHAR* LPCWSTR
|
|
173
174
|
ctypedef enum DWORD:
|
|
174
175
|
FR_PRIVATE
|
|
175
|
-
int
|
|
176
|
-
|
|
176
|
+
int AddFontResourceExW(
|
|
177
|
+
LPCWSTR name,
|
|
177
178
|
DWORD fl,
|
|
178
179
|
unsigned int res
|
|
179
180
|
)
|
|
180
|
-
bint
|
|
181
|
-
|
|
181
|
+
bint RemoveFontResourceExW(
|
|
182
|
+
LPCWSTR name,
|
|
182
183
|
DWORD fl,
|
|
183
184
|
unsigned int pdv
|
|
184
185
|
)
|
|
@@ -269,8 +269,8 @@ def text2svg(
|
|
|
269
269
|
class MarkupUtils:
|
|
270
270
|
@staticmethod
|
|
271
271
|
def validate(text: str) -> bool:
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
text_bytes = text.encode("utf-8")
|
|
273
|
+
return pango_parse_markup(text_bytes, -1, 0, NULL, NULL, NULL, NULL)
|
|
274
274
|
|
|
275
275
|
@staticmethod
|
|
276
276
|
def text2svg(
|
|
@@ -428,7 +428,7 @@ IF UNAME_SYSNAME == "Linux":
|
|
|
428
428
|
a=Path(font_path)
|
|
429
429
|
assert a.exists(), f"font doesn't exist at {a.absolute()}"
|
|
430
430
|
font_path = str(a.absolute())
|
|
431
|
-
font_path_bytes=font_path.encode('
|
|
431
|
+
font_path_bytes=font_path.encode('utf-8')
|
|
432
432
|
cdef const unsigned char* fontPath = font_path_bytes
|
|
433
433
|
fontAddStatus = FcConfigAppFontAddFile(FcConfigGetCurrent(), fontPath)
|
|
434
434
|
if fontAddStatus:
|
|
@@ -473,7 +473,7 @@ IF UNAME_SYSNAME == "Windows":
|
|
|
473
473
|
False means there was an unknown error
|
|
474
474
|
Examples
|
|
475
475
|
--------
|
|
476
|
-
>>> register_font("
|
|
476
|
+
>>> register_font("C:/home/roboto.tff")
|
|
477
477
|
1
|
|
478
478
|
Raises
|
|
479
479
|
------
|
|
@@ -483,10 +483,8 @@ IF UNAME_SYSNAME == "Windows":
|
|
|
483
483
|
a=Path(font_path)
|
|
484
484
|
assert a.exists(), f"font doesn't exist at {a.absolute()}"
|
|
485
485
|
font_path = str(a.absolute())
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
fontAddStatus = AddFontResourceExA(
|
|
489
|
-
font_path_bytes,
|
|
486
|
+
fontAddStatus = AddFontResourceExW(
|
|
487
|
+
<bytes>font_path,
|
|
490
488
|
FR_PRIVATE,
|
|
491
489
|
0
|
|
492
490
|
)
|
|
@@ -515,10 +513,8 @@ IF UNAME_SYSNAME == "Windows":
|
|
|
515
513
|
a=Path(font_path)
|
|
516
514
|
assert a.exists(), f"font doesn't exist at {a.absolute()}"
|
|
517
515
|
font_path = str(a.absolute())
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
return RemoveFontResourceExA(
|
|
521
|
-
font_path_bytes,
|
|
516
|
+
return RemoveFontResourceExW(
|
|
517
|
+
<bytes>font_path,
|
|
522
518
|
FR_PRIVATE,
|
|
523
519
|
0
|
|
524
520
|
)
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
import shlex
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
import warnings
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from shlex import quote
|
|
11
|
+
from subprocess import PIPE, Popen, check_call
|
|
12
|
+
|
|
13
|
+
from setuptools import Extension, setup
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
from Cython.Build import cythonize
|
|
17
|
+
|
|
18
|
+
USE_CYTHON = True
|
|
19
|
+
except ImportError:
|
|
20
|
+
USE_CYTHON = False
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_version():
|
|
24
|
+
version_file = "manimpango/_version.py"
|
|
25
|
+
with open(version_file) as f:
|
|
26
|
+
exec(compile(f.read(), version_file, "exec"))
|
|
27
|
+
return locals()["__version__"]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
NAME = "ManimPango"
|
|
31
|
+
MANIMPANGO_VERSION = get_version()
|
|
32
|
+
MINIMUM_PANGO_VERSION = "1.30.0"
|
|
33
|
+
DEBUG = False
|
|
34
|
+
|
|
35
|
+
if sys.platform == "win32" and sys.version_info >= (3, 10):
|
|
36
|
+
import atexit
|
|
37
|
+
|
|
38
|
+
atexit.register(
|
|
39
|
+
lambda: warnings.warn(
|
|
40
|
+
f"ManimPango {MANIMPANGO_VERSION} does not support Python "
|
|
41
|
+
f"{sys.version_info.major}.{sys.version_info.minor} and does not provide "
|
|
42
|
+
"prebuilt Windows binaries. We do not recommend building from source on "
|
|
43
|
+
"Windows.",
|
|
44
|
+
RuntimeWarning,
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class RequiredDependencyException(Exception):
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
NEEDED_LIBS = [
|
|
54
|
+
"pangocairo-1.0",
|
|
55
|
+
"pango-1.0",
|
|
56
|
+
"gobject-2.0",
|
|
57
|
+
"glib-2.0",
|
|
58
|
+
"intl",
|
|
59
|
+
"harfbuzz",
|
|
60
|
+
"cairo",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class PKG_CONFIG:
|
|
65
|
+
"""Preform operations with pkg-config.
|
|
66
|
+
Parameters
|
|
67
|
+
==========
|
|
68
|
+
libname : :class:`str`
|
|
69
|
+
The library name to query.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
def __init__(self, libname: str) -> None:
|
|
73
|
+
self.name = libname
|
|
74
|
+
self.pkg_config = os.environ.get("PKG_CONFIG", "pkg-config")
|
|
75
|
+
self.setup_argparse()
|
|
76
|
+
self.check_pkgconfig = self.check_pkgconfig()
|
|
77
|
+
|
|
78
|
+
def check_pkgconfig(self):
|
|
79
|
+
"""Check whether pkg-config works.
|
|
80
|
+
If it doesn't work raise a warning.
|
|
81
|
+
"""
|
|
82
|
+
try:
|
|
83
|
+
check_call([self.pkg_config, "--version"], stdout=subprocess.DEVNULL)
|
|
84
|
+
return True
|
|
85
|
+
except Exception:
|
|
86
|
+
warnings.warn(
|
|
87
|
+
f"{self.pkg_config} doesn't exists or doesn't seem to work"
|
|
88
|
+
"We assume that you give the compiler flags using"
|
|
89
|
+
"corresponding environment variables.",
|
|
90
|
+
RuntimeWarning,
|
|
91
|
+
)
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
def parse_cflags(self, raw_cflags):
|
|
95
|
+
"""Parse the flags from pkg-config using argparse."""
|
|
96
|
+
raw_args = shlex.split(raw_cflags.strip())
|
|
97
|
+
args, unknown = self._cflag_parser.parse_known_args(raw_args)
|
|
98
|
+
config = {k: v or [] for k, v in args.__dict__.items()}
|
|
99
|
+
for i, x in enumerate(config["define_macros"]):
|
|
100
|
+
parts = x.split("=", 1)
|
|
101
|
+
value = x[1] or None if len(x) == 2 else None
|
|
102
|
+
config["define_macros"][i] = (parts[0], value)
|
|
103
|
+
return config, " ".join(quote(x) for x in unknown)
|
|
104
|
+
|
|
105
|
+
def setup_argparse(self):
|
|
106
|
+
_cflag_parser = argparse.ArgumentParser(add_help=False)
|
|
107
|
+
_cflag_parser.add_argument("-I", dest="include_dirs", action="append")
|
|
108
|
+
_cflag_parser.add_argument("-L", dest="library_dirs", action="append")
|
|
109
|
+
_cflag_parser.add_argument("-l", dest="libraries", action="append")
|
|
110
|
+
_cflag_parser.add_argument("-D", dest="define_macros", action="append")
|
|
111
|
+
_cflag_parser.add_argument("-R", dest="runtime_library_dirs", action="append")
|
|
112
|
+
self._cflag_parser = _cflag_parser
|
|
113
|
+
|
|
114
|
+
def check_min_version(self, version):
|
|
115
|
+
"""Check whether the library of that version exists."""
|
|
116
|
+
command = [
|
|
117
|
+
self.pkg_config,
|
|
118
|
+
"--print-errors",
|
|
119
|
+
"--atleast-version",
|
|
120
|
+
version,
|
|
121
|
+
self.name,
|
|
122
|
+
]
|
|
123
|
+
try:
|
|
124
|
+
check_call(command, stdout=subprocess.DEVNULL)
|
|
125
|
+
return True
|
|
126
|
+
except Exception:
|
|
127
|
+
raise RequiredDependencyException("{self.name} >= {version} is required")
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def libs(self):
|
|
131
|
+
"""Get distutils-compatible extension extras for the given library.
|
|
132
|
+
This requires ``pkg-config``.
|
|
133
|
+
"""
|
|
134
|
+
if self.check_pkgconfig:
|
|
135
|
+
name = self.name
|
|
136
|
+
command = self.pkg_config
|
|
137
|
+
try:
|
|
138
|
+
proc = Popen(
|
|
139
|
+
[command, "--libs", name],
|
|
140
|
+
stdout=PIPE,
|
|
141
|
+
stderr=PIPE,
|
|
142
|
+
)
|
|
143
|
+
except Exception:
|
|
144
|
+
pass
|
|
145
|
+
raw_libs, _ = proc.communicate()
|
|
146
|
+
known_libs, unknown_libs = self.parse_cflags(raw_libs.decode("utf8"))
|
|
147
|
+
if unknown_libs:
|
|
148
|
+
known_libs["extra_link_args"] = unknown_libs.split()
|
|
149
|
+
return known_libs
|
|
150
|
+
return dict()
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def cflags(self):
|
|
154
|
+
if self.check_pkgconfig:
|
|
155
|
+
name = self.name
|
|
156
|
+
command = self.pkg_config
|
|
157
|
+
try:
|
|
158
|
+
proc = Popen(
|
|
159
|
+
[command, "--cflags", name],
|
|
160
|
+
stdout=PIPE,
|
|
161
|
+
stderr=PIPE,
|
|
162
|
+
)
|
|
163
|
+
except Exception:
|
|
164
|
+
pass
|
|
165
|
+
raw_cflags, _ = proc.communicate()
|
|
166
|
+
known_cflags, unknown_cflags = self.parse_cflags(raw_cflags.decode("utf8"))
|
|
167
|
+
if unknown_cflags:
|
|
168
|
+
known_cflags["extra_compile_args"] = unknown_cflags.split()
|
|
169
|
+
# return update_dict(known_cflags, known_libs)
|
|
170
|
+
return known_cflags
|
|
171
|
+
return dict()
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def setuptools_args(self):
|
|
175
|
+
return update_dict(self.libs, self.cflags)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def update_dict(dict1: dict, dict2: dict):
|
|
179
|
+
for key in dict1:
|
|
180
|
+
if key in dict2:
|
|
181
|
+
dict2[key] = dict1[key] + dict2[key]
|
|
182
|
+
else:
|
|
183
|
+
dict2[key] = dict1[key]
|
|
184
|
+
return dict2
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
ext = ".pyx" if USE_CYTHON else ".c"
|
|
188
|
+
base_file = Path(__file__).parent / "manimpango"
|
|
189
|
+
_pkg_config = PKG_CONFIG("pangocairo")
|
|
190
|
+
_pkg_config.check_min_version(MINIMUM_PANGO_VERSION)
|
|
191
|
+
returns = _pkg_config.setuptools_args
|
|
192
|
+
if not _pkg_config.check_pkgconfig:
|
|
193
|
+
returns["libraries"] = NEEDED_LIBS
|
|
194
|
+
if sys.platform == "win32":
|
|
195
|
+
returns["libraries"] += ["Gdi32"]
|
|
196
|
+
if hasattr(returns, "define_macros"):
|
|
197
|
+
returns["define_macros"] += [("UNICODE", 1)]
|
|
198
|
+
else:
|
|
199
|
+
returns["define_macros"] = [("UNICODE", 1)]
|
|
200
|
+
|
|
201
|
+
ext_modules = [
|
|
202
|
+
Extension(
|
|
203
|
+
"manimpango.cmanimpango",
|
|
204
|
+
[str(base_file / ("cmanimpango" + ext))],
|
|
205
|
+
**returns,
|
|
206
|
+
),
|
|
207
|
+
]
|
|
208
|
+
if USE_CYTHON:
|
|
209
|
+
ext_modules = cythonize(
|
|
210
|
+
ext_modules,
|
|
211
|
+
language_level=3,
|
|
212
|
+
include_path=["manimpango"],
|
|
213
|
+
gdb_debug=DEBUG,
|
|
214
|
+
)
|
|
215
|
+
with open("README.md") as fh:
|
|
216
|
+
long_description = fh.read()
|
|
217
|
+
|
|
218
|
+
setup(
|
|
219
|
+
name=NAME,
|
|
220
|
+
version=MANIMPANGO_VERSION,
|
|
221
|
+
author="Naveen M K",
|
|
222
|
+
author_email="naveen@syrusdark.website",
|
|
223
|
+
maintainer="The Manim Community Developers",
|
|
224
|
+
url="https://manimpango.manim.community/",
|
|
225
|
+
description="Bindings for Pango for using with Manim.",
|
|
226
|
+
long_description=long_description,
|
|
227
|
+
zip_safe=False,
|
|
228
|
+
long_description_content_type="text/markdown",
|
|
229
|
+
packages=["manimpango"],
|
|
230
|
+
python_requires=">=3.6",
|
|
231
|
+
platforms=["Linux", "macOS", "Windows"],
|
|
232
|
+
keywords=["cython", "pango", "cairo", "manim"],
|
|
233
|
+
classifiers=[
|
|
234
|
+
"Programming Language :: Python :: 3",
|
|
235
|
+
"Programming Language :: Python :: 3.6",
|
|
236
|
+
"Programming Language :: Python :: 3.7",
|
|
237
|
+
"Programming Language :: Python :: 3.8",
|
|
238
|
+
"Programming Language :: Python :: 3.9",
|
|
239
|
+
"Development Status :: 3 - Alpha",
|
|
240
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
241
|
+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
242
|
+
"Operating System :: OS Independent",
|
|
243
|
+
"Programming Language :: Cython",
|
|
244
|
+
],
|
|
245
|
+
project_urls={
|
|
246
|
+
"Documentation": "https://manimpango.manim.community/",
|
|
247
|
+
"Source": "https://github.com/ManimCommunity/manimpango",
|
|
248
|
+
"Release notes": "https://github.com/ManimCommunity/ManimPango/releases/",
|
|
249
|
+
},
|
|
250
|
+
ext_modules=ext_modules,
|
|
251
|
+
package_data={
|
|
252
|
+
"manimpango": ["*.pxd"],
|
|
253
|
+
},
|
|
254
|
+
)
|