本文整理汇总了Python中pythonforandroid.util.current_directory函数的典型用法代码示例。如果您正苦于以下问题:Python current_directory函数的具体用法?Python current_directory怎么用?Python current_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了current_directory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: build_arch
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)
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:35,代码来源:__init__.py
示例2: build_arch
def build_arch(self, arch):
recipe_build_dir = self.get_build_dir(arch.arch)
# Create a subdirectory to actually perform the build
build_dir = join(recipe_build_dir, self.build_subdir)
ensure_dir(build_dir)
if not exists(join(build_dir, 'python')):
with current_directory(recipe_build_dir):
# Configure the build
with current_directory(build_dir):
if not exists('config.status'):
shprint(
sh.Command(join(recipe_build_dir, 'configure')))
# Create the Setup file. This copying from Setup.dist
# seems to be the normal and expected procedure.
shprint(sh.cp, join('Modules', 'Setup.dist'),
join(build_dir, 'Modules', 'Setup'))
result = shprint(sh.make, '-C', build_dir)
else:
info('Skipping {name} ({version}) build, as it has already '
'been completed'.format(name=self.name, version=self.version))
self.ctx.hostpython = join(build_dir, 'python')
开发者ID:kronenpj,项目名称:python-for-android,代码行数:26,代码来源:python.py
示例3: download_file
def download_file(self, url, target, cwd=None):
"""
(internal) Download an ``url`` to a ``target``.
"""
if not url:
return
info('Downloading {} from {}'.format(self.name, url))
if cwd:
target = join(cwd, target)
parsed_url = urlparse(url)
if parsed_url.scheme in ('http', 'https'):
def report_hook(index, blksize, size):
if size <= 0:
progression = '{0} bytes'.format(index * blksize)
else:
progression = '{0:.2f}%'.format(
index * blksize * 100. / float(size))
if "CI" not in environ:
stdout.write('- Download {}\r'.format(progression))
stdout.flush()
if exists(target):
unlink(target)
# Download item with multiple attempts (for bad connections):
attempts = 0
while True:
try:
urlretrieve(url, target, report_hook)
except OSError as e:
attempts += 1
if attempts >= 5:
raise e
stdout.write('Download failed retrying in a second...')
time.sleep(1)
continue
break
return target
elif parsed_url.scheme in ('git', 'git+file', 'git+ssh', 'git+http', 'git+https'):
if isdir(target):
with current_directory(target):
shprint(sh.git, 'fetch', '--tags')
if self.version:
shprint(sh.git, 'checkout', self.version)
shprint(sh.git, 'pull')
shprint(sh.git, 'pull', '--recurse-submodules')
shprint(sh.git, 'submodule', 'update', '--recursive')
else:
if url.startswith('git+'):
url = url[4:]
shprint(sh.git, 'clone', '--recursive', url, target)
if self.version:
with current_directory(target):
shprint(sh.git, 'checkout', self.version)
shprint(sh.git, 'submodule', 'update', '--recursive')
return target
开发者ID:PKRoma,项目名称:python-for-android,代码行数:58,代码来源:recipe.py
示例4: build_arch
def build_arch(self, 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('autoreconf'), '-vif', _env=env)
shprint(sh.Command('./configure'),
'--host=' + arch.command_prefix,
'--prefix=' + self.get_build_dir(arch.arch),
'--disable-builddir',
'--enable-shared', _env=env)
# '--with-sysroot={}'.format(self.ctx.ndk_platform),
# '--target={}'.format(arch.toolchain_prefix),
# ndk 15 introduces unified headers required --sysroot and
# -isysroot for libraries and headers. libtool's head explodes
# trying to weave them into it's own magic. The result is a link
# failure trying to link libc. We call make to compile the bits
# and manually link...
try:
shprint(sh.make, '-j5', 'libffi.la', _env=env)
except sh.ErrorReturnCode_2:
info("make libffi.la failed as expected")
cc = sh.Command(env['CC'].split()[0])
cflags = env['CC'].split()[1:]
host_build = self.get_build_dir(arch.arch)
arch_flags = ''
if '-march=' in env['CFLAGS']:
arch_flags = '-march={}'.format(env['CFLAGS'].split('-march=')[1])
src_arch = arch.command_prefix.split('-')[0]
if src_arch == 'x86_64':
# libffi has not specific arch files for x86_64...so...using
# the ones from x86 which seems to build fine...
src_arch = 'x86'
cflags.extend(arch_flags.split())
cflags.extend(['-shared', '-fPIC', '-DPIC'])
cflags.extend(glob(join(host_build, 'src/.libs/*.o')))
cflags.extend(glob(join(host_build, 'src', src_arch, '.libs/*.o')))
ldflags = env['LDFLAGS'].split()
cflags.extend(ldflags)
cflags.extend(['-Wl,-soname', '-Wl,libffi.so', '-o',
'.libs/libffi.so'])
with current_directory(host_build):
shprint(cc, *cflags, _env=env)
ensure_dir(self.ctx.get_libs_dir(arch.arch))
shprint(sh.cp,
join(host_build, '.libs', 'libffi.so'),
self.ctx.get_libs_dir(arch.arch))
开发者ID:kronenpj,项目名称:python-for-android,代码行数:55,代码来源:__init__.py
示例5: build_arch
def build_arch(self, 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', _env=env)
shprint(sh.make, '-j5', 'libffi.la', _env=env)
# dlname = None
# with open(join(host, 'libffi.la')) as f:
# for line in f:
# if line.startswith('dlname='):
# dlname = line.strip()[8:-1]
# break
#
# if not dlname or not exists(join(host, '.libs', dlname)):
# raise RuntimeError('failed to locate shared object! ({})'
# .format(dlname))
# shprint(sh.sed, '-i', 's/^dlname=.*$/dlname=\'libffi.so\'/', join(host, 'libffi.la'))
shprint(sh.cp, '-t', self.ctx.get_libs_dir(arch.arch),
join(self.get_host(arch), '.libs', 'libffi.so')) #,
开发者ID:423230557,项目名称:python-for-android,代码行数:26,代码来源:__init__.py
示例6: build_cython_components
def build_cython_components(self, arch):
info('Cythonizing anything necessary in {}'.format(self.name))
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
hostpython = sh.Command(self.ctx.hostpython)
info('Trying first build of {} to get cython files: this is '
'expected to fail'.format(self.name))
try:
shprint(hostpython, 'setup.py', 'build_ext', _env=env,
*self.setup_extra_args)
except sh.ErrorReturnCode_1:
print()
info('{} first build failed (as expected)'.format(self.name))
info('Running cython where appropriate')
shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
'-exec', self.ctx.cython, '{}', ';', _env=env)
info('ran cython')
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
_tail=20, _critical=True, *self.setup_extra_args)
print('stripping')
build_lib = glob.glob('./build/lib*')
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
env['STRIP'], '{}', ';', _env=env)
print('stripped!?')
开发者ID:simudream,项目名称:python-for-android,代码行数:27,代码来源:recipe.py
示例7: build_cython_components
def build_cython_components(self, arch):
info('Cythonizing anything necessary in {}'.format(self.name))
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
hostpython = sh.Command(self.ctx.hostpython)
shprint(hostpython, '-c', 'import sys; print(sys.path)', _env=env)
debug('cwd is {}'.format(realpath(curdir)))
info('Trying first build of {} to get cython files: this is '
'expected to fail'.format(self.name))
manually_cythonise = False
try:
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
*self.setup_extra_args)
except sh.ErrorReturnCode_1:
print()
info('{} first build failed (as expected)'.format(self.name))
manually_cythonise = True
if manually_cythonise:
self.cythonize_build(env=env)
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
_tail=20, _critical=True, *self.setup_extra_args)
else:
info('First build appeared to complete correctly, skipping manual'
'cythonising.')
self.strip_object_files(arch, env)
开发者ID:PKRoma,项目名称:python-for-android,代码行数:30,代码来源:recipe.py
示例8: install_python_package
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)
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:29,代码来源:__init__.py
示例9: run_pymodules_install
def run_pymodules_install(ctx, modules):
modules = filter(ctx.not_has_package, modules)
if not modules:
info('There are no Python modules to install, skipping')
return
info('The requirements ({}) don\'t have recipes, attempting to install '
'them with pip'.format(', '.join(modules)))
info('If this fails, it may mean that the module has compiled '
'components and needs a recipe.')
venv = sh.Command(ctx.virtualenv)
with current_directory(join(ctx.build_dir)):
shprint(venv, '--python=python2.7', 'venv')
info('Creating a requirements.txt file for the Python modules')
with open('requirements.txt', 'w') as fileh:
for module in modules:
fileh.write('{}\n'.format(module))
info('Installing Python modules with pip')
info('If this fails with a message about /bin/false, this '
'probably means the package cannot be installed with '
'pip as it needs a compilation recipe.')
# This bash method is what old-p4a used
# It works but should be replaced with something better
shprint(sh.bash, '-c', (
"source venv/bin/activate && env CC=/bin/false CXX=/bin/false "
"PYTHONPATH={0} pip install --target '{0}' --no-deps -r requirements.txt"
).format(ctx.get_site_packages_dir()))
开发者ID:latin1593,项目名称:python-for-android,代码行数:32,代码来源:build.py
示例10: build_arch
def build_arch(self, arch):
env = self.get_recipe_env(arch)
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format(
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl/include -I{jni_path}/sdl_mixer'.format(
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl_ttf -I{jni_path}/sdl_image'.format(
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
debug('pygame cflags', env['CFLAGS'])
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{libs_path} -L{src_path}/obj/local/{arch} -lm -lz'.format(
libs_path=self.ctx.libs_dir, src_path=self.ctx.bootstrap.build_dir, arch=env['ARCH'])
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')
with current_directory(self.get_build_dir(arch.arch)):
info('hostpython is ' + self.ctx.hostpython)
hostpython = sh.Command(self.ctx.hostpython)
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
_tail=10, _critical=True)
info('strip is ' + env['STRIP'])
build_lib = glob.glob('./build/lib*')
assert len(build_lib) == 1
print('stripping pygame')
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
env['STRIP'], '{}', ';')
python_install_path = join(self.ctx.build_dir, 'python-install')
warning('Should remove pygame tests etc. here, but skipping for now')
开发者ID:TangTab,项目名称:python-for-android,代码行数:32,代码来源:__init__.py
示例11: prebuild_arch
def prebuild_arch(self, arch):
if not self.is_patched(arch):
super(ReportLabRecipe, self).prebuild_arch(arch)
self.apply_patch('patches/fix-setup.patch', arch.arch)
recipe_dir = self.get_build_dir(arch.arch)
shprint(sh.touch, os.path.join(recipe_dir, '.patched'))
ft = self.get_recipe('freetype', self.ctx)
ft_dir = ft.get_build_dir(arch.arch)
ft_lib_dir = os.environ.get('_FT_LIB_', os.path.join(ft_dir, 'objs', '.libs'))
ft_inc_dir = os.environ.get('_FT_INC_', os.path.join(ft_dir, 'include'))
tmp_dir = os.path.normpath(os.path.join(recipe_dir, "..", "..", "tmp"))
info('reportlab recipe: recipe_dir={}'.format(recipe_dir))
info('reportlab recipe: tmp_dir={}'.format(tmp_dir))
info('reportlab recipe: ft_dir={}'.format(ft_dir))
info('reportlab recipe: ft_lib_dir={}'.format(ft_lib_dir))
info('reportlab recipe: ft_inc_dir={}'.format(ft_inc_dir))
with current_directory(recipe_dir):
sh.ls('-lathr')
ensure_dir(tmp_dir)
pfbfile = os.path.join(tmp_dir, "pfbfer-20070710.zip")
if not os.path.isfile(pfbfile):
sh.wget("http://www.reportlab.com/ftp/pfbfer-20070710.zip", "-O", pfbfile)
sh.unzip("-u", "-d", os.path.join(recipe_dir, "src", "reportlab", "fonts"), pfbfile)
if os.path.isfile("setup.py"):
with open('setup.py', 'rb') as f:
text = f.read().replace('_FT_LIB_', ft_lib_dir).replace('_FT_INC_', ft_inc_dir)
with open('setup.py', 'wb') as f:
f.write(text)
开发者ID:yileye,项目名称:python-for-android,代码行数:28,代码来源:__init__.py
示例12: apk
def apk(self, args):
'''Create an APK using the given distribution.'''
# AND: Need to add a parser here for any extra options
# parser = argparse.ArgumentParser(
# description='Build an APK')
# args = parser.parse_args(args)
ctx = self.ctx
dist = self._dist
# Manually fixing these arguments at the string stage is
# unsatisfactory and should probably be changed somehow, but
# we can't leave it until later as the build.py scripts assume
# they are in the current directory.
for i, arg in enumerate(args[:-1]):
if arg in ('--dir', '--private'):
args[i+1] = realpath(expanduser(args[i+1]))
build = imp.load_source('build', join(dist.dist_dir, 'build.py'))
with current_directory(dist.dist_dir):
build.parse_args(args)
shprint(sh.ant, 'debug', _tail=20, _critical=True)
# AND: This is very crude, needs improving. Also only works
# for debug for now.
info_main('# Copying APK to current directory')
apks = glob.glob(join(dist.dist_dir, 'bin', '*-*-debug.apk'))
if len(apks) == 0:
raise ValueError('Couldn\'t find the built APK')
if len(apks) > 1:
info('More than one built APK found...guessing you '
'just built {}'.format(apks[-1]))
shprint(sh.cp, apks[-1], './')
开发者ID:wybert,项目名称:python-for-android,代码行数:34,代码来源:toolchain.py
示例13: prebuild_arch
def prebuild_arch(self, arch):
super(AndroidRecipe, self).prebuild_arch(arch)
ctx_bootstrap = self.ctx.bootstrap.name
# define macros for Cython, C, Python
tpxi = 'DEF {} = {}\n'
th = '#define {} {}\n'
tpy = '{} = {}\n'
# make sure bootstrap name is in unicode
if isinstance(ctx_bootstrap, bytes):
ctx_bootstrap = ctx_bootstrap.decode('utf-8')
bootstrap = bootstrap_name = ctx_bootstrap
is_sdl2 = bootstrap_name in ('sdl2', 'sdl2python3', 'sdl2_gradle')
is_webview = bootstrap_name in ('webview',)
if is_sdl2 or is_webview:
if is_sdl2:
bootstrap = 'sdl2'
java_ns = u'org.kivy.android'
jni_ns = u'org/kivy/android'
else:
logger.error((
'unsupported bootstrap for android recipe: {}'
''.format(bootstrap_name)
))
exit(1)
config = {
'BOOTSTRAP': bootstrap,
'IS_SDL2': int(is_sdl2),
'PY2': int(will_build('python2')(self)),
'JAVA_NAMESPACE': java_ns,
'JNI_NAMESPACE': jni_ns,
}
# create config files for Cython, C and Python
with (
current_directory(self.get_build_dir(arch.arch))), (
open(join('android', 'config.pxi'), 'w')) as fpxi, (
open(join('android', 'config.h'), 'w')) as fh, (
open(join('android', 'config.py'), 'w')) as fpy:
for key, value in config.items():
fpxi.write(tpxi.format(key, repr(value)))
fpy.write(tpy.format(key, repr(value)))
fh.write(th.format(
key,
value if isinstance(value, int) else '"{}"'.format(value)
))
self.config_env[key] = str(value)
if is_sdl2:
fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n')
fh.write(
'#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n'
)
开发者ID:PKRoma,项目名称:python-for-android,代码行数:59,代码来源:__init__.py
示例14: install_python_package
def install_python_package(self, arch, name=None, env=None, is_dir=True):
'''Automate the installation of a Python package (or a cython
package where the cython components are pre-built).'''
# arch = self.filtered_archs[0] # old kivy-ios way
if name is None:
name = self.name
if env is None:
env = self.get_recipe_env(arch)
info('Installing {} into site-packages'.format(self.name))
with current_directory(self.get_build_dir(arch.arch)):
hostpython = sh.Command(self.hostpython_location)
# hostpython = sh.Command('python3.5')
if self.ctx.python_recipe.from_crystax:
# 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
# hpenv['PYTHONHOME'] = self.ctx.get_python_install_dir()
# shprint(hostpython, 'setup.py', 'build',
# _env=hpenv, *self.setup_extra_args)
shprint(hostpython, 'setup.py', 'install', '-O2',
'--root={}'.format(self.ctx.get_python_install_dir()),
'--install-lib=.',
# AND: will need to unhardcode the 3.5 when adding 2.7 (and other crystax supported versions)
_env=hpenv, *self.setup_extra_args)
# site_packages_dir = self.ctx.get_site_packages_dir()
# built_files = glob.glob(join('build', 'lib*', '*'))
# for filen in built_files:
# shprint(sh.cp, '-r', filen, join(site_packages_dir, split(filen)[-1]))
elif self.call_hostpython_via_targetpython:
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
*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',
_env=hpenv, *self.setup_extra_args)
# AND: Hardcoded python2.7 needs fixing
# If asked, also install in the hostpython build dir
if self.install_in_hostpython:
self.install_hostpython_package(arch)
开发者ID:LogicalDash,项目名称:python-for-android,代码行数:58,代码来源:recipe.py
示例15: download
def download(self):
if self.url is None:
info('Skipping {} download as no URL is set'.format(self.name))
return
url = self.versioned_url
ma = match(u'^(.+)#md5=([0-9a-f]{32})$', url)
if ma: # fragmented URL?
if self.md5sum:
raise ValueError(
('Received md5sum from both the {} recipe '
'and its url').format(self.name))
url = ma.group(1)
expected_md5 = ma.group(2)
else:
expected_md5 = self.md5sum
shprint(sh.mkdir, '-p', join(self.ctx.packages_path, self.name))
with current_directory(join(self.ctx.packages_path, self.name)):
filename = shprint(sh.basename, url).stdout[:-1].decode('utf-8')
do_download = True
marker_filename = '.mark-{}'.format(filename)
if exists(filename) and isfile(filename):
if not exists(marker_filename):
shprint(sh.rm, filename)
elif expected_md5:
current_md5 = md5sum(filename)
if current_md5 != expected_md5:
debug('* Generated md5sum: {}'.format(current_md5))
debug('* Expected md5sum: {}'.format(expected_md5))
raise ValueError(
('Generated md5sum does not match expected md5sum '
'for {} recipe').format(self.name))
do_download = False
else:
do_download = False
# If we got this far, we will download
if do_download:
debug('Downloading {} from {}'.format(self.name, url))
shprint(sh.rm, '-f', marker_filename)
self.download_file(self.versioned_url, filename)
shprint(sh.touch, marker_filename)
if exists(filename) and isfile(filename) and expected_md5:
current_md5 = md5sum(filename)
if expected_md5 is not None:
if current_md5 != expected_md5:
debug('* Generated md5sum: {}'.format(current_md5))
debug('* Expected md5sum: {}'.format(expected_md5))
raise ValueError(
('Generated md5sum does not match expected md5sum '
'for {} recipe').format(self.name))
else:
info('{} download already cached, skipping'.format(self.name))
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:58,代码来源:recipe.py
示例16: download_file
def download_file(self, url, target, cwd=None):
"""
(internal) Download an ``url`` to a ``target``.
"""
if not url:
return
info('Downloading {} from {}'.format(self.name, url))
if cwd:
target = join(cwd, target)
parsed_url = urlparse(url)
if parsed_url.scheme in ('http', 'https'):
def report_hook(index, blksize, size):
if size <= 0:
progression = '{0} bytes'.format(index * blksize)
else:
progression = '{0:.2f}%'.format(
index * blksize * 100. / float(size))
stdout.write('- Download {}\r'.format(progression))
stdout.flush()
if exists(target):
unlink(target)
urlretrieve(url, target, report_hook)
return target
elif parsed_url.scheme in ('git', 'git+ssh', 'git+http', 'git+https'):
if isdir(target):
with current_directory(target):
shprint(sh.git, 'fetch', '--tags')
if self.version:
shprint(sh.git, 'checkout', self.version)
shprint(sh.git, 'pull')
shprint(sh.git, 'pull', '--recurse-submodules')
shprint(sh.git, 'submodule', 'update', '--recursive')
else:
if url.startswith('git+'):
url = url[4:]
shprint(sh.git, 'clone', '--recursive', url, target)
if self.version:
with current_directory(target):
shprint(sh.git, 'checkout', self.version)
shprint(sh.git, 'submodule', 'update', '--recursive')
return target
开发者ID:simudream,项目名称:python-for-android,代码行数:45,代码来源:recipe.py
示例17: download_file
def download_file(self, url, target, cwd=None):
"""
(internal) Download an ``url`` to a ``target``.
"""
if not url:
return
info("Downloading {} from {}".format(self.name, url))
if cwd:
target = join(cwd, target)
parsed_url = urlparse(url)
if parsed_url.scheme in ("http", "https"):
def report_hook(index, blksize, size):
if size <= 0:
progression = "{0} bytes".format(index * blksize)
else:
progression = "{0:.2f}%".format(index * blksize * 100.0 / float(size))
stdout.write("- Download {}\r".format(progression))
stdout.flush()
if exists(target):
unlink(target)
urlretrieve(url, target, report_hook)
return target
elif parsed_url.scheme in ("git", "git+ssh", "git+http", "git+https"):
if isdir(target):
with current_directory(target):
shprint(sh.git, "fetch", "--tags")
if self.version:
shprint(sh.git, "checkout", self.version)
shprint(sh.git, "pull")
shprint(sh.git, "pull", "--recurse-submodules")
shprint(sh.git, "submodule", "update", "--recursive")
else:
if url.startswith("git+"):
url = url[4:]
shprint(sh.git, "clone", "--recursive", url, target)
if self.version:
with current_directory(target):
shprint(sh.git, "checkout", self.version)
shprint(sh.git, "submodule", "update", "--recursive")
return target
开发者ID:hottwaj,项目名称:python-for-android,代码行数:45,代码来源:recipe.py
示例18: build_compiled_components
def build_compiled_components(self,arch):
super(CppCompiledComponentsPythonRecipe, self).build_compiled_components(arch)
# Copy libgnustl_shared.so
with current_directory(self.get_build_dir(arch.arch)):
sh.cp(
"{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx,arch=arch),
self.ctx.get_libs_dir(arch.arch)
)
开发者ID:llfkj,项目名称:python-for-android,代码行数:9,代码来源:recipe.py
示例19: build_cython_components
def build_cython_components(self, arch):
info('Cythonizing anything necessary in {}'.format(self.name))
env = self.get_recipe_env(arch)
if self.ctx.python_recipe.from_crystax:
command = sh.Command('python{}'.format(self.ctx.python_recipe.version))
site_packages_dirs = command(
'-c', 'import site; print("\\n".join(site.getsitepackages()))')
site_packages_dirs = site_packages_dirs.stdout.decode('utf-8').split('\n')
# env['PYTHONPATH'] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
if 'PYTHONPATH' in env:
env['PYTHONPATH'] = env + ':{}'.format(':'.join(site_packages_dirs))
else:
env['PYTHONPATH'] = ':'.join(site_packages_dirs)
with current_directory(self.get_build_dir(arch.arch)):
hostpython = sh.Command(self.ctx.hostpython)
# hostpython = sh.Command('python3.5')
shprint(hostpython, '-c', 'import sys; print(sys.path)', _env=env)
print('cwd is', realpath(curdir))
info('Trying first build of {} to get cython files: this is '
'expected to fail'.format(self.name))
manually_cythonise = False
try:
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
*self.setup_extra_args)
except sh.ErrorReturnCode_1:
print()
info('{} first build failed (as expected)'.format(self.name))
manually_cythonise = True
if manually_cythonise:
info('Running cython where appropriate')
cyenv = env.copy()
if 'CYTHONPATH' in cyenv:
cyenv['PYTHONPATH'] = cyenv['CYTHONPATH']
elif 'PYTHONPATH' in cyenv:
del cyenv['PYTHONPATH']
cython = 'cython' if self.ctx.python_recipe.from_crystax else self.ctx.cython
cython_cmd = 'find "{}" -iname *.pyx | xargs "{}"'.format(
self.get_build_dir(arch.arch), cython)
shprint(sh.sh, '-c', cython_cmd, _env=cyenv)
info('ran cython')
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
_tail=20, _critical=True, *self.setup_extra_args)
else:
info('First build appeared to complete correctly, skipping manual'
'cythonising.')
print('stripping')
build_lib = glob.glob('./build/lib*')
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
env['STRIP'], '{}', ';', _env=env)
print('stripped!?')
开发者ID:FluidCoding,项目名称:python-for-android,代码行数:57,代码来源:recipe.py
示例20: load_info
def load_info(self):
'''Load information about the dist from the info file that p4a
automatically creates.'''
with current_directory(self.dist_dir):
filen = 'dist_info.json'
if not exists(filen):
return None
with open('dist_info.json', 'r') as fileh:
dist_info = json.load(fileh)
return dist_info
开发者ID:TangTab,项目名称:python-for-android,代码行数:10,代码来源:distribution.py
注:本文中的pythonforandroid.util.current_directory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论