From d5353a4085d573f2a18cc31f67393b6581ed1865 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Tue, 1 Dec 2020 19:36:56 -0600 Subject: [PATCH] Switch from brotlipy to brotlicffi for PyPy support --- Lib/fontTools/ttLib/woff2.py | 5 ++++- Tests/ttLib/woff2_test.py | 5 ++++- Tests/ttx/ttx_test.py | 5 ++++- setup.py | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Lib/fontTools/ttLib/woff2.py b/Lib/fontTools/ttLib/woff2.py index 67b1d1c10..75b55527c 100644 --- a/Lib/fontTools/ttLib/woff2.py +++ b/Lib/fontTools/ttLib/woff2.py @@ -19,7 +19,10 @@ log = logging.getLogger("fontTools.ttLib.woff2") haveBrotli = False try: - import brotli + try: + import brotlicffi as brotli + except ImportError: + import brotli haveBrotli = True except ImportError: pass diff --git a/Tests/ttLib/woff2_test.py b/Tests/ttLib/woff2_test.py index 2651e8085..661fd4485 100644 --- a/Tests/ttLib/woff2_test.py +++ b/Tests/ttLib/woff2_test.py @@ -21,7 +21,10 @@ import pytest haveBrotli = False try: - import brotli + try: + import brotlicffi as brotli + except ImportError: + import brotli haveBrotli = True except ImportError: pass diff --git a/Tests/ttx/ttx_test.py b/Tests/ttx/ttx_test.py index 753cc9ce2..3d4c3f92b 100644 --- a/Tests/ttx/ttx_test.py +++ b/Tests/ttx/ttx_test.py @@ -18,7 +18,10 @@ try: except ImportError: zopfli = None try: - import brotli + try: + import brotlicffi as brotli + except ImportError: + import brotli except ImportError: brotli = None diff --git a/setup.py b/setup.py index 2cd2ccb0c..8a04da167 100755 --- a/setup.py +++ b/setup.py @@ -82,8 +82,8 @@ extras_require = { # for fontTools.sfnt and fontTools.woff2: to compress/uncompress # WOFF 1.0 and WOFF 2.0 webfonts. "woff": [ - "brotli >= 1.0.1; platform_python_implementation != 'PyPy'", - "brotlipy >= 0.7.0; platform_python_implementation == 'PyPy'", + "brotli >= 1.0.1; platform_python_implementation == 'CPython'", + "brotlicffi >= 0.8.0; platform_python_implementation != 'CPython'", "zopfli >= 0.1.4", ], # for fontTools.unicode and fontTools.unicodedata: to use the latest version