我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sh.Command()。
def RunProcess(self): """This function will run the process' command. It will run the command in background. Currenlty, we don't support running command in foreground. Returns: Doesn't return anything but runs the process by running the proc_command. """ if not self.args: # when arguments are not provided as array command_args = shlex.split(self.command) run = sh.Command(command_args[0]) self.name = command_args[0] command_args = command_args[1:] else: # when argument is provided as array command_args = self.args run = sh.Command(self.command) self.name = self.command running_process = run(command_args, _out=self.os, _err_to_out=True, _bg=True) self.pid = running_process.pid
def export_appstore_ipa(archive_path, scheme, ipa_path, plist_path): """ ????AppStore?ipa :param archive_path: .xcworkspace ??? :param scheme: project ? scheme :param ipa_path: ??? .ipa ?? :param plist_path: .plist ??? :return: sh.Command """ tmp_path = 'tmp_{}'.format(random.randint(100000000, 1000000000)) tmp_file = '{}/{}.ipa'.format(tmp_path, scheme) cmd = __cmd_xcodebuild('-exportArchive', '-archivePath', archive_path, '-exportPath', tmp_path, '-exportOptionsPlist', plist_path) if not cmd.exit_code: __cmd_mv(tmp_file, ipa_path) __cmd_rm('-rf', tmp_path) return cmd
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # sh fails with code 255 trying to execute ./Configure # so instead we manually run perl passing in Configure perl = sh.Command('perl') buildarch = self.select_build_arch(arch) shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env) self.apply_patch('disable-sover.patch', arch.arch) self.apply_patch('rename-shared-lib.patch', arch.arch) # check_ssl = partial(self.check_symbol, env, 'libssl' + self.version + '.so') check_crypto = partial(self.check_symbol, env, 'libcrypto' + self.version + '.so') while True: shprint(sh.make, 'build_libs', _env=env) if all(map(check_crypto, ('SSLeay', 'MD5_Transform', 'MD4_Init'))): break shprint(sh.make, 'clean', _env=env) self.install_libs(arch, 'libssl' + self.version + '.so', 'libcrypto' + self.version + '.so')
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # Build M2Crypto hostpython = sh.Command(self.hostpython_location) r = self.get_recipe('openssl', self.ctx) openssl_dir = r.get_build_dir(arch.arch) shprint(hostpython, 'setup.py', 'build_ext', '-p' + arch.arch, '-c' + 'unix', '--openssl=' + openssl_dir , _env=env) # Install M2Crypto super(M2CryptoRecipe, self).build_arch(arch)
def prebuild_arch(self, arch): super(BoostRecipe, self).prebuild_arch(arch) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): if not exists(env['CROSSHOME']): # Make custom toolchain bash = sh.Command('bash') shprint(bash, join(self.ctx.ndk_dir, 'build/tools/make-standalone-toolchain.sh'), '--arch=' + env['ARCH'], '--platform=android-' + str(self.ctx.android_api), '--toolchain=' + env['CROSSHOST'] + '-' + env['TOOLCHAIN_VERSION'], '--install-dir=' + env['CROSSHOME'] ) # Set custom configuration shutil.copyfile(join(self.get_recipe_dir(), 'user-config.jam'), join(env['BOOST_BUILD_PATH'], 'user-config.jam'))
def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): env = self.get_recipe_env(arch) configure = sh.Command('./configure') shprint(configure, '--cross-prefix=arm-linux-androideabi-', '--host=arm-linux', '--disable-asm', '--disable-cli', '--enable-pic', '--disable-shared', '--enable-static', '--prefix={}'.format(realpath('.')), _env=env) shprint(sh.make, '-j4', _env=env) shprint(sh.make, 'install', _env=env)
def build_cython_components(self, arch): libzmq_recipe = Recipe.get_recipe('libzmq', self.ctx) libzmq_prefix = join(libzmq_recipe.get_build_dir(arch.arch), "install") self.setup_extra_args = ["--zmq={}".format(libzmq_prefix)] self.build_cmd = "configure" env = self.get_recipe_env(arch) setup_cfg = join(self.get_build_dir(arch.arch), "setup.cfg") with open(setup_cfg, "wb") as fd: fd.write(""" [global] zmq_prefix = {} skip_check_zmq = True """.format(libzmq_prefix)) return super(PyZMQRecipe, self).build_cython_components(arch) with current_directory(self.get_build_dir(arch.arch)): hostpython = sh.Command(self.hostpython_location) shprint(hostpython, 'setup.py', 'configure', '-v', _env=env) shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env) build_dir = glob.glob('build/lib.*')[0] shprint(sh.find, build_dir, '-name', '"*.o"', '-exec', env['STRIP'], '{}', ';', _env=env)
def build_arch(self, arch): env = self.get_recipe_env(arch) harfbuzz_recipe = Recipe.get_recipe('harfbuzz', self.ctx) env['LDFLAGS'] = ' '.join( [env['LDFLAGS'], '-L{}'.format(join(harfbuzz_recipe.get_build_dir(arch.arch), 'src', '.libs'))]) with current_directory(self.get_build_dir(arch.arch)): configure = sh.Command('./configure') shprint(configure, '--host=arm-linux-androideabi', '--prefix={}'.format(realpath('.')), '--without-zlib', '--with-png=no', '--enable-shared', _env=env) shprint(sh.make, '-j5', _env=env) shprint(sh.cp, 'objs/.libs/libfreetype.so', self.ctx.libs_dir)
def build_arch(self, arch): super(LibSecp256k1Recipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): if not exists('configure'): shprint(sh.Command('./autogen.sh'), _env=env) shprint( sh.Command('./configure'), '--host=' + arch.toolchain_prefix, '--prefix=' + self.ctx.get_python_install_dir(), '--enable-shared', '--enable-module-recovery', '--enable-experimental', '--enable-module-ecdh', _env=env) shprint(sh.make, '-j' + str(cpu_count()), _env=env) libs = ['.libs/libsecp256k1.so'] self.install_libs(arch, *libs)
def sdk_tools(self, args): '''Runs the android binary from the detected SDK directory, passing all arguments straight to it. This binary is used to install e.g. platform-tools for different API level targets. This is intended as a convenience function if android is not in your $PATH. ''' ctx = self.ctx ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir, user_ndk_dir=self.ndk_dir, user_android_api=self.android_api, user_ndk_ver=self.ndk_version) android = sh.Command(join(ctx.sdk_dir, 'tools', args.tool)) output = android( *args.unknown_args, _iter=True, _out_bufsize=1, _err_to_out=True) for line in output: sys.stdout.write(line) sys.stdout.flush()
def _adb(self, commands): '''Call the adb executable from the SDK, passing the given commands as arguments.''' ctx = self.ctx ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir, user_ndk_dir=self.ndk_dir, user_android_api=self.android_api, user_ndk_ver=self.ndk_version) if platform in ('win32', 'cygwin'): adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb.exe')) else: adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb')) info_notify('Starting adb...') output = adb(*commands, _iter=True, _out_bufsize=1, _err_to_out=True) for line in output: sys.stdout.write(line) sys.stdout.flush()
def strip_libraries(self, arch): info('Stripping libraries') if self.ctx.python_recipe.from_crystax: info('Python was loaded from CrystaX, skipping strip') return env = arch.get_env() strip = which('arm-linux-androideabi-strip', env['PATH']) if strip is None: warning('Can\'t find strip in PATH...') return strip = sh.Command(strip) filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'), '-iname', '*.so', _env=env).stdout.decode('utf-8') logger.info('Stripping libraries in private dir') for filen in filens.split('\n'): try: strip(filen, _env=env) except sh.ErrorReturnCode_1: logger.debug('Failed to strip ' + filen)
def _translate_image_name(templates, image_name): """ Translates a set of user-friendly image names into a set of actual image names that can be sent to the makefile. For example, "all" will be translated to the set of all images, while "windows" and "linux" will be translated to the appropriate subset of Windows or Linux images. """ ret = [] if image_name == 'all': ret = templates.keys() elif image_name in Command.image_groups: for k, v in templates.iteritems(): if v['image_group'] == image_name: ret.append(k) elif image_name in templates.keys(): ret = [image_name] else: raise CommandError('Invalid image name: %s. Run ``s2e image_build`` ' 'to list available images' % image_name) return ret
def add_arguments(self, parser): super(Command, self).add_arguments(parser) parser.add_argument('name', help='The name of the image to build. If empty,' ' shows available images', nargs='?') parser.add_argument('-g', '--gui', action='store_true', help='Display QEMU GUI during image build') parser.add_argument('-c', '--cores', required=False, default=2, type=int, help='The number of cores used when building the ' 'VM image. Defaults to 2') parser.add_argument('-x', '--clean', action='store_true', help='Deletes all images and rebuild them from ' 'scratch') parser.add_argument('-a', '--archive', action='store_true', help='Creates an archive for the specified image') parser.add_argument('-d', '--download', action='store_true', help='Download image from the repository instead ' 'of building it') parser.add_argument('-i', '--iso-dir', help='Path to folder that stores ISO files of Windows images')
def phase_edit(rinex_fname, work_path=None, disc_fix=DISC_FIX, discfix_args=[], glonass=False): """ ??? """ logger.info('applying GPSTk DiscFix to {}'.format(rinex_fname)) command = sh.Command(disc_fix) with SmartTempDir(work_path) as work_path: basename = os.path.basename(rinex_fname) log_fname = os.path.join(work_path, basename + '.df.log') stdout_fname = os.path.join(work_path, basename + '.df.stdout') stderr_fname = os.path.join(work_path, basename + '.df.stderr') cmd_fname = os.path.join(work_path, basename + '.df.out') args = ['--obs', rinex_fname, '--log', log_fname, '--cmd', cmd_fname] if glonass: args += ['--doGLO'] if discfix_args: logger.info('passing options to DiscFix: {}'.format(' '.join(discfix_args))) args += discfix_args command(*args, _out=stdout_fname, _err=stderr_fname) return parse_edit_commands(cmd_fname)
def dump_rinex(dump_fname, rinex_fname, nav_fname, data_keys=GPS_KEYS, p1c1_table=P1C1_TABLE, receiver_position=None, rin_dump=RIN_DUMP): """ ??? currently only dumps GPS observables receiver position in [m] """ rin_dump_command = sh.Command(rin_dump) stderr_buffer = StringIO() if receiver_position is None: receiver_position = get_receiver_position(rinex_fname, nav_fname) logger.info('dumping {} to {}'.format(rinex_fname, dump_fname)) args = ['--nav', nav_fname, '--ref', ','.join(map(str, receiver_position)), rinex_fname] + data_keys rin_dump_command(*args, _out=dump_fname, _err=stderr_buffer) stderr = stderr_buffer.read() if len(stderr) > 0: raise RuntimeError('error dumping the contents of ' '{} with {} ({})'.format(rinex_fname, rin_dump, stderr)) append_station_id(dump_fname, rinex_fname) append_receiver_type(dump_fname, rinex_fname) append_p1c1_date_table(dump_fname, p1c1_table(fname2date(rinex_fname))) return dump_fname
def run_command(cmd, debug=False): """ Execute the given command and return None. :param cmd: A `sh.Command` object to execute. :param debug: An optional bool to toggle debug output. :return: None """ if debug: msg = ' PWD: {}'.format(os.getcwd()) print_warn(msg) msg = ' COMMAND: {}'.format(cmd) print_warn(msg) cmd()
def build_sh_cmd(cmd, cwd=None): """Build a `sh.Command` from a string. :param cmd: String with the command to convert. :param cwd: Optional path to use as working directory. :return: `sh.Command` """ args = cmd.split() return getattr(sh, args[0]).bake(_cwd=cwd, *args[1:])
def __init__(self, base_path): self._base_path = base_path try: self._btrfs = sh.Command('btrfs') self._btrfs('quota', 'enable', self._base_path) except sh.CommandNotFound as e: print(self._err('driver init', e.stderr, e.full_cmd))
def _find_java_home(self): if self._java_home: return self._java_home # First check if the enviornment variable is set. java_home = os.environ.get("JAVA_HOME", None) if java_home: return java_home # On OS X, there's a magical command that gives you $JAVA_HOME if sys.platform == "darwin": try: cmd = sh.Command("/usr/libexec/java_home") return cmd().strip() except sh.ErrorReturnCode: pass # If only one Java is installed in the default Linux JVM folder, use # that if sys.platform in {"linux", "linux2"}: if os.path.isdir(self.DEFAULT_LINUX_JVM): javas = os.listdir(self.DEFAULT_LINUX_JVM) if len(javas) == 1: return javas[0] # Give up return None
def exec_cmd(*cmds, **kwargs): ''' @arguments env=None, timeout=3 may raise Error ''' env = os.environ.copy() env.update(kwargs.get('env', {})) envcopy = {} for key in env: try: envcopy[key] = str(env[key]).encode('utf-8') # fix encoding except: print('IGNORE BAD ENV KEY: ' + repr(key)) env = envcopy timeout = kwargs.get('timeout', 120) shell = kwargs.get('shell', False) try: import sh # log.debug('RUN(timeout=%ds): %s'%(timeout, ' '.join(cmds))) if shell: cmds = list(cmds) cmds[:0] = ['bash', '-c'] c = sh.Command(cmds[0]) try: r = c(*cmds[1:], _err_to_out=True, _out=sys.stdout, _env=env, _timeout=timeout) except: # log.error('EXEC_CMD error, cmd: %s'%(' '.join(cmds))) raise except ImportError: # log.debug('RUN(timeout=XX): %s'%(' '.join(cmds))) if shell: cmds = ' '.join(cmds) r = subprocess.Popen(cmds, env=env, stdout=sys.stdout, stderr=sys.stderr, shell=shell) return r.wait() return 0
def do_test_archive(filename): sevenzip = sh.Command('7z') return sevenzip.t(filename)
def keychain_unlock(password='', path=__default_path_keychain): """ ??keychain :param password: login user ??? :param path: login.keychain???, ??? ~/Library/Keychains/login.keychain :return: sh.Command """ assert password is not None # password ??? return __cmd_security('unlock-keychain', '-p', "'{}'".format(password), expanduser(path))
def list_info(path, is_project=True): """ ??project or workspace?? :param path: project or workspace ??? :param is_project: ???project(?????project or workspace) :return: sh.Command """ option = option_project_or_workspace(is_project) return __cmd_xcodebuild('-list', option, path)
def clean(path, scheme, is_project=True): """ ??package?build????? :param path: project or workspace ??? :param scheme: project ? scheme :param is_project: ???project(?????project or workspace) :return: sh.Command """ option = option_project_or_workspace(is_project) return __cmd_xcodebuild('clean', option, path, '-scheme', scheme)
def package_archive(path, scheme, configuration_name, archive_path, is_project=True): """ ??iOS???.xcarchive :param path: project or workspace ??? :param scheme: project ? scheme :param configuration_name: Release, Debug or othen custom config_name :param archive_path: ???.xcarchive?? :param is_project: ???project(?????project or workspace) :return: sh.Command """ option = option_project_or_workspace(is_project) return __cmd_xcodebuild(option, path, '-scheme', scheme, '-destination', 'generic/platform=iOS', 'archive', '-configuration', configuration_name, 'ONLY_ACTIVE_ARCH=NO', '-archivePath', archive_path)
def get_app_path(archive_path, scheme): """ ??.app??? :param archive_path: .xcarchive ??? :param scheme: project ? scheme :return: sh.Command """ return join(archive_path, 'Products/Applications/{}.app'.format(scheme))
def export_ipa(app_path, ipa_path): """ ??ipa :param app_path: .app ?? :param ipa_path: ??? .ipa ?? :return: sh.Command """ export_path = realpath(ipa_path) if ipa_path.find('~') == -1 else expanduser(ipa_path) return __cmd_xcrun('-sdk', 'iphoneos', 'PackageApplication', '-v', app_path, '-o', export_path)
def upload_appstore(appstore_ipa_path, developer_account, developer_password, xcode_path=None): """ ???AppStore :param appstore_ipa_path: .ipa ??? :param developer_account: ????? :param developer_password: ???????? :param xcode_path: Xcode??? :return: sh.Command """ if xcode_path: altool = sh.Command('{}{}' if xcode_path[-1] == '/' else '{}/{}').format(xcode_path, __default_path_altool) else: altool = __cmd_altool return altool('--upload-app', '-f', appstore_ipa_path, '-u', developer_account, '-p', developer_password, '-t', 'ios', '--output', 'xml')
def exec_cmd(*cmds, **kwargs): ''' @arguments env=None, timeout=3 may raise Error ''' env = os.environ.copy() env.update(kwargs.get('env', {})) envcopy = {} for key in env: try: envcopy[key] = str(env[key]).encode('utf-8') # fix encoding except: print 'IGNORE BAD ENV KEY:', repr(key) env = envcopy timeout = kwargs.get('timeout', 120) shell = kwargs.get('shell', False) try: import sh # log.debug('RUN(timeout=%ds): %s'%(timeout, ' '.join(cmds))) if shell: cmds = list(cmds) cmds[:0] = ['bash', '-c'] c = sh.Command(cmds[0]) try: r = c(*cmds[1:], _err_to_out=True, _out=sys.stdout, _env=env, _timeout=timeout) except: # log.error('EXEC_CMD error, cmd: %s'%(' '.join(cmds))) raise except ImportError: # log.debug('RUN(timeout=XX): %s'%(' '.join(cmds))) if shell: cmds = ' '.join(cmds) r = subprocess.Popen(cmds, env=env, stdout=sys.stdout, stderr=sys.stderr, shell=shell) return r.wait() return 0
def ledger_with_contents(contents): return sh.Command('/usr/bin/ledger').bake(no_color=True, file="-", _in=contents)
def new(cls, filename): if hasattr(settings, 'LEDGER_BIN'): ledger_bin = settings.LEDGER_BIN else: ledger_bin = sh.which('ledger') return Ledger(sh.Command(ledger_bin).bake(_tty_out=False, no_color=True, file=filename), filename=filename)
def add(self): if self.pkg: dbPath = os.path.join(self.repoPath, "%s.db.tar.gz" % (self.repoName)) pkgPath = os.path.join(self.repoPath, os.path.basename(self.pkg)) shutil.copy(self.pkg, pkgPath) repoAdd = sh.Command("repo-add") repoAdd(dbPath, pkgPath)
def run_galaxy_install(organization): roles_path = os.path.join(get_env_path(organization), 'roles') dependencies_paths = [os.path.join(roles_path, '%s.%s' % (filename, ext)) for (filename, ext) in product(['requirements', 'dependencies'], ['yml', 'txt'])] for path in dependencies_paths: if os.path.exists(path): dependencies_path = path break else: return last_mtime = None last_mtime_file = os.path.join(get_env_path(organization), '.galaxy') if os.path.exists(last_mtime_file): with open(last_mtime_file, 'r') as f: last_mtime = f.readline() mtime = str(os.stat(dependencies_path).st_mtime) if last_mtime == mtime: return info("Updating dependencies for %s ..." % organization) galaxy = shCommand(os.path.join(aeriscloud_path, 'scripts', 'wrapper.sh')) galaxy(os.path.join(aeriscloud_path, 'venv', 'bin', 'ansible-galaxy'), 'install', '-f', '-p', roles_path, '-r', dependencies_path, _out=sys.stdout, _out_bufsize=0, _err_to_out=True) with open(last_mtime_file, 'w') as f: f.write(mtime)
def VBoxManage(*args, **kwargs): global _vbm if not _vbm: _vbm = Command('VBoxManage') return _vbm(*args, **kwargs)
def cmd(): """Command fixture.""" return sh.Command(main.__app_name__)
def test_cli_help(cmd): result = cmd('--help') lines = result.stdout.decode('ascii').splitlines() assert main.__app_name__ in lines[0].split(), "Command name is reported"
def build_arch(self, arch): env = dict(environ) with current_directory(self.get_build_dir()): if exists('hostpython'): info('hostpython already exists, skipping build') self.ctx.hostpython = join(self.get_build_dir(), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen') return configure = sh.Command('./configure') shprint(configure, _env=env) shprint(sh.make, '-j5', _env=env) shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen') if exists('python.exe'): shprint(sh.mv, 'python.exe', 'hostpython') elif exists('python'): shprint(sh.mv, 'python', 'hostpython') else: warning('Unable to find the python executable after ' 'hostpython build! Exiting.') exit(1) self.ctx.hostpython = join(self.get_build_dir(), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')
def build_compiled_components(self, arch): info('Configuring compiled components in {}'.format(self.name)) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): configure = sh.Command('./configure') shprint(configure, '--host=arm-eabi', '--prefix={}'.format(self.ctx.get_python_install_dir()), '--enable-shared', _env=env) super(PyCryptoRecipe, self).build_compiled_components(arch)
def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): env = self.get_recipe_env(arch) configure = sh.Command('./configure') shprint(configure, '--host=arm-linux', _env=env) shprint(sh.make, '-j4', _env=env) shprint(sh.mkdir, 'include') shprint(sh.cp, '-a', 'gmp.h', 'include/gmp.h') shprint(sh.cp, '-a', '.libs/libgmp.so', join(self.ctx.get_libs_dir(arch.arch), 'libgmp.so')) shprint(sh.cp, '-a', '.libs/libgmp.so', join(self.ctx.get_libs_dir(''), 'libgmp.so')) # also copy to libs_collections/<package_name>
def build_arch(self, arch): with current_directory(self.get_build_dir()): if exists('hostpython'): info('hostpython already exists, skipping build') self.ctx.hostpython = join(self.get_build_dir(), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen') return configure = sh.Command('./configure') shprint(configure) shprint(sh.make, '-j5') shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen') if exists('python.exe'): shprint(sh.mv, 'python.exe', 'hostpython') elif exists('python'): shprint(sh.mv, 'python', 'hostpython') else: warning('Unable to find the python executable after ' 'hostpython build! Exiting.') exit(1) self.ctx.hostpython = join(self.get_build_dir(), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(join(self.get_build_dir(arch.arch), 'libmysqlclient')): shprint(sh.cp, '-t', '.', join(self.get_recipe_dir(), 'p4a.cmake')) # shprint(sh.mkdir, 'Platform') # shprint(sh.cp, '-t', 'Platform', join(self.get_recipe_dir(), 'Linux.cmake')) shprint(sh.rm, '-f', 'CMakeCache.txt') shprint(sh.cmake, '-G', 'Unix Makefiles', # '-DCMAKE_MODULE_PATH=' + join(self.get_build_dir(arch.arch), 'libmysqlclient'), '-DCMAKE_INSTALL_PREFIX=./install', '-DCMAKE_TOOLCHAIN_FILE=p4a.cmake', _env=env) shprint(sh.make, _env=env) self.install_libs(arch, join('libmysql', 'libmysql.so')) # def get_recipe_env(self, arch=None): # env = super(LibmysqlclientRecipe, self).get_recipe_env(arch) # env['WITHOUT_SERVER'] = 'ON' # ncurses = self.get_recipe('ncurses', self) # # env['CFLAGS'] += ' -I' + join(ncurses.get_build_dir(arch.arch), # # 'include') # env['CURSES_LIBRARY'] = join(self.ctx.get_libs_dir(arch.arch), 'libncurses.so') # env['CURSES_INCLUDE_PATH'] = join(ncurses.get_build_dir(arch.arch), # 'include') # return env # # def build_arch(self, arch): # env = self.get_recipe_env(arch) # with current_directory(self.get_build_dir(arch.arch)): # # configure = sh.Command('./configure') # # TODO: should add openssl as an optional dep and compile support # # shprint(configure, '--enable-shared', '--enable-assembler', # # '--enable-thread-safe-client', '--with-innodb', # # '--without-server', _env=env) # # shprint(sh.make, _env=env) # shprint(sh.cmake, '.', '-DCURSES_LIBRARY=' + env['CURSES_LIBRARY'], # '-DCURSES_INCLUDE_PATH=' + env['CURSES_INCLUDE_PATH'], _env=env) # shprint(sh.make, _env=env) # # self.install_libs(arch, 'libmysqlclient.so')
def build_arch(self, arch): super(BoostRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # Compile Boost.Build engine with this custom toolchain bash = sh.Command('bash') shprint(bash, 'bootstrap.sh', '--with-python=' + join(env['PYTHON_ROOT'], 'bin/python.host'), '--with-python-version=2.7', '--with-python-root=' + env['PYTHON_ROOT'] ) # Do not pass env # Install app stl shutil.copyfile(join(env['CROSSHOME'], env['CROSSHOST'], 'lib/libgnustl_shared.so'), join(self.ctx.get_libs_dir(arch.arch), 'libgnustl_shared.so'))
def build_arch(self, arch): env = self.get_recipe_env(arch) # Build libproto.a with current_directory(self.get_build_dir(arch.arch)): env['HOSTARCH'] = 'arm-eabi' env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0] if not exists('configure'): shprint(sh.Command('./autogen.sh'), _env=env) shprint(sh.Command('./configure'), '--host={}'.format(env['HOSTARCH']), '--enable-shared', _env=env) with current_directory(join(self.get_build_dir(arch.arch), 'src')): shprint(sh.make, 'libprotobuf.la', '-j'+str(cpu_count()), _env=env) shprint(sh.cp, '.libs/libprotobuf.a', join(self.ctx.get_libs_dir(arch.arch), 'libprotobuf.a')) # Copy stl library shutil.copyfile(self.ctx.ndk_dir + '/sources/cxx-stl/gnu-libstdc++/' + self.ctx.toolchain_version + '/libs/' + arch.arch + '/libgnustl_shared.so', join(self.ctx.get_libs_dir(arch.arch), 'libgnustl_shared.so')) # Build python bindings and _message.so with current_directory(join(self.get_build_dir(arch.arch), 'python')): hostpython = sh.Command(self.hostpython_location) shprint(hostpython, 'setup.py', 'build_ext', '--cpp_implementation' , _env=env) # Install python bindings self.install_python_package(arch)
def install_python_package(self, arch): env = self.get_recipe_env(arch) info('Installing {} into site-packages'.format(self.name)) with current_directory(join(self.get_build_dir(arch.arch), 'python')): hostpython = sh.Command(self.hostpython_location) if self.ctx.python_recipe.from_crystax: hpenv = env.copy() shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=.', '--cpp_implementation', _env=hpenv, *self.setup_extra_args) else: hppath = join(dirname(self.hostpython_location), 'Lib', 'site-packages') hpenv = env.copy() if 'PYTHONPATH' in hpenv: hpenv['PYTHONPATH'] = ':'.join([hppath] + hpenv['PYTHONPATH'].split(':')) else: hpenv['PYTHONPATH'] = hppath shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=lib/python2.7/site-packages', '--cpp_implementation', _env=hpenv, *self.setup_extra_args)
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # Build python bindings hostpython = sh.Command(self.hostpython_location) shprint(hostpython, 'setup.py', 'build_ext', '--enable=fts4' , _env=env) # Install python bindings super(ApswRecipe, self).build_arch(arch)
def build_arch(self, arch): super(LibtorrentRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(join(self.get_build_dir(arch.arch), 'bindings/python')): # Compile libtorrent with boost libraries and python bindings b2 = sh.Command(join(env['BOOST_ROOT'], 'b2')) shprint(b2, '-q', '-j5', 'toolset=gcc-' + env['ARCH'], 'target-os=android', 'threading=multi', 'link=shared', 'boost-link=shared', 'boost=source', 'encryption=openssl' if 'openssl' in recipe.ctx.recipe_build_order else '', '--prefix=' + env['CROSSHOME'], 'release' , _env=env) # Common build directories build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source' if 'openssl' in recipe.ctx.recipe_build_order: build_subdirs += '/encryption-openssl' build_subdirs += '/libtorrent-python-pic-on/target-os-android/threading-multi/visibility-hidden' # Copy the shared libraries into the libs folder shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/python/build', build_subdirs, 'libboost_python.so'), join(self.ctx.get_libs_dir(arch.arch), 'libboost_python.so')) shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/system/build', build_subdirs, 'libboost_system.so'), join(self.ctx.get_libs_dir(arch.arch), 'libboost_system.so')) if 'openssl' in recipe.ctx.recipe_build_order: shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/date_time/build', build_subdirs, 'libboost_date_time.so'), join(self.ctx.get_libs_dir(arch.arch), 'libboost_date_time.so')) shutil.copyfile(join(self.get_build_dir(arch.arch), 'bin', build_subdirs, 'libtorrent_rasterbar.so'), join(self.ctx.get_libs_dir(arch.arch), 'libtorrent_rasterbar.so')) shutil.copyfile(join(self.get_build_dir(arch.arch), 'bindings/python/bin', build_subdirs, 'libtorrent.so'), join(self.ctx.get_site_packages_dir(arch.arch), 'libtorrent.so'))
def build_arch(self, arch): # AND: Should use an i386 recipe system warning('Running hostpython build. Arch is armeabi! ' 'This is naughty, need to fix the Arch system!') # AND: Fix armeabi again with current_directory(self.get_build_dir(arch.arch)): if exists('hostpython'): info('hostpython already exists, skipping build') self.ctx.hostpython = join(self.get_build_dir('armeabi'), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir('armeabi'), 'hostpgen') return configure = sh.Command('./configure') shprint(configure) shprint(sh.make, '-j5', 'BUILDPYTHON=hostpython', 'hostpython', 'PGEN=Parser/hostpgen', 'Parser/hostpgen') shprint(sh.mv, join('Parser', 'hostpgen'), 'hostpgen') # if exists('python.exe'): # shprint(sh.mv, 'python.exe', 'hostpython') # elif exists('python'): # shprint(sh.mv, 'python', 'hostpython') if exists('hostpython'): pass # The above commands should automatically create # the hostpython binary, unlike with python2 else: warning('Unable to find the python executable after ' 'hostpython build! Exiting.') exit(1) self.ctx.hostpython = join(self.get_build_dir(arch.arch), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(arch.arch), 'hostpgen')