diff --git a/recipes/itsdangerous/__init__.py b/recipes/itsdangerous/__init__.py index e3ffb71..13425e1 100644 --- a/recipes/itsdangerous/__init__.py +++ b/recipes/itsdangerous/__init__.py @@ -1,8 +1,7 @@ # 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 import sh -import os class ItsDangerousRecipe(PythonRecipe): @@ -13,14 +12,14 @@ class ItsDangerousRecipe(PythonRecipe): def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) - os.chdir(build_dir) hostpython = sh.Command(self.ctx.hostpython) build_env = arch.get_env() dest_dir = join(self.ctx.dist_dir, "root", "python") build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') cmd = sh.Command("sed") - shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env) - shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env) + with cd(build_dir): + shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env) + shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env) recipe = ItsDangerousRecipe() diff --git a/recipes/pycrypto/__init__.py b/recipes/pycrypto/__init__.py index c2326bc..dbfde89 100644 --- a/recipes/pycrypto/__init__.py +++ b/recipes/pycrypto/__init__.py @@ -1,9 +1,8 @@ '''Recipe for pycrypto on ios ''' -from toolchain import CythonRecipe, shprint +from toolchain import CythonRecipe, shprint, cd from os.path import join import sh -import os class PycryptoRecipe(CythonRecipe): @@ -31,12 +30,12 @@ class PycryptoRecipe(CythonRecipe): def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) - os.chdir(build_dir) hostpython = sh.Command(self.ctx.hostpython) build_env = arch.get_env() dest_dir = join(self.ctx.dist_dir, "root", "python") build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') - shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env) + with cd(build_dir): + shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env) recipe = PycryptoRecipe() diff --git a/toolchain.py b/toolchain.py index 31f17a7..afa9ccf 100755 --- a/toolchain.py +++ b/toolchain.py @@ -62,10 +62,12 @@ IS_PY2 = sys.version_info[0] == 2 @contextmanager def cd(newdir): prevdir = getcwd() + logger.info("cd {}".format(newdir)) chdir(expanduser(newdir)) try: yield finally: + logger.info("cd {}".format(prevdir)) chdir(prevdir)