Skip to content

Commit 2733aec

Browse files
committed
Updates matplotlib, fixes an issue related to shared libc++
1 parent c77e07d commit 2733aec

File tree

5 files changed

+34
-160
lines changed

5 files changed

+34
-160
lines changed

pythonforandroid/recipe.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -492,20 +492,6 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
492492
if arch is None:
493493
arch = self.filtered_archs[0]
494494
env = arch.get_env(with_flags_in_cc=with_flags_in_cc)
495-
496-
if self.need_stl_shared:
497-
env['CPPFLAGS'] = env.get('CPPFLAGS', '')
498-
env['CPPFLAGS'] += ' -I{}'.format(self.ctx.ndk.libcxx_include_dir)
499-
500-
env['CXXFLAGS'] = env['CFLAGS'] + ' -frtti -fexceptions'
501-
502-
if with_flags_in_cc:
503-
env['CXX'] += ' -frtti -fexceptions'
504-
505-
env['LDFLAGS'] += ' -L{}'.format(arch.ndk_lib_dir)
506-
env['LIBS'] = env.get('LIBS', '') + " -l{}".format(
507-
self.stl_lib_name
508-
)
509495
return env
510496

511497
def prebuild_arch(self, arch):

pythonforandroid/recipes/cppy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class CppyRecipe(PythonRecipe):
66

77
# Pin to commit: `Nucleic migration and project documentation`,
88
# because the official releases are too old, at time of writing
9-
version = '4e0b956'
9+
version = '1.1.0'
1010
url = 'https://github.com/nucleic/cppy/archive/{version}.zip'
1111
call_hostpython_via_targetpython = False
1212
# to be detected by the matplotlib install script

pythonforandroid/recipes/kiwisolver/__init__.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,9 @@ class KiwiSolverRecipe(CppCompiledComponentsPythonRecipe):
99
# changes that we want to include are merged to master branch
1010
# Note: the commit we want to include is
1111
# `Cppy use update and c++11 compatibility` (4858730)
12-
version = '0846189'
12+
version = '1.3.2'
1313
url = 'https://github.com/nucleic/kiwi/archive/{version}.zip'
1414
depends = ['cppy']
1515

16-
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
17-
env = super().get_recipe_env(arch, with_flags_in_cc)
18-
if self.need_stl_shared:
19-
# kiwisolver compile flags does not honor the standard flags:
20-
# `CPPFLAGS` and `LDLIBS`, so we put in `CFLAGS` and `LDFLAGS` to
21-
# correctly link with the `c++_shared` library
22-
env['CFLAGS'] += f' -I{self.ctx.ndk.libcxx_include_dir}'
23-
env['CFLAGS'] += ' -frtti -fexceptions'
24-
25-
env['LDFLAGS'] += f' -L{arch.ndk_lib_dir}'
26-
env['LDFLAGS'] += f' -l{self.stl_lib_name}'
27-
return env
28-
2916

3017
recipe = KiwiSolverRecipe()

pythonforandroid/recipes/matplotlib/__init__.py

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
from pythonforandroid.logger import info_notify
31
from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe
42
from pythonforandroid.util import ensure_dir
53

@@ -8,22 +6,20 @@
86

97
class MatplotlibRecipe(CppCompiledComponentsPythonRecipe):
108

11-
version = '3.1.3'
9+
version = '3.5.2'
1210
url = 'https://github.com/matplotlib/matplotlib/archive/v{version}.zip'
1311

14-
depends = ['numpy', 'png', 'setuptools', 'freetype', 'kiwisolver']
12+
depends = ['kiwisolver', 'numpy', 'pillow', 'setuptools', 'freetype']
1513

16-
python_depends = ['pyparsing', 'cycler', 'python-dateutil']
14+
python_depends = ['cycler', 'fonttools', 'packaging', 'pyparsing', 'python-dateutil']
1715

1816
# We need to patch to:
1917
# - make mpl install work without importing numpy
2018
# - make mpl use shared libraries for freetype and png
2119
# - make mpl link to png16, to match p4a library name for png
2220
# - prevent mpl trying to build TkAgg, which wouldn't work
2321
# on Android anyway but has build issues
24-
patches = ['mpl_android_fixes.patch']
25-
26-
call_hostpython_via_targetpython = False
22+
# patches = ['mpl_android_fixes.patch']
2723

2824
def generate_libraries_pc_files(self, arch):
2925
"""
@@ -42,10 +38,9 @@ def generate_libraries_pc_files(self, arch):
4238
# version for freetype, but we have our recipe named without
4339
# the version...so we add it in here for our pc file
4440
'freetype': 'freetype2.pc',
45-
'png': 'png.pc',
4641
}
4742

48-
for lib_name in {'freetype', 'png'}:
43+
for lib_name in {'freetype'}:
4944
pc_template_file = join(
5045
self.get_recipe_dir(),
5146
f'lib{lib_name}.pc.template'
@@ -67,53 +62,18 @@ def generate_libraries_pc_files(self, arch):
6762
with open(pc_dest_file, 'w') as pc_file:
6863
pc_file.write(text_buffer)
6964

70-
def download_web_backend_dependencies(self, arch):
71-
"""
72-
During building, host needs to download the jquery-ui package (in order
73-
to make it work the mpl web backend). This operation seems to fail
74-
in our CI tests, so we download this package at the expected location
75-
by the mpl install script which is defined by the environ variable
76-
`XDG_CACHE_HOME` (we modify that one in our `get_recipe_env` so it will
77-
be the same regardless of the host platform).
78-
"""
79-
80-
env = self.get_recipe_env(arch)
81-
82-
info_notify('Downloading jquery-ui for matplatlib web backend')
83-
# We use the same jquery-ui version than mpl's setup.py script,
84-
# inside function `_download_jquery_to`
85-
jquery_sha = (
86-
'f8233674366ab36b2c34c577ec77a3d70cac75d2e387d8587f3836345c0f624d'
87-
)
88-
url = "https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip"
89-
target_file = join(env['XDG_CACHE_HOME'], 'matplotlib', jquery_sha)
90-
91-
info_notify(f'Will download into {env["XDG_CACHE_HOME"]}')
92-
ensure_dir(join(env['XDG_CACHE_HOME'], 'matplotlib'))
93-
self.download_file(url, target_file)
94-
9565
def prebuild_arch(self, arch):
9666
with open(join(self.get_recipe_dir(), 'setup.cfg.template')) as fileh:
9767
setup_cfg = fileh.read()
9868

99-
with open(join(self.get_build_dir(arch), 'setup.cfg'), 'w') as fileh:
69+
with open(join(self.get_build_dir(arch), 'mplsetup.cfg'), 'w') as fileh:
10070
fileh.write(setup_cfg.format(
10171
ndk_sysroot_usr=join(self.ctx.ndk.sysroot, 'usr')))
10272

10373
self.generate_libraries_pc_files(arch)
104-
self.download_web_backend_dependencies(arch)
10574

10675
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
10776
env = super().get_recipe_env(arch, with_flags_in_cc)
108-
if self.need_stl_shared:
109-
# matplotlib compile flags does not honor the standard flags:
110-
# `CPPFLAGS` and `LDLIBS`, so we put in `CFLAGS` and `LDFLAGS` to
111-
# correctly link with the `c++_shared` library
112-
env['CFLAGS'] += ' -I{}'.format(self.ctx.ndk.libcxx_include_dir)
113-
env['CFLAGS'] += ' -frtti -fexceptions'
114-
115-
env['LDFLAGS'] += ' -L{}'.format(arch.ndk_lib_dir)
116-
env['LDFLAGS'] += ' -l{}'.format(self.stl_lib_name)
11777

11878
# we modify `XDG_CACHE_HOME` to download `jquery-ui` into that folder,
11979
# or mpl install will fail when trying to download/install it, but if
@@ -140,10 +100,6 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
140100
# success with our build (without depending on system development
141101
# libraries), but if we tell the compiler where to find our libraries
142102
# and includes, then the install success :)
143-
png = self.get_recipe('png', self.ctx)
144-
env['CFLAGS'] += f' -I{png.get_build_dir(arch)}'
145-
env['LDFLAGS'] += f' -L{join(png.get_build_dir(arch.arch), ".libs")}'
146-
147103
freetype = self.get_recipe('freetype', self.ctx)
148104
free_lib_dir = join(freetype.get_build_dir(arch.arch), 'objs', '.libs')
149105
free_inc_dir = join(freetype.get_build_dir(arch.arch), 'include')
Lines changed: 26 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,38 @@
1-
# Rename this file to setup.cfg to modify Matplotlib's
2-
# build options.
3-
4-
[egg_info]
5-
6-
[directories]
7-
# Uncomment to override the default basedir in setupext.py.
8-
# This can be a single directory or a comma-delimited list of directories.
9-
basedirlist = {ndk_sysroot_usr}
10-
11-
[test]
12-
# If you plan to develop Matplotlib and run or add to the test suite,
13-
# set this to True. It will download and build a specific version of
14-
# FreeType, and then use that to build the ft2font extension. This
15-
# ensures that test images are exactly reproducible.
16-
# local_freetype = True
17-
18-
[status]
19-
# To suppress display of the dependencies and their versions
20-
# at the top of the build log, uncomment the following line:
21-
#suppress = True
1+
# Rename this file to mplsetup.cfg to modify Matplotlib's build options.
2+
3+
[libs]
4+
# By default, Matplotlib builds with LTO, which may be slow if you re-compile
5+
# often, and don't need the space saving/speedup.
6+
enable_lto = False
7+
# By default, Matplotlib downloads and builds its own copies of FreeType and of
8+
# Qhull. You may set the following to True to instead link against a system
9+
# FreeType/Qhull. As an exception, Matplotlib defaults to the system version
10+
# of FreeType on AIX.
11+
system_freetype = True
12+
#system_qhull = False
2213

2314
[packages]
24-
# There are a number of subpackages of Matplotlib that are considered
25-
# optional. All except tests are installed by default, but that can
26-
# be changed here.
27-
#
28-
tests = False
29-
sample_data = False
30-
#toolkits = True
31-
# Tests for the toolkits are only automatically installed
32-
# if the tests and toolkits packages are also getting installed.
33-
toolkits_tests = False
15+
# There are a number of data subpackages from Matplotlib that are
16+
# considered optional. All except 'tests' data (meaning the baseline
17+
# image files) are installed by default, but that can be changed here.
18+
#tests = False
3419

3520
[gui_support]
36-
# Matplotlib supports multiple GUI toolkits, including
37-
# GTK3, MacOSX, Qt4, Qt5, Tk, and WX. Support for many of
38-
# these toolkits requires AGG, the Anti-Grain Geometry library,
39-
# which is provided by Matplotlib and built by default.
40-
#
41-
# Some backends are written in pure Python, and others require
42-
# extension code to be compiled. By default, Matplotlib checks for
43-
# these GUI toolkits during installation and, if present, compiles the
44-
# required extensions to support the toolkit.
45-
#
46-
# - Tk support requires Tk development headers and Tkinter.
47-
# - Mac OSX backend requires the Cocoa headers included with XCode.
48-
# - Windowing is MS-Windows specific, and requires the "windows.h"
49-
# header.
21+
# Matplotlib supports multiple GUI toolkits, known as backends.
22+
# The MacOSX backend requires the Cocoa headers included with XCode.
23+
# You can select whether to build it by uncommenting the following line.
24+
# It is never built on Linux or Windows, regardless of the config value.
5025
#
51-
# The other GUI toolkits do not require any extension code, and can be
52-
# used as long as the libraries are installed on your system --
53-
# therefore they are installed unconditionally.
54-
#
55-
# You can uncomment any the following lines to change this
56-
# behavior. Acceptable values are:
57-
#
58-
# True: build the extension. Exits with a warning if the
59-
# required dependencies are not available
60-
# False: do not build the extension
61-
# auto: build if the required dependencies are available,
62-
# otherwise skip silently. This is the default
63-
# behavior
64-
#
65-
agg = True
66-
cairo = False
67-
gtk3agg = False
68-
gtk3cairo = False
6926
macosx = False
70-
pyside = False
71-
qt4agg = False
72-
tkagg = False
73-
windowing = False
74-
wxagg = False
7527

7628
[rc_options]
7729
# User-configurable options
7830
#
79-
# Default backend, one of: Agg, Cairo, GTK3Agg, GTK3Cairo, MacOSX, Pdf, Ps,
80-
# Qt4Agg, Qt5Agg, SVG, TkAgg, WX, WXAgg.
31+
# Default backend, one of: Agg, Cairo, GTK3Agg, GTK3Cairo, GTK4Agg, GTK4Cairo,
32+
# MacOSX, Pdf, Ps, QtAgg, QtCairo, SVG, TkAgg, WX, WXAgg.
8133
#
82-
# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do
83-
# not choose MacOSX, or TkAgg if you have disabled the relevant extension
84-
# modules. Agg will be used by default.
85-
#
86-
backend = Agg
87-
#
88-
89-
[package_data]
90-
# Package additional files found in the lib/matplotlib directories.
34+
# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do
35+
# not choose MacOSX if you have disabled the relevant extension modules. The
36+
# default is determined by fallback.
9137
#
92-
# On Windows, package DLL files.
93-
#dlls = True
38+
#backend = Agg

0 commit comments

Comments
 (0)