toolchain: have a better installation method
Instead of installing on a temporary directory, and copying only what we want, this install directly in the dist, and the recipe can clean itself in reduce_python_package(). This prevent the fix for kivy recipes using bdist_egg and easy_install.
This commit is contained in:
parent
180ad7ebd0
commit
49b16c6f0d
2 changed files with 15 additions and 64 deletions
|
@ -3,6 +3,7 @@ from os.path import join
|
|||
from os import chdir, listdir, getcwd
|
||||
import sh
|
||||
import logging
|
||||
import shutil
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -43,55 +44,10 @@ class KivyRecipe(CythonRecipe):
|
|||
with open(pyconfig, "w") as fd:
|
||||
fd.writelines(lines)
|
||||
|
||||
def install_python_package(self, name=None, env=None, is_dir=True):
|
||||
"""
|
||||
Automate the installation of a Python package into the target
|
||||
site-packages.
|
||||
"""
|
||||
arch = self.filtered_archs[0]
|
||||
if name is None:
|
||||
name = self.name
|
||||
if env is None:
|
||||
env = self.get_recipe_env(arch)
|
||||
print("Install {} into the site-packages".format(name))
|
||||
build_dir = self.get_build_dir(arch.arch)
|
||||
chdir(build_dir)
|
||||
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
env["PYTHONPATH"] = self.ctx.site_packages_dir
|
||||
shprint(
|
||||
hostpython,
|
||||
"setup.py",
|
||||
"bdist_egg",
|
||||
"--exclude-source-files",
|
||||
"--plat-name=",
|
||||
# "--plat-name={}".format(arch.arch),
|
||||
_env=env,
|
||||
)
|
||||
for file in listdir("./dist"):
|
||||
if file.endswith(".egg"):
|
||||
egg_name = file
|
||||
shprint(
|
||||
hostpython,
|
||||
"setup.py",
|
||||
"easy_install",
|
||||
"--no-deps",
|
||||
"--install-dir",
|
||||
self.ctx.site_packages_dir,
|
||||
join("dist", egg_name),
|
||||
_env=env,
|
||||
)
|
||||
|
||||
# clean
|
||||
oldpwd = getcwd()
|
||||
try:
|
||||
logger.info("Remove files unlikely to be used")
|
||||
chdir(join(self.ctx.site_packages_dir, egg_name))
|
||||
sh.rm("-rf", "share")
|
||||
sh.rm("-rf", "kivy/tools")
|
||||
sh.rm("-rf", "kivy/tests")
|
||||
finally:
|
||||
chdir(oldpwd)
|
||||
def reduce_python_package(self):
|
||||
dest_dir = join(self.ctx.site_packages_dir, "kivy")
|
||||
shutil.rmtree(join(dest_dir, "tools"))
|
||||
shutil.rmtree(join(dest_dir, "tests"))
|
||||
|
||||
|
||||
recipe = KivyRecipe()
|
||||
|
|
25
toolchain.py
25
toolchain.py
|
@ -1043,21 +1043,16 @@ class PythonRecipe(Recipe):
|
|||
build_dir = self.get_build_dir(arch.arch)
|
||||
chdir(build_dir)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
iosbuild = join(build_dir, "iosbuild")
|
||||
shprint(hostpython, "setup.py", "install", "-O2",
|
||||
"--prefix", iosbuild,
|
||||
_env=env)
|
||||
dest_dir = join(self.ctx.site_packages_dir, name)
|
||||
if is_dir:
|
||||
if exists(dest_dir):
|
||||
shutil.rmtree(dest_dir)
|
||||
func = shutil.copytree
|
||||
else:
|
||||
func = shutil.copy
|
||||
func(
|
||||
join(iosbuild, "lib",
|
||||
self.ctx.python_ver_dir, "site-packages", name),
|
||||
dest_dir)
|
||||
|
||||
shprint(
|
||||
hostpython,
|
||||
"setup.py",
|
||||
"install",
|
||||
"-O2",
|
||||
"--root", self.ctx.python_prefix,
|
||||
"--prefix", "",
|
||||
_env=env,
|
||||
)
|
||||
|
||||
def reduce_python_package(self):
|
||||
"""Feel free to remove things you don't want in the final
|
||||
|
|
Loading…
Reference in a new issue