Skip to content

Commit

Permalink
update for recent iOS platform changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tcaduser committed Sep 10, 2023
1 parent d274c43 commit 4f2e88a
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 21 deletions.
4 changes: 2 additions & 2 deletions kivy_ios/recipes/kiwisolver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
26 changes: 11 additions & 15 deletions kivy_ios/recipes/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 = {
Expand All @@ -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,
Expand All @@ -67,29 +67,29 @@ 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')
self.apply_patch('setupext.py.patch')
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']
Expand All @@ -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']
Expand Down
11 changes: 10 additions & 1 deletion kivy_ios/recipes/matplotlib/setup.py.patch
Original file line number Diff line number Diff line change
@@ -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=[
Expand Down
44 changes: 43 additions & 1 deletion kivy_ios/recipes/matplotlib/setupext.py.patch
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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
8 changes: 6 additions & 2 deletions kivy_ios/tools/cpplink
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 4f2e88a

Please sign in to comment.