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
|
from os import chdir, listdir, getcwd
|
||||||
import sh
|
import sh
|
||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -43,55 +44,10 @@ class KivyRecipe(CythonRecipe):
|
||||||
with open(pyconfig, "w") as fd:
|
with open(pyconfig, "w") as fd:
|
||||||
fd.writelines(lines)
|
fd.writelines(lines)
|
||||||
|
|
||||||
def install_python_package(self, name=None, env=None, is_dir=True):
|
def reduce_python_package(self):
|
||||||
"""
|
dest_dir = join(self.ctx.site_packages_dir, "kivy")
|
||||||
Automate the installation of a Python package into the target
|
shutil.rmtree(join(dest_dir, "tools"))
|
||||||
site-packages.
|
shutil.rmtree(join(dest_dir, "tests"))
|
||||||
"""
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
recipe = KivyRecipe()
|
recipe = KivyRecipe()
|
||||||
|
|
25
toolchain.py
25
toolchain.py
|
@ -1043,21 +1043,16 @@ class PythonRecipe(Recipe):
|
||||||
build_dir = self.get_build_dir(arch.arch)
|
build_dir = self.get_build_dir(arch.arch)
|
||||||
chdir(build_dir)
|
chdir(build_dir)
|
||||||
hostpython = sh.Command(self.ctx.hostpython)
|
hostpython = sh.Command(self.ctx.hostpython)
|
||||||
iosbuild = join(build_dir, "iosbuild")
|
|
||||||
shprint(hostpython, "setup.py", "install", "-O2",
|
shprint(
|
||||||
"--prefix", iosbuild,
|
hostpython,
|
||||||
_env=env)
|
"setup.py",
|
||||||
dest_dir = join(self.ctx.site_packages_dir, name)
|
"install",
|
||||||
if is_dir:
|
"-O2",
|
||||||
if exists(dest_dir):
|
"--root", self.ctx.python_prefix,
|
||||||
shutil.rmtree(dest_dir)
|
"--prefix", "",
|
||||||
func = shutil.copytree
|
_env=env,
|
||||||
else:
|
)
|
||||||
func = shutil.copy
|
|
||||||
func(
|
|
||||||
join(iosbuild, "lib",
|
|
||||||
self.ctx.python_ver_dir, "site-packages", name),
|
|
||||||
dest_dir)
|
|
||||||
|
|
||||||
def reduce_python_package(self):
|
def reduce_python_package(self):
|
||||||
"""Feel free to remove things you don't want in the final
|
"""Feel free to remove things you don't want in the final
|
||||||
|
|
Loading…
Reference in a new issue