Merge pull request #455 from misl6/add-plain-python-requirements

Add python depends
This commit is contained in:
Andre Miras 2020-05-09 15:35:17 +02:00 committed by GitHub
commit 5da6cb8517
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 29 deletions

View file

@ -18,6 +18,7 @@ class KivyRecipe(CythonRecipe):
library = "libkivy.a"
depends = ["sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios",
"pyobjus", "python", "host_setuptools3"]
python_depends = ["certifi"]
pbx_frameworks = ["OpenGLES", "Accelerate", "CoreMedia", "CoreVideo"]
pre_build_ext = True

View file

@ -424,6 +424,7 @@ class Recipe:
"archs": [],
"depends": [],
"optional_depends": [],
"python_depends": [],
"library": None,
"libraries": [],
"include_dir": None,
@ -814,6 +815,8 @@ class Recipe:
self.install_frameworks()
logger.info("Install sources for {}".format(self.name))
self.install_sources()
logger.info("Install python deps for {}".format(self.name))
self.install_python_deps()
logger.info("Install {}".format(self.name))
self.install()
@ -929,6 +932,11 @@ class Recipe:
ensure_dir(dirname(dest))
shutil.copy(src_dir, dest)
@cache_execution
def install_python_deps(self):
for dep in self.python_depends:
_pip(["install", dep])
@cache_execution
def install(self):
pass
@ -1126,6 +1134,37 @@ def ensure_recipes_loaded(ctx):
recipe.init_with_ctx(ctx)
def _pip(args):
ctx = Context()
for recipe in Recipe.list_recipes():
key = "{}.build_all".format(recipe)
if key not in ctx.state:
continue
recipe = Recipe.get_recipe(recipe, ctx)
recipe.init_with_ctx(ctx)
if not hasattr(ctx, "site_packages_dir"):
logger.error("python must be compiled before using pip")
sys.exit(1)
pip_env = {
"CC": "/bin/false",
"CXX": "/bin/false",
"PYTHONPATH": ctx.site_packages_dir,
"PYTHONOPTIMIZE": "2",
# "PIP_INSTALL_TARGET": ctx.site_packages_dir
}
pip_path = join(ctx.dist_dir, 'hostpython3', 'bin', 'pip3')
if len(args) > 1 and args[0] == "install":
pip_args = ["--isolated", "--ignore-installed", "--prefix", ctx.python_prefix]
args = ["install"] + pip_args + args[1:]
logger.error("Executing pip with: {}".format(args))
pip_cmd = sh.Command(pip_path)
shprint(pip_cmd, *args, _env=pip_env)
def update_pbxproj(filename, pbx_frameworks=None):
# list all the compiled recipes
ctx = Context()
@ -1415,35 +1454,7 @@ pip Install a pip dependency into the distribution
self.pip()
def pip(self):
ctx = Context()
for recipe in Recipe.list_recipes():
key = "{}.build_all".format(recipe)
if key not in ctx.state:
continue
recipe = Recipe.get_recipe(recipe, ctx)
recipe.init_with_ctx(ctx)
if not hasattr(ctx, "site_packages_dir"):
logger.error("python must be compiled before using pip")
sys.exit(1)
pip_env = {
"CC": "/bin/false",
"CXX": "/bin/false",
"PYTHONPATH": ctx.site_packages_dir,
"PYTHONOPTIMIZE": "2",
# "PIP_INSTALL_TARGET": ctx.site_packages_dir
}
pip_path = join(ctx.dist_dir, 'hostpython3', 'bin', 'pip3')
pip_args = []
if len(sys.argv) > 2 and sys.argv[2] == "install":
pip_args = ["--isolated", "--ignore-installed", "--prefix", ctx.python_prefix]
args = [pip_path] + [sys.argv[2]] + pip_args + sys.argv[3:]
else:
args = [pip_path] + pip_args + sys.argv[2:]
import os
logger.error("Executing pip with: {}".format(args))
os.execve(pip_path, args, pip_env)
_pip(sys.argv[2:])
def launchimage(self):
import xcassets