Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable API #48

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
env:
CIBW_BUILD: cp36-${{ matrix.platform_id }} cp37-${{ matrix.platform_id }} cp38-${{ matrix.platform_id }} cp39-${{ matrix.platform_id }}
CIBW_SKIP: pp* cp35
CIBW_BEFORE_BUILD_MACOS: "source packing/build_pango_mac.sh && pip install cython && cd manimpango && cythonize cmanimpango.pyx -3 -k -f && cd ../ && pip install . && pkg-config --libs pango"
CIBW_BEFORE_BUILD_WINDOWS: "pip install cython && python packing/download_dlls.py && cd manimpango && cythonize cmanimpango.pyx -3 -k -f && cd ../ && pkg-config --libs pango && pip install ."
CIBW_BEFORE_BUILD_MACOS: "source scripts/build_pango_mac.sh && pip install cython && cd manimpango && cythonize cmanimpango.pyx -3 -k -f && cd ../ && pip install . && pkg-config --libs pango"
CIBW_BEFORE_BUILD_WINDOWS: "pip install cython && python scripts/download_dlls.py && cd manimpango && cythonize cmanimpango.pyx -3 -k -f && cd ../ && pkg-config --libs pango && pip install ."
CIBW_ENVIRONMENT_WINDOWS: "PKG_CONFIG_PATH='C:\\cibw\\vendor\\lib\\pkgconfig'"
CIBW_ENVIRONMENT_MACOS: "PKG_CONFIG_PATH='/Users/runner/pangobuild/lib/pkgconfig'"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python packing/inject-dlls.py {wheel} {dest_dir} C:\cibw\vendor\bin
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python scripts/inject-dlls.py {wheel} {dest_dir} C:\cibw\vendor\bin
CIBW_TEST_REQUIRES: pytest Cython pytest-cov
CIBW_TEST_COMMAND: "bash {project}/packing/test_wheels.sh {project}"
CIBW_TEST_COMMAND: "bash {project}/scripts/test_wheels.sh {project}"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand All @@ -62,14 +62,14 @@ jobs:
$ErrorActionPreference = 'Stop'
$env:PATH="$env:PATH;C:\cibw\pkg-config\bin"
$env:PKG_CONFIG_PATH="C:\cibw\vendor\lib\pkgconfig"
Copy-Item packing/LICENSE.bin .
Copy-Item scripts/LICENSE.bin .
Rename-Item LICENSE.bin LICENSE.win32
python -m cibuildwheel --output-dir wheelhouse

- name: Build wheels (Non-Windows)
if: runner.os != 'windows'
run: |
cp packing/LICENSE.bin .
cp scripts/LICENSE.bin .
python -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v2
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ jobs:
uses: actions/cache@v2
with:
path: ~/pangoprefix
key: ${{ hashFiles('packing/build_pango_tests.sh') }}-${{ runner.os }}
key: ${{ hashFiles('scripts/build_pango_tests.sh') }}-${{ runner.os }}
- name: Install System Dependency
if: steps.cache-pango.outputs.cache-hit != 'true'
run: |
source packing/build_pango_tests.sh
source scripts/build_pango_tests.sh

- name: Install python dependencies
run: |
Expand All @@ -50,8 +50,6 @@ jobs:
- name: Run Tests
run: |
python setup.py build_ext -i --coverage
python setup.py sdist
pip install .
pytest
- name: Coverage
run: |
Expand Down Expand Up @@ -99,10 +97,7 @@ jobs:
- name: Run tests
shell: msys2 {0}
run: |
pip install .
python setup.py build_ext -i --coverage
python setup.py sdist
python -m pip install dist/*
pytest
- name: Coverage
shell: msys2 {0}
Expand Down Expand Up @@ -136,10 +131,10 @@ jobs:
uses: actions/cache@v2
with:
path: C:\cibw\pkg-config
key: ${{ hashFiles('packing/download_dlls.py') }}-${{ hashFiles('packing/build_pkgconfig.ps1') }}-1
key: ${{ hashFiles('scripts/download_dlls.py') }}-${{ hashFiles('scripts/build_pkgconfig.ps1') }}-1
- name: Download Binary
run: |
python packing/download_dlls.py
python scripts/download_dlls.py
- name: Set Path
run: |
$env:Path = "C:\cibw\pkg-config\bin;C:\cibw\vendor\bin;$($env:PATH)"
Expand All @@ -149,8 +144,6 @@ jobs:
$env:PKG_CONFIG_PATH="C:\cibw\vendor\lib\pkgconfig"
pip install -r requirements-dev.txt
python setup.py build_ext -i --coverage
python setup.py sdist
python -m pip install dist/*
$env:PATH="C:\cibw\vendor\bin;$env:PATH"
pytest
- name: Coverage
Expand All @@ -165,15 +158,13 @@ jobs:
architecture: "x86"
- name: Download Binary
run: |
python packing/download_dlls.py
python scripts/download_dlls.py
- name: Build x86 Build
run: |
$env:PATH="$env:PATH;C:\cibw\vendor\pkg-config\bin;C:\cibw\vendor\bin"
$env:PKG_CONFIG_PATH="C:\cibw\vendor\lib\pkgconfig"
pip install -r requirements-dev.txt
python setup.py build_ext -i --coverage
python setup.py sdist
python -m pip install dist/*
$env:PATH="C:\cibw\vendor\bin;$env:PATH"
pytest
- name: Coverage
Expand Down
1 change: 0 additions & 1 deletion docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:show-inheritance:
:members:

{% block methods %}
Expand Down
15 changes: 8 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
# import sys
# sys.path.insert(0, os.path.abspath(".."))


from pathlib import Path

import manimpango

# -- Project information -----------------------------------------------------
from pkg_resources import get_distribution

project = "ManimPango"
copyright = "2021, The Manim Community Dev Team"
author = "The Manim Community Dev Team"
copyright = "2021, Naveen M K"
author = "Naveen M K"

release = get_distribution("ManimPango").version
release = manimpango.__version__
version = ".".join(release.split(".")[:2])


Expand All @@ -42,6 +42,7 @@
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinxext.opengraph",
"sphinx_rtd_theme",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -58,7 +59,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "furo"
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -76,7 +77,7 @@
add_module_names = False

intersphinx_mapping = {
"manim": ("https://docs.manim.community/en/v0.2.0", None),
"manim": ("https://docs.manim.community/en/stable", None),
"python": ("https://docs.python.org/3", None),
}

Expand Down
38 changes: 27 additions & 11 deletions docs/reference.rst
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
Manimpango Reference
====================

.. currentmodule:: manimpango

************
Font Manager
************

.. autosummary::
:toctree: reference

manimpango.TextSetting
manimpango.PangoUtils
manimpango.text2svg
manimpango.MarkupUtils
manimpango.register_font
manimpango.unregister_font
manimpango.list_fonts
~FontProperties
~RegisterFont

*****
Enums
=====
*****

.. autosummary::
:toctree: reference

~Style
~Weight
~Variant
~Alignment

*****
Utils
*****

.. autosummary::
:toctree: reference

manimpango.Style
manimpango.Weight
manimpango.Variant
~Color
~pango_version
~cairo_version
~list_fonts
8 changes: 4 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: manimpango
name: '48'
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- ca-certificates=2020.12.8=h06a4308_0
- ca-certificates=2021.4.13=h06a4308_1
- cairo=1.14.12=h8948797_3
- certifi=2020.12.5=py37h06a4308_0
- fontconfig=2.13.0=h9420a91_0
Expand All @@ -23,7 +23,7 @@ dependencies:
- libxcb=1.14=h7b6447c_0
- libxml2=2.9.10=hb55368b_3
- ncurses=6.2=he6710b0_1
- openssl=1.1.1i=h27cfd23_0
- openssl=1.1.1k=h27cfd23_0
- pango=1.45.3=hd140c19_0
- pcre=8.44=he6710b0_0
- pip=20.3.3=py37h06a4308_0
Expand All @@ -32,6 +32,7 @@ dependencies:
- python=3.7.9=h7579374_0
- readline=8.0=h7b6447c_0
- setuptools=51.0.0=py37h06a4308_2
- sphinx_rtd_theme=0.4.3=py_0
- sqlite=3.33.0=h62c20be_0
- tk=8.6.10=hbc83047_0
- wheel=0.36.2=pyhd3eb1b0_0
Expand All @@ -44,7 +45,6 @@ dependencies:
- chardet==4.0.0
- cython==0.29.21
- docutils==0.16
- furo==2021.3.20b30
- idna==2.10
- imagesize==1.2.0
- jinja2==2.11.2
Expand Down
24 changes: 12 additions & 12 deletions manimpango/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# -*- coding: utf-8 -*-
import os
import sys

from . import _distributor_init # noqa: F401
from ._version import __version__ # noqa: F403,F401

if os.name == "nt": # pragma: no cover
os.environ["PATH"] = (
f"{os.path.abspath(os.path.dirname(__file__))}"
f"{os.pathsep}"
f"{os.environ['PATH']}"
)
try:
from .cmanimpango import * # noqa: F403,F401
from .enums import * # noqa: F403,F401
from .register_font import * # noqa: F403,F401
from .utils import * # noqa: F403,F401

initialize_glib() # noqa: F405

# utils should be imported first
from .font_manager import * # noqa: F403,F401
from .layout import * # noqa: F403,F401
from .renderer import * # noqa: F403,F401


except ImportError as ie: # pragma: no cover
py_ver = ".".join(map(str, sys.version_info[:3]))
msg = f"""

ManimPango could not import and load the necessary shared libraries.
ManimPango could not import and initialize itself.
This error may occur when ManimPango and its dependencies are improperly set up.
Please make sure the following versions are what you expect:

Expand Down
21 changes: 21 additions & 0 deletions manimpango/_distributor_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
"""
Helper to preload windows dlls to prevent dll not found errors.
Once a DLL is preloaded, its namespace is made available to any
subsequent DLL.
"""
import glob
import os

if os.name == "nt": # pragma: no cover
try:
from ctypes import WinDLL

basedir = os.path.dirname(__file__)
except: # noqa: E722
pass
else:
for filename in glob.glob(os.path.join(basedir, "*.dll")):
WinDLL(os.path.abspath(filename))
if hasattr(os, "add_dll_directory"):
os.add_dll_directory(basedir)
Empty file.
19 changes: 19 additions & 0 deletions manimpango/bufferproxy/bufferproxy.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cdef class BaseBuffer:
cdef size_t _buffer_size(self)
cdef void* _buffer_ptr(self)
cdef bint _buffer_writable(self)


cdef class ImageBuffer(Buffer):
cdef int size
cdef unsigned char *buf
cdef cairo_t* cr
cdef cairo_surface_t* surface
cdef int set_cairo_data(
self,
cairo_t* cr,
cairo_surface_t* surface
)
cdef size_t _buffer_size(self)
cdef void* _buffer_ptr(self)
cdef bint _buffer_writable(self)
Loading