toolchain: add a pip command to ease the installation of pip packages within the toolchain
This commit is contained in:
parent
bc864ccad6
commit
5fa807cf5f
1 changed files with 30 additions and 0 deletions
30
toolchain.py
30
toolchain.py
|
@ -1223,6 +1223,36 @@ Xcode:
|
|||
print("--")
|
||||
print("Project {} updated".format(filename))
|
||||
|
||||
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)
|
||||
print(ctx.site_packages_dir)
|
||||
if not hasattr(ctx, "site_packages_dir"):
|
||||
print("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
|
||||
}
|
||||
print pip_env
|
||||
pip_path = sh.which("pip")
|
||||
args = [pip_path] + sys.argv[2:]
|
||||
if not pip_path:
|
||||
print("ERROR: pip not found")
|
||||
sys.exit(1)
|
||||
import os
|
||||
print("-- execute pip with: {}".format(args))
|
||||
os.execve(pip_path, args, pip_env)
|
||||
|
||||
def launchimage(self):
|
||||
import xcassets
|
||||
self._xcassets("LaunchImage", xcassets.launchimage)
|
||||
|
|
Loading…
Add table
Reference in a new issue