Skip to content

Commit 6a51476

Browse files
committed
Require raqm>=0.2 (extern C in header).
1 parent 43e0a8c commit 6a51476

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

README.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ As usual, install using pip::
5555

5656
python -mpip install mplcairo
5757

58-
mplcairo can use Raqm_ for complex text layout if it is available. Refer to
58+
mplcairo can use Raqm_ (≥0.2) for complex text layout if it is available. Refer to
5959
the instructions on that project's website for installation on Linux and OSX.
6060
You may want to look at https://github.com/HOST-Oman/libraqm-cmake for Windows
6161
build scripts.
@@ -92,11 +92,6 @@ can be built and installed using any of the standard commands (``pip wheel
9292
--no-deps .``, ``pip install .``, ``pip install -e .`` and ``python setup.py
9393
build_ext -i`` being the most relevant ones).
9494

95-
If the ``MPLCAIRO_USE_LIBRAQM`` environment variable is set, the build also
96-
uses Raqm to perform complex text layout (right-to-left scripts, etc.). An
97-
installation of Raqm is required; run ``setup.py`` for instructions for Unix
98-
OSes.
99-
10095
Unix
10196
----
10297

@@ -116,8 +111,8 @@ The following additional dependencies are required:
116111
On Linux, they can also be installed with your distribution's package manager
117112
(Debian/Ubuntu: ``libcairo2-dev``, Fedora: ``cairo-devel``).
118113

119-
Raqm headers are also needed, but will be automatically downloaded if not
120-
found.
114+
Raqm (≥0.2) headers are also needed, but will be automatically downloaded if
115+
not found.
121116

122117
Linux
123118
`````
@@ -133,9 +128,9 @@ will be mis-linked and fail to load.
133128

134129
The manylinux wheel is built using ``tools/build-manylinux.sh``.
135130

136-
**NOTE**: On Arch Linux, the python-pillow 5.0.0-1 (Arch) package includes an
137-
invalid version ``raqm.h`` (https://bugs.archlinux.org/task/57492) and must not
138-
be installed while building a Raqm-enabled version of mplcairo using the system
131+
**NOTE**: On Arch Linux, the python-pillow (Arch) package includes an invalid
132+
version of ``raqm.h`` (https://bugs.archlinux.org/task/57492) and must not be
133+
installed while building a Raqm-enabled version of mplcairo using the system
139134
Python, even in a virtualenv (it can be installed when *using* mplcairo without
140135
causing any problems). One solution is to temporarily uninstall the package;
141136
another one is to package it yourself using e.g. pypi2pkgbuild_.

setup.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@
2121
from setupext import Extension, build_ext, find_packages, setup
2222

2323

24+
MIN_CAIRO_VERSION = "1.11.4"
25+
MIN_RAQM_VERSION = "0.2.0"
2426
RAQM_TAG = "v0.5.0"
2527

2628

2729
def get_pkg_config(info, lib):
28-
if os.environ.get("MANYLINUX") and info == "--cflags":
29-
return ["-static-libgcc", "-static-libstdc++",
30-
"-I/usr/include/cairo",
31-
"-I/usr/include/freetype2"]
30+
if os.environ.get("MANYLINUX"):
31+
if info.startswith("--atleast-version"):
32+
if lib == "raqm":
33+
raise FileNotFoundError # Trigger the header download.
34+
else:
35+
return ""
36+
if info == "--cflags":
37+
return ["-static-libgcc", "-static-libstdc++",
38+
"-I/usr/include/cairo",
39+
"-I/usr/include/freetype2"]
3240
return shlex.split(subprocess.check_output(["pkg-config", info, lib],
3341
universal_newlines=True))
3442

@@ -77,7 +85,8 @@ def build_extensions(self):
7785
pybind11.get_include(), pybind11.get_include(user=True)])
7886

7987
try:
80-
get_pkg_config("--exists", "raqm")
88+
get_pkg_config(
89+
"--atleast-version={}".format(MIN_RAQM_VERSION), "raqm")
8190
except (FileNotFoundError, CalledProcessError):
8291
with urllib.request.urlopen(
8392
"https://raw.githubusercontent.com/HOST-Oman/libraqm/"
@@ -87,6 +96,8 @@ def build_extensions(self):
8796

8897
if sys.platform == "linux":
8998
import cairo
99+
get_pkg_config(
100+
"--atleast-version={}".format(MIN_CAIRO_VERSION), "cairo")
90101
ext.include_dirs += [cairo.get_include()]
91102
ext.extra_compile_args += (
92103
["-std=c++1z", "-fvisibility=hidden", "-flto",
@@ -103,6 +114,8 @@ def build_extensions(self):
103114

104115
elif sys.platform == "darwin":
105116
import cairo
117+
get_pkg_config(
118+
"--atleast-version={}".format(MIN_CAIRO_VERSION), "cairo")
106119
ext.include_dirs += [cairo.get_include()]
107120
ext.extra_compile_args += (
108121
# version-min=10.9 avoids deprecation warning wrt. libstdc++.

src/_feature_tests.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@
77
#if defined __clang__ && !defined _LIBCPP_VERSION
88
#error "Compilation with Clang requires using libc++, not libstdc++."
99
#endif
10-
11-
#if !__has_include(<raqm.h>)
12-
#error "Please download raqm.h and place it in the include/ directory. " \
13-
"You may want to use tools/download_raqm_header.py."
14-
#endif

0 commit comments

Comments
 (0)