1
-
2
- from pythonforandroid .logger import info_notify
3
1
from pythonforandroid .recipe import CppCompiledComponentsPythonRecipe
4
2
from pythonforandroid .util import ensure_dir
5
3
8
6
9
7
class MatplotlibRecipe (CppCompiledComponentsPythonRecipe ):
10
8
11
- version = '3.1.3 '
9
+ version = '3.5.2 '
12
10
url = 'https://github.com/matplotlib/matplotlib/archive/v{version}.zip'
13
11
14
- depends = ['numpy ' , 'png ' , 'setuptools ' , 'freetype ' , 'kiwisolver ' ]
12
+ depends = ['kiwisolver ' , 'numpy ' , 'pillow ' , 'setuptools ' , 'freetype ' ]
15
13
16
- python_depends = ['pyparsing ' , 'cycler ' , 'python-dateutil' ]
14
+ python_depends = ['cycler ' , 'fonttools' , 'packaging' , 'pyparsing ' , 'python-dateutil' ]
17
15
18
16
# We need to patch to:
19
17
# - make mpl install work without importing numpy
20
18
# - make mpl use shared libraries for freetype and png
21
19
# - make mpl link to png16, to match p4a library name for png
22
20
# - prevent mpl trying to build TkAgg, which wouldn't work
23
21
# 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']
27
23
28
24
def generate_libraries_pc_files (self , arch ):
29
25
"""
@@ -42,10 +38,9 @@ def generate_libraries_pc_files(self, arch):
42
38
# version for freetype, but we have our recipe named without
43
39
# the version...so we add it in here for our pc file
44
40
'freetype' : 'freetype2.pc' ,
45
- 'png' : 'png.pc' ,
46
41
}
47
42
48
- for lib_name in {'freetype' , 'png' }:
43
+ for lib_name in {'freetype' }:
49
44
pc_template_file = join (
50
45
self .get_recipe_dir (),
51
46
f'lib{ lib_name } .pc.template'
@@ -67,53 +62,18 @@ def generate_libraries_pc_files(self, arch):
67
62
with open (pc_dest_file , 'w' ) as pc_file :
68
63
pc_file .write (text_buffer )
69
64
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
-
95
65
def prebuild_arch (self , arch ):
96
66
with open (join (self .get_recipe_dir (), 'setup.cfg.template' )) as fileh :
97
67
setup_cfg = fileh .read ()
98
68
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 :
100
70
fileh .write (setup_cfg .format (
101
71
ndk_sysroot_usr = join (self .ctx .ndk .sysroot , 'usr' )))
102
72
103
73
self .generate_libraries_pc_files (arch )
104
- self .download_web_backend_dependencies (arch )
105
74
106
75
def get_recipe_env (self , arch = None , with_flags_in_cc = True ):
107
76
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 )
117
77
118
78
# we modify `XDG_CACHE_HOME` to download `jquery-ui` into that folder,
119
79
# 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):
140
100
# success with our build (without depending on system development
141
101
# libraries), but if we tell the compiler where to find our libraries
142
102
# 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
-
147
103
freetype = self .get_recipe ('freetype' , self .ctx )
148
104
free_lib_dir = join (freetype .get_build_dir (arch .arch ), 'objs' , '.libs' )
149
105
free_inc_dir = join (freetype .get_build_dir (arch .arch ), 'include' )
0 commit comments