Skip to content

Commit 5da6cb8

Browse files
authored
Merge pull request #455 from misl6/add-plain-python-requirements
Add python depends
2 parents 085d04b + 85177f5 commit 5da6cb8

File tree

2 files changed

+41
-29
lines changed

2 files changed

+41
-29
lines changed

kivy_ios/recipes/kivy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class KivyRecipe(CythonRecipe):
1818
library = "libkivy.a"
1919
depends = ["sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios",
2020
"pyobjus", "python", "host_setuptools3"]
21+
python_depends = ["certifi"]
2122
pbx_frameworks = ["OpenGLES", "Accelerate", "CoreMedia", "CoreVideo"]
2223
pre_build_ext = True
2324

kivy_ios/toolchain.py

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ class Recipe:
424424
"archs": [],
425425
"depends": [],
426426
"optional_depends": [],
427+
"python_depends": [],
427428
"library": None,
428429
"libraries": [],
429430
"include_dir": None,
@@ -814,6 +815,8 @@ def build_all(self):
814815
self.install_frameworks()
815816
logger.info("Install sources for {}".format(self.name))
816817
self.install_sources()
818+
logger.info("Install python deps for {}".format(self.name))
819+
self.install_python_deps()
817820
logger.info("Install {}".format(self.name))
818821
self.install()
819822

@@ -929,6 +932,11 @@ def install_include(self):
929932
ensure_dir(dirname(dest))
930933
shutil.copy(src_dir, dest)
931934

935+
@cache_execution
936+
def install_python_deps(self):
937+
for dep in self.python_depends:
938+
_pip(["install", dep])
939+
932940
@cache_execution
933941
def install(self):
934942
pass
@@ -1126,6 +1134,37 @@ def ensure_recipes_loaded(ctx):
11261134
recipe.init_with_ctx(ctx)
11271135

11281136

1137+
def _pip(args):
1138+
ctx = Context()
1139+
for recipe in Recipe.list_recipes():
1140+
key = "{}.build_all".format(recipe)
1141+
if key not in ctx.state:
1142+
continue
1143+
recipe = Recipe.get_recipe(recipe, ctx)
1144+
recipe.init_with_ctx(ctx)
1145+
if not hasattr(ctx, "site_packages_dir"):
1146+
logger.error("python must be compiled before using pip")
1147+
sys.exit(1)
1148+
1149+
pip_env = {
1150+
"CC": "/bin/false",
1151+
"CXX": "/bin/false",
1152+
"PYTHONPATH": ctx.site_packages_dir,
1153+
"PYTHONOPTIMIZE": "2",
1154+
# "PIP_INSTALL_TARGET": ctx.site_packages_dir
1155+
}
1156+
1157+
pip_path = join(ctx.dist_dir, 'hostpython3', 'bin', 'pip3')
1158+
1159+
if len(args) > 1 and args[0] == "install":
1160+
pip_args = ["--isolated", "--ignore-installed", "--prefix", ctx.python_prefix]
1161+
args = ["install"] + pip_args + args[1:]
1162+
1163+
logger.error("Executing pip with: {}".format(args))
1164+
pip_cmd = sh.Command(pip_path)
1165+
shprint(pip_cmd, *args, _env=pip_env)
1166+
1167+
11291168
def update_pbxproj(filename, pbx_frameworks=None):
11301169
# list all the compiled recipes
11311170
ctx = Context()
@@ -1415,35 +1454,7 @@ def pip3(self):
14151454
self.pip()
14161455

14171456
def pip(self):
1418-
ctx = Context()
1419-
for recipe in Recipe.list_recipes():
1420-
key = "{}.build_all".format(recipe)
1421-
if key not in ctx.state:
1422-
continue
1423-
recipe = Recipe.get_recipe(recipe, ctx)
1424-
recipe.init_with_ctx(ctx)
1425-
if not hasattr(ctx, "site_packages_dir"):
1426-
logger.error("python must be compiled before using pip")
1427-
sys.exit(1)
1428-
1429-
pip_env = {
1430-
"CC": "/bin/false",
1431-
"CXX": "/bin/false",
1432-
"PYTHONPATH": ctx.site_packages_dir,
1433-
"PYTHONOPTIMIZE": "2",
1434-
# "PIP_INSTALL_TARGET": ctx.site_packages_dir
1435-
}
1436-
pip_path = join(ctx.dist_dir, 'hostpython3', 'bin', 'pip3')
1437-
pip_args = []
1438-
if len(sys.argv) > 2 and sys.argv[2] == "install":
1439-
pip_args = ["--isolated", "--ignore-installed", "--prefix", ctx.python_prefix]
1440-
args = [pip_path] + [sys.argv[2]] + pip_args + sys.argv[3:]
1441-
else:
1442-
args = [pip_path] + pip_args + sys.argv[2:]
1443-
1444-
import os
1445-
logger.error("Executing pip with: {}".format(args))
1446-
os.execve(pip_path, args, pip_env)
1457+
_pip(sys.argv[2:])
14471458

14481459
def launchimage(self):
14491460
import xcassets

0 commit comments

Comments
 (0)