diff --git a/kivy_ios/recipes/kiwisolver/__init__.py b/kivy_ios/recipes/kiwisolver/__init__.py index d71f7d3a..ac10aec8 100644 --- a/kivy_ios/recipes/kiwisolver/__init__.py +++ b/kivy_ios/recipes/kiwisolver/__init__.py @@ -22,8 +22,8 @@ class KiwiSolverRecipe(CythonRecipe): cythonize = False library = "libkiwisolver.a" - def get_recipe_env(self, arch=None, with_flags_in_cc=True): - env = super().get_recipe_env(arch) + def get_recipe_env(self, plat): + env = super().get_recipe_env(plat) # cpplink setup env['CXX_ORIG'] = env['CXX'] diff --git a/kivy_ios/recipes/matplotlib/__init__.py b/kivy_ios/recipes/matplotlib/__init__.py index 628055dd..690c8474 100644 --- a/kivy_ios/recipes/matplotlib/__init__.py +++ b/kivy_ios/recipes/matplotlib/__init__.py @@ -26,7 +26,7 @@ class MatplotlibRecipe(CythonRecipe): 'pyparsing', 'python-dateutil'] cythonize = False - def generate_libraries_pc_files(self, arch): + def generate_libraries_pc_files(self, plat): """ Create *.pc files for libraries that `matplotib` depends on. @@ -35,7 +35,7 @@ def generate_libraries_pc_files(self, arch): well...we don't even install the libraries...so we must trick a little the mlp install). """ - pkg_config_path = self.get_recipe_env(arch)['PKG_CONFIG_PATH'] + pkg_config_path = self.get_recipe_env(plat)['PKG_CONFIG_PATH'] ensure_dir(pkg_config_path) lib_to_pc_file = { @@ -56,7 +56,7 @@ def generate_libraries_pc_files(self, arch): # set the library absolute path and library version lib_recipe = self.get_recipe(lib_name, self.ctx) text_buffer = text_buffer.replace( - 'path_to_built', lib_recipe.get_build_dir(arch.arch), + 'path_to_built', lib_recipe.get_build_dir(plat), ) text_buffer = text_buffer.replace( 'library_version', lib_recipe.version, @@ -67,14 +67,14 @@ def generate_libraries_pc_files(self, arch): with open(pc_dest_file, 'w') as pc_file: pc_file.write(text_buffer) - def prebuild_arch(self, arch): + def prebuild_platform(self, plat): if self.has_marker("patched"): return shutil.copyfile( join(abspath(self.recipe_dir), "setup.cfg.template"), - join(self.get_build_dir(arch.arch), "mplsetup.cfg"), + join(self.get_build_dir(plat), "mplsetup.cfg"), ) - self.generate_libraries_pc_files(arch) + self.generate_libraries_pc_files(plat) self.apply_patch('_tri.cpp.patch') self.apply_patch('_tri.h.patch') self.apply_patch('_tri_wrapper.cpp.patch') @@ -82,14 +82,14 @@ def prebuild_arch(self, arch): self.apply_patch('setup.py.patch') self.set_marker("patched") - def get_recipe_env(self, arch=None, with_flags_in_cc=True): - env = super().get_recipe_env(arch) + def get_recipe_env(self, plat): + env = super().get_recipe_env(plat) # we make use of the same directory than `XDG_CACHE_HOME`, for our # custom library pc files, so we have all the install files that we # generate at the same place env['XDG_CACHE_HOME'] = join( - self.get_build_dir(arch.arch), + self.get_build_dir(plat), 'p4a_files' ) env['PKG_CONFIG_PATH'] = env['XDG_CACHE_HOME'] @@ -99,15 +99,11 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True): # libraries), but if we tell the compiler where to find our libraries # and includes, then the install success :) freetype = self.get_recipe('freetype', self.ctx) - free_inc_dir = join(freetype.get_build_dir(arch.arch), 'include') + free_inc_dir = join(freetype.get_build_dir(plat), 'include') numpytype = self.get_recipe('numpy', self.ctx) - numpy_inc_dir = join(numpytype.get_build_dir(arch.arch), - 'build', 'src.macosx-13.5-arm64-3.10', - 'numpy', 'core', 'include', 'numpy') - # this numpy include directory is not in the dist directory - numpy_inc_dir = dirname(sh.glob(numpytype.get_build_dir(arch.arch) + '/**/_numpyconfig.h', recursive=True)[0]) + numpy_inc_dir = dirname(sh.glob(numpytype.get_build_dir(plat) + '/**/_numpyconfig.h', recursive=True)[0]) env['CFLAGS'] += f' -I{free_inc_dir} -I{numpy_inc_dir}' env['CXX_ORIG'] = env['CXX'] diff --git a/kivy_ios/recipes/matplotlib/setup.py.patch b/kivy_ios/recipes/matplotlib/setup.py.patch index 84c197f7..51d514cb 100644 --- a/kivy_ios/recipes/matplotlib/setup.py.patch +++ b/kivy_ios/recipes/matplotlib/setup.py.patch @@ -1,5 +1,14 @@ --- matplotlib-3.5.2.orig/setup.py 2022-05-02 22:49:57 -+++ matplotlib-3.5.2/setup.py 2023-09-09 22:22:57 ++++ matplotlib-3.5.2/setup.py 2023-09-10 11:11:57 +@@ -47,7 +47,7 @@ + setupext.FreeType(), + setupext.Qhull(), + setupext.Tests(), +- setupext.BackendMacOSX(), ++# setupext.BackendMacOSX(), + ] + + @@ -315,7 +315,7 @@ python_requires='>={}'.format('.'.join(str(n) for n in py_min_version)), setup_requires=[ diff --git a/kivy_ios/recipes/matplotlib/setupext.py.patch b/kivy_ios/recipes/matplotlib/setupext.py.patch index 83d8cdd5..41bea128 100644 --- a/kivy_ios/recipes/matplotlib/setupext.py.patch +++ b/kivy_ios/recipes/matplotlib/setupext.py.patch @@ -1,5 +1,5 @@ --- matplotlib-3.5.2.orig/setupext.py 2023-09-08 14:01:18 -+++ matplotlib-3.5.2/setupext.py 2023-09-09 22:23:24 ++++ matplotlib-3.5.2/setupext.py 2023-09-10 11:29:38 @@ -404,7 +404,7 @@ "matplotlib._contour", [ "src/_contour.cpp", @@ -53,3 +53,45 @@ ext.define_macros.extend([ # Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each # extension. +@@ -749,22 +749,22 @@ + ext.libraries.extend("m") + + +-class BackendMacOSX(OptionalPackage): +- config_category = 'gui_support' +- name = 'macosx' +- +- def check(self): +- if sys.platform != 'darwin': +- raise Skipped("Mac OS-X only") +- return super().check() +- +- def get_extensions(self): +- sources = [ +- 'src/_macosx.m' +- ] +- ext = Extension('matplotlib.backends._macosx', sources) +- ext.extra_compile_args.extend(['-Werror=unguarded-availability']) +- ext.extra_link_args.extend(['-framework', 'Cocoa']) +- if platform.python_implementation().lower() == 'pypy': +- ext.extra_compile_args.append('-DPYPY=1') +- yield ext ++#class BackendMacOSX(OptionalPackage): ++# config_category = 'gui_support' ++# name = 'macosx' ++# ++# def check(self): ++# if sys.platform != 'darwin': ++# raise Skipped("Mac OS-X only") ++# return super().check() ++# ++# def get_extensions(self): ++# sources = [ ++# 'src/_macosx.m' ++# ] ++# ext = Extension('matplotlib.backends._macosx', sources) ++# ext.extra_compile_args.extend(['-Werror=unguarded-availability']) ++# ext.extra_link_args.extend(['-framework', 'Cocoa']) ++# if platform.python_implementation().lower() == 'pypy': ++# ext.extra_compile_args.append('-DPYPY=1') ++# yield ext diff --git a/kivy_ios/tools/cpplink b/kivy_ios/tools/cpplink index dac8a671..952f2225 100755 --- a/kivy_ios/tools/cpplink +++ b/kivy_ios/tools/cpplink @@ -100,10 +100,14 @@ def call_linker(objects, output): print('cpplink redirect linking with', objects) ld = environ.get('ARM_LD') arch = environ.get('ARCH', 'arm64') - if 'arm' in arch: + sdk = environ.get('PLATFORM_SDK', 'iphoneos') + if sdk == 'iphoneos': min_version_flag = '-ios_version_min' - else: + elif sdk == 'iphonesimulator': min_version_flag = '-ios_simulator_version_min' + else: + raise ValueError("Unsupported SDK: {}".format(sdk)) + call = [ld, '-r', '-o', output + '.o', min_version_flag, '9.0', '-arch', arch] if min_version_flag == "-ios_version_min": call += ["-bitcode_bundle"]