Merge pull request #485 from AndreMiras/feature/use_cd_context_manager
Uses cd context manager in Python3Recipe.reduce_python()
This commit is contained in:
commit
9c68080ca3
1 changed files with 19 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
||||||
from kivy_ios.toolchain import Recipe, shprint
|
from kivy_ios.toolchain import Recipe, shprint, cd
|
||||||
from os.path import join
|
from os.path import join
|
||||||
import sh
|
import sh
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -149,29 +149,28 @@ class Python3Recipe(Recipe):
|
||||||
|
|
||||||
def reduce_python(self):
|
def reduce_python(self):
|
||||||
logger.info("Reduce python")
|
logger.info("Reduce python")
|
||||||
oldpwd = os.getcwd()
|
logger.info("Remove files unlikely to be used")
|
||||||
try:
|
with cd(join(self.ctx.dist_dir, "root", "python3")):
|
||||||
logger.info("Remove files unlikely to be used")
|
|
||||||
os.chdir(join(self.ctx.dist_dir, "root", "python3"))
|
|
||||||
sh.rm("-rf", "bin", "share")
|
sh.rm("-rf", "bin", "share")
|
||||||
# platform binaries and configuration
|
# platform binaries and configuration
|
||||||
os.chdir(join(
|
with cd(join(
|
||||||
self.ctx.dist_dir, "root", "python3", "lib",
|
self.ctx.dist_dir, "root", "python3", "lib",
|
||||||
"python3.8", "config-3.8-darwin"))
|
"python3.8", "config-3.8-darwin")):
|
||||||
sh.rm("libpython3.8.a")
|
sh.rm(
|
||||||
sh.rm("python.o")
|
"libpython3.8.a",
|
||||||
sh.rm("config.c.in")
|
"python.o",
|
||||||
sh.rm("makesetup")
|
"config.c.in",
|
||||||
sh.rm("install-sh")
|
"makesetup",
|
||||||
|
"install-sh",
|
||||||
|
)
|
||||||
|
|
||||||
# cleanup pkgconfig and compiled lib
|
# cleanup pkgconfig and compiled lib
|
||||||
os.chdir(join(self.ctx.dist_dir, "root", "python3", "lib"))
|
with cd(join(self.ctx.dist_dir, "root", "python3", "lib")):
|
||||||
sh.rm("-rf", "pkgconfig")
|
sh.rm("-rf", "pkgconfig", "libpython3.8.a")
|
||||||
sh.rm("-f", "libpython3.8.a")
|
|
||||||
|
|
||||||
# cleanup python libraries
|
# cleanup python libraries
|
||||||
os.chdir(join(
|
with cd(join(
|
||||||
self.ctx.dist_dir, "root", "python3", "lib", "python3.8"))
|
self.ctx.dist_dir, "root", "python3", "lib", "python3.8")):
|
||||||
sh.rm("-rf", "wsgiref", "curses", "idlelib", "lib2to3",
|
sh.rm("-rf", "wsgiref", "curses", "idlelib", "lib2to3",
|
||||||
"ensurepip", "turtledemo", "lib-dynload", "venv",
|
"ensurepip", "turtledemo", "lib-dynload", "venv",
|
||||||
"pydoc_data")
|
"pydoc_data")
|
||||||
|
@ -199,8 +198,6 @@ class Python3Recipe(Recipe):
|
||||||
sh.rm("-rf", sh.glob("*"))
|
sh.rm("-rf", sh.glob("*"))
|
||||||
sh.mv("../config-3.8-darwin", ".")
|
sh.mv("../config-3.8-darwin", ".")
|
||||||
sh.mv("../site-packages", ".")
|
sh.mv("../site-packages", ".")
|
||||||
finally:
|
|
||||||
os.chdir(oldpwd)
|
|
||||||
|
|
||||||
|
|
||||||
recipe = Python3Recipe()
|
recipe = Python3Recipe()
|
||||||
|
|
Loading…
Reference in a new issue