Skip to content

Commit 044a5e5

Browse files
committed
BLD: Use Meson to build extensions
1 parent 6665b26 commit 044a5e5

File tree

20 files changed

+1982
-12
lines changed

20 files changed

+1982
-12
lines changed

.circleci/config.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,9 @@ commands:
117117
python -m pip install --user -ve .
118118
fi
119119
- save_cache:
120-
key: build-deps-1
120+
key: build-deps-2
121121
paths:
122-
# FreeType 2.6.1 tarball.
123-
- ~/.cache/matplotlib/0a3c7dfbda6da1e8fce29232e8e96d987ababbbf71ebc8c75659e4132c367014
124-
# Qhull 2020.2 tarball.
125-
- ~/.cache/matplotlib/b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e
122+
- subprojects/packagecache
126123

127124
doc-build:
128125
steps:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ pip-wheel-metadata/*
4444
mplsetup.cfg
4545
# generated by setuptools_scm
4646
lib/matplotlib/_version.py
47+
# build subproject files
48+
subprojects/*/
49+
!subprojects/packagefiles/
4750

4851
# OS generated files #
4952
######################

extern/agg24-svn/meson.build

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# We need a patched Agg not available elsewhere, so always use the vendored
2+
# version.
3+
4+
agg_incdir = include_directories('include')
5+
6+
agg_lib = static_library('agg',
7+
'src/agg_bezier_arc.cpp',
8+
'src/agg_curves.cpp',
9+
'src/agg_image_filters.cpp',
10+
'src/agg_trans_affine.cpp',
11+
'src/agg_vcgen_contour.cpp',
12+
'src/agg_vcgen_dash.cpp',
13+
'src/agg_vcgen_stroke.cpp',
14+
'src/agg_vpgen_segmentator.cpp',
15+
include_directories : agg_incdir,
16+
gnu_symbol_visibility: 'inlineshidden',
17+
)
18+
19+
agg_dep = declare_dependency(
20+
include_directories: agg_incdir,
21+
link_with: agg_lib,
22+
)

extern/meson.build

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Bundled code.
2+
subdir('agg24-svn')
3+
subdir('ttconv')
4+
5+
# External code.
6+
7+
# FreeType 2.3 has libtool version 9.11.3 as can be checked from the tarball.
8+
# For FreeType>=2.4, there is a conversion table in docs/VERSIONS.txt in the
9+
# FreeType source tree.
10+
if get_option('system-freetype')
11+
freetype_dep = dependency('freetype2', version: '>=9.11.3')
12+
else
13+
# This is the version of FreeType to use when building a local version. It
14+
# must match the value in `lib/matplotlib.__init__.py`. Also update the docs
15+
# in `docs/devel/dependencies.rst`. Bump the cache key in
16+
# `.circleci/config.yml` when changing requirements.
17+
TESTING_VERSION_OF_FREETYPE = '2.6.1'
18+
if host_machine.system() == 'windows' and host_machine.cpu_family() == 'aarch64'
19+
# Older versions of freetype are not supported for win/arm64
20+
# Matplotlib tests will not pass
21+
LOCAL_FREETYPE_VERSION = '2.11.1'
22+
else
23+
LOCAL_FREETYPE_VERSION = TESTING_VERSION_OF_FREETYPE
24+
endif
25+
26+
freetype_proj = subproject(
27+
f'freetype-@LOCAL_FREETYPE_VERSION@',
28+
default_options: ['default_library=static'])
29+
freetype_dep = freetype_proj.get_variable('freetype_dep')
30+
endif
31+
32+
if get_option('system-qhull')
33+
qhull_dep = dependency('qhull_r', version: '>=8.0.2', required: false)
34+
if not qhull_dep.found()
35+
cc.check_header('libqhull_r/qhull_ra.h', required: true)
36+
qhull_dep = cc.find_library('qhull_r')
37+
endif
38+
else
39+
qhull_proj = subproject('qhull')
40+
qhull_dep = qhull_proj.get_variable('qhull_dep')
41+
endif

extern/ttconv/meson.build

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ttconv_lib = static_library('ttconv',
2+
'pprdrv_tt2.cpp',
3+
'pprdrv_tt.cpp',
4+
'ttutil.cpp',
5+
'pprdrv.h',
6+
'truetype.h',
7+
dependencies: [py3_dep],
8+
gnu_symbol_visibility: 'inlineshidden',
9+
)
10+
11+
ttconv_dep = declare_dependency(
12+
include_directories: include_directories('.'),
13+
link_with: ttconv_lib,
14+
)

meson.build

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
project(
2+
'matplotlib',
3+
'c', 'cpp',
4+
version: '3.9.0.dev0',
5+
# qt_editor backend is MIT
6+
# ResizeObserver at end of lib/matplotlib/backends/web_backend/js/mpl.js is CC0
7+
# Carlogo, STIX and Computer Modern is OFL
8+
# DejaVu is Bitstream Vera and Public Domain
9+
license: 'PSF-2.0 AND MIT AND CC0-1.0 AND OFL-1.1 AND Bitstream-Vera AND Public-Domain',
10+
default_options: [
11+
'b_lto=true',
12+
'cpp_std=c++11',
13+
'auto_features=disabled', # Force FreeType to avoid extra dependencies.
14+
],
15+
)
16+
17+
cc = meson.get_compiler('c')
18+
cpp = meson.get_compiler('cpp')
19+
20+
# https://mesonbuild.com/Python-module.html
21+
py_mod = import('python')
22+
py3 = py_mod.find_installation()
23+
py3_dep = py3.dependency()
24+
25+
pybind11_dep = dependency('pybind11', version: '>=2.6')
26+
27+
subdir('extern')
28+
subdir('src')

meson_options.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# By default, Matplotlib downloads and builds its own copies of FreeType and of
2+
# Qhull. You may set the following to True to instead link against a system
3+
# FreeType/Qhull. As an exception, Matplotlib defaults to the system version
4+
# of FreeType on AIX.
5+
option('system-freetype', type: 'boolean', value: false,
6+
description: 'Build against system version of FreeType')
7+
option('system-qhull', type: 'boolean', value: false,
8+
description: 'Build against system version of Qhull')
9+
10+
# Some of Matplotlib's components are optional: the MacOSX backend (installed
11+
# by default on MacOSX; requires the Cocoa headers included with XCode), and
12+
# the test data (i.e., the baseline image files; not installed by default). You
13+
# can control whether they are installed by uncommenting the following lines.
14+
# Note that the MacOSX backend is never built on Linux or Windows, regardless
15+
# of the config value.
16+
option('macosx', type: 'boolean', value: true,
17+
description: 'Enable MacOSX backend (requires Cocoa)')

src/_c_internal_utils.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#ifdef _WIN32
2+
#define WIN32_LEAN_AND_MEAN
3+
// Windows 10, for latest HiDPI API support.
4+
#define WINVER 0x0A00
5+
#define _WIN32_WINNT 0x0A00
6+
#endif
17
#define PY_SSIZE_T_CLEAN
28
#include <Python.h>
39
#ifdef __linux__

src/_tkagg.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
// rewritten, we have removed the PIL licensing information. If you want PIL,
1010
// you can get it at https://python-pillow.org/
1111

12+
#ifdef _WIN32
13+
#define WIN32_LEAN_AND_MEAN
14+
// Windows 8.1
15+
#define WINVER 0x0603
16+
#define _WIN32_WINNT 0x0603
17+
#endif
18+
1219
#define PY_SSIZE_T_CLEAN
1320
#include <Python.h>
1421

src/_ttconv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "mplutils.h"
99

1010
#include <pybind11/pybind11.h>
11-
#include "ttconv/pprdrv.h"
11+
#include "pprdrv.h"
1212
#include <vector>
1313

1414
namespace py = pybind11;

0 commit comments

Comments
 (0)