Uses new cd context manager more

Also adds logging as we change directories.
This commit is contained in:
Andre Miras 2020-05-02 22:37:11 +02:00
parent a83b3f495b
commit c06c51f149
3 changed files with 9 additions and 9 deletions

View file

@ -1,8 +1,7 @@
# pure-python package, this can be removed when we'll support any python package # pure-python package, this can be removed when we'll support any python package
from toolchain import PythonRecipe, shprint from toolchain import PythonRecipe, shprint, cd
from os.path import join from os.path import join
import sh import sh
import os
class ItsDangerousRecipe(PythonRecipe): class ItsDangerousRecipe(PythonRecipe):
@ -13,12 +12,12 @@ class ItsDangerousRecipe(PythonRecipe):
def install(self): def install(self):
arch = list(self.filtered_archs)[0] arch = list(self.filtered_archs)[0]
build_dir = self.get_build_dir(arch.arch) build_dir = self.get_build_dir(arch.arch)
os.chdir(build_dir)
hostpython = sh.Command(self.ctx.hostpython) hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env() build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python") dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
cmd = sh.Command("sed") cmd = sh.Command("sed")
with cd(build_dir):
shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env) shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env)
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env) shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -1,9 +1,8 @@
'''Recipe for pycrypto on ios '''Recipe for pycrypto on ios
''' '''
from toolchain import CythonRecipe, shprint from toolchain import CythonRecipe, shprint, cd
from os.path import join from os.path import join
import sh import sh
import os
class PycryptoRecipe(CythonRecipe): class PycryptoRecipe(CythonRecipe):
@ -31,11 +30,11 @@ class PycryptoRecipe(CythonRecipe):
def install(self): def install(self):
arch = list(self.filtered_archs)[0] arch = list(self.filtered_archs)[0]
build_dir = self.get_build_dir(arch.arch) build_dir = self.get_build_dir(arch.arch)
os.chdir(build_dir)
hostpython = sh.Command(self.ctx.hostpython) hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env() build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python") dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
with cd(build_dir):
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env) shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -62,10 +62,12 @@ IS_PY2 = sys.version_info[0] == 2
@contextmanager @contextmanager
def cd(newdir): def cd(newdir):
prevdir = getcwd() prevdir = getcwd()
logger.info("cd {}".format(newdir))
chdir(expanduser(newdir)) chdir(expanduser(newdir))
try: try:
yield yield
finally: finally:
logger.info("cd {}".format(prevdir))
chdir(prevdir) chdir(prevdir)