Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses new cd context manager more #465

Merged
merged 1 commit into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions recipes/itsdangerous/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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()
7 changes: 3 additions & 4 deletions recipes/pycrypto/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -31,12 +30,12 @@ def build_arch(self, arch):
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()
2 changes: 2 additions & 0 deletions toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@
@contextmanager
def cd(newdir):
prevdir = getcwd()
logger.info("cd {}".format(newdir))
chdir(expanduser(newdir))
try:
yield
finally:
logger.info("cd {}".format(prevdir))
chdir(prevdir)


Expand Down