本文整理汇总了Python中pythonforandroid.util.ensure_dir函数的典型用法代码示例。如果您正苦于以下问题:Python ensure_dir函数的具体用法?Python ensure_dir怎么用?Python ensure_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ensure_dir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: build_recipes
def build_recipes(build_order, python_modules, ctx):
# Put recipes in correct build order
bs = ctx.bootstrap
info_notify("Recipe build order is {}".format(build_order))
if python_modules:
python_modules = sorted(set(python_modules))
info_notify(
('The requirements ({}) were not found as recipes, they will be '
'installed with pip.').format(', '.join(python_modules)))
recipes = [Recipe.get_recipe(name, ctx) for name in build_order]
# download is arch independent
info_main('# Downloading recipes ')
for recipe in recipes:
recipe.download_if_necessary()
for arch in ctx.archs:
info_main('# Building all recipes for arch {}'.format(arch.arch))
info_main('# Unpacking recipes')
for recipe in recipes:
ensure_dir(recipe.get_build_container_dir(arch.arch))
recipe.prepare_build_dir(arch.arch)
info_main('# Prebuilding recipes')
# 2) prebuild packages
for recipe in recipes:
info_main('Prebuilding {} for {}'.format(recipe.name, arch.arch))
recipe.prebuild_arch(arch)
recipe.apply_patches(arch)
# 3) build packages
info_main('# Building recipes')
for recipe in recipes:
info_main('Building {} for {}'.format(recipe.name, arch.arch))
if recipe.should_build(arch):
recipe.build_arch(arch)
else:
info('{} said it is already built, skipping'
.format(recipe.name))
# 4) biglink everything
# AND: Should make this optional
info_main('# Biglinking object files')
if not ctx.python_recipe or not ctx.python_recipe.from_crystax:
biglink(ctx, arch)
else:
info('NDK is crystax, skipping biglink (will this work?)')
# 5) postbuild packages
info_main('# Postbuilding recipes')
for recipe in recipes:
info_main('Postbuilding {} for {}'.format(recipe.name, arch.arch))
recipe.postbuild_arch(arch)
info_main('# Installing pure Python modules')
run_pymodules_install(ctx, python_modules)
return
开发者ID:autosportlabs,项目名称:python-for-android,代码行数:60,代码来源:build.py
示例2: __init__
def __init__(self):
super(Context, self).__init__()
self.include_dirs = []
self._build_env_prepared = False
self._sdk_dir = None
self._ndk_dir = None
self._android_api = None
self._ndk_ver = None
self.toolchain_prefix = None
self.toolchain_version = None
self.local_recipes = None
# root of the toolchain
self.setup_dirs()
# this list should contain all Archs, it is pruned later
self.archs = (
ArchARM(self),
ArchARMv7_a(self),
Archx86(self)
)
ensure_dir(join(self.build_dir, 'bootstrap_builds'))
ensure_dir(join(self.build_dir, 'other_builds'))
# other_builds: where everything else is built
# remove the most obvious flags that can break the compilation
self.env.pop("LDFLAGS", None)
self.env.pop("ARCHFLAGS", None)
self.env.pop("CFLAGS", None)
开发者ID:simudream,项目名称:python-for-android,代码行数:34,代码来源:build.py
示例3: get_recipe_env
def get_recipe_env(self, arch, with_flags_in_cc=True):
env = super(CythonRecipe, self).get_recipe_env(arch, with_flags_in_cc)
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
self.ctx.get_libs_dir(arch.arch) +
' -L{} '.format(self.ctx.libs_dir) +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
arch.arch)))
if self.ctx.python_recipe.from_crystax:
env['LDFLAGS'] = (env['LDFLAGS'] +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)))
if self.ctx.python_recipe.from_crystax or self.ctx.python_recipe.name == 'python3':
env['LDSHARED'] = env['CC'] + ' -shared'
else:
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink.sh')
# shprint(sh.whereis, env['LDSHARED'], _env=env)
env['LIBLINK'] = 'NOTNONE'
env['NDKPLATFORM'] = self.ctx.ndk_platform
if self.ctx.copy_libs:
env['COPYLIBS'] = '1'
# Every recipe uses its own liblink path, object files are
# collected and biglinked later
liblink_path = join(self.get_build_container_dir(arch.arch),
'objects_{}'.format(self.name))
env['LIBLINK_PATH'] = liblink_path
ensure_dir(liblink_path)
return env
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:29,代码来源:recipe.py
示例4: 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
示例5: 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
示例6: make_build_dest
def make_build_dest(dest):
build_dest = join(build_root, dest)
if not isdir(build_dest):
ensure_dir(build_dest)
return build_dest, False
return build_dest, True
开发者ID:PKRoma,项目名称:python-for-android,代码行数:7,代码来源:__init__.py
示例7: build_arch
def build_arch(self, arch):
super(LibZMQRecipe, self).build_arch(arch)
env = self.get_recipe_env(arch)
#
# libsodium_recipe = Recipe.get_recipe('libsodium', self.ctx)
# libsodium_dir = libsodium_recipe.get_build_dir(arch.arch)
# env['sodium_CFLAGS'] = '-I{}'.format(join(
# libsodium_dir, 'src'))
# env['sodium_LDLAGS'] = '-L{}'.format(join(
# libsodium_dir, 'src', 'libsodium', '.libs'))
curdir = self.get_build_dir(arch.arch)
prefix = join(curdir, "install")
with current_directory(curdir):
bash = sh.Command('sh')
shprint(
bash, './configure',
'--host=arm-linux-androideabi',
'--without-documentation',
'--prefix={}'.format(prefix),
'--with-libsodium=no',
_env=env)
shprint(sh.make, _env=env)
shprint(sh.make, 'install', _env=env)
shutil.copyfile('.libs/libzmq.so', join(
self.ctx.get_libs_dir(arch.arch), 'libzmq.so'))
bootstrap_obj_dir = join(self.ctx.bootstrap.build_dir, 'obj', 'local', arch.arch)
ensure_dir(bootstrap_obj_dir)
shutil.copyfile(
'{}/sources/cxx-stl/gnu-libstdc++/{}/libs/{}/libgnustl_shared.so'.format(
self.ctx.ndk_dir, self.ctx.toolchain_version, arch),
join(bootstrap_obj_dir, 'libgnustl_shared.so'))
开发者ID:XX-net,项目名称:python-for-android,代码行数:33,代码来源:__init__.py
示例8: _unpack_aar
def _unpack_aar(self, aar, arch):
'''Unpack content of .aar bundle and copy to current dist dir.'''
with temp_directory() as temp_dir:
name = splitext(basename(aar))[0]
jar_name = name + '.jar'
info("unpack {} aar".format(name))
debug(" from {}".format(aar))
debug(" to {}".format(temp_dir))
shprint(sh.unzip, '-o', aar, '-d', temp_dir)
jar_src = join(temp_dir, 'classes.jar')
jar_tgt = join('libs', jar_name)
debug("copy {} jar".format(name))
debug(" from {}".format(jar_src))
debug(" to {}".format(jar_tgt))
ensure_dir('libs')
shprint(sh.cp, '-a', jar_src, jar_tgt)
so_src_dir = join(temp_dir, 'jni', arch.arch)
so_tgt_dir = join('libs', arch.arch)
debug("copy {} .so".format(name))
debug(" from {}".format(so_src_dir))
debug(" to {}".format(so_tgt_dir))
ensure_dir(so_tgt_dir)
so_files = glob.glob(join(so_src_dir, '*.so'))
for f in so_files:
shprint(sh.cp, '-a', f, so_tgt_dir)
开发者ID:kronenpj,项目名称:python-for-android,代码行数:27,代码来源:bootstrap.py
示例9: get_recipe_env
def get_recipe_env(self, arch, with_flags_in_cc=True):
env = super(CythonRecipe, self).get_recipe_env(arch, with_flags_in_cc)
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
self.ctx.get_libs_dir(arch.arch) +
' -L{} '.format(self.ctx.libs_dir) +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
arch.arch)))
if self.ctx.python_recipe.from_crystax:
env['LDFLAGS'] = (env['LDFLAGS'] +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)))
# ' -L/home/asandy/.local/share/python-for-android/build/bootstrap_builds/sdl2/libs/armeabi '
if self.ctx.python_recipe.from_crystax:
env['LDSHARED'] = env['CC'] + ' -shared'
else:
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink.sh')
# shprint(sh.whereis, env['LDSHARED'], _env=env)
env['LIBLINK'] = 'NOTNONE'
env['NDKPLATFORM'] = self.ctx.ndk_platform
if self.ctx.copy_libs:
env['COPYLIBS'] = '1'
# Every recipe uses its own liblink path, object files are
# collected and biglinked later
liblink_path = join(self.get_build_container_dir(arch.arch),
'objects_{}'.format(self.name))
env['LIBLINK_PATH'] = liblink_path
ensure_dir(liblink_path)
if self.ctx.python_recipe.from_crystax:
env['CFLAGS'] = '-I{} '.format(
join(self.ctx.ndk_dir, 'sources', 'python',
self.ctx.python_recipe.version, 'include',
'python')) + env['CFLAGS']
return env
开发者ID:LogicalDash,项目名称:python-for-android,代码行数:35,代码来源:recipe.py
示例10: build_arch
def build_arch(self, arch):
info("Extracting CrystaX python3 from NDK package")
dirn = self.ctx.get_python_install_dir()
ensure_dir(dirn)
self.ctx.hostpython = "python{}".format(self.version)
开发者ID:hottwaj,项目名称:python-for-android,代码行数:7,代码来源:__init__.py
示例11: get_recipe_env
def get_recipe_env(self, arch, with_flags_in_cc=True):
env = super(CythonRecipe, self).get_recipe_env(arch, with_flags_in_cc)
env["LDFLAGS"] = env["LDFLAGS"] + " -L{} ".format(
self.ctx.get_libs_dir(arch.arch)
+ " -L{} ".format(self.ctx.libs_dir)
+ " -L{}".format(join(self.ctx.bootstrap.build_dir, "obj", "local", arch.arch))
)
if self.ctx.python_recipe.from_crystax:
env["LDFLAGS"] = env["LDFLAGS"] + " -L{}".format(join(self.ctx.bootstrap.build_dir, "libs", arch.arch))
# ' -L/home/asandy/.local/share/python-for-android/build/bootstrap_builds/sdl2/libs/armeabi '
if self.ctx.python_recipe.from_crystax:
env["LDSHARED"] = env["CC"] + " -shared"
else:
env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink.sh")
# shprint(sh.whereis, env['LDSHARED'], _env=env)
env["LIBLINK"] = "NOTNONE"
env["NDKPLATFORM"] = self.ctx.ndk_platform
if self.ctx.copy_libs:
env["COPYLIBS"] = "1"
# Every recipe uses its own liblink path, object files are
# collected and biglinked later
liblink_path = join(self.get_build_container_dir(arch.arch), "objects_{}".format(self.name))
env["LIBLINK_PATH"] = liblink_path
ensure_dir(liblink_path)
if self.ctx.python_recipe.from_crystax:
env["CFLAGS"] = (
"-I{} ".format(
join(self.ctx.ndk_dir, "sources", "python", self.ctx.python_recipe.version, "include", "python")
)
+ env["CFLAGS"]
)
return env
开发者ID:hottwaj,项目名称:python-for-android,代码行数:35,代码来源:recipe.py
示例12: run_distribute
def run_distribute(self):
info_main('# Creating Android project from build and {} bootstrap'.format(
self.name))
info('This currently just copies the build stuff straight from the build dir.')
shprint(sh.rm, '-rf', self.dist_dir)
shprint(sh.cp, '-r', self.build_dir, self.dist_dir)
with current_directory(self.dist_dir):
with open('local.properties', 'w') as fileh:
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))
arch = self.ctx.archs[0]
if len(self.ctx.archs) > 1:
raise ValueError('built for more than one arch, but bootstrap cannot handle that yet')
info('Bootstrap running with arch {}'.format(arch))
with current_directory(self.dist_dir):
info('Copying python distribution')
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
self.distribute_aars(arch)
self.distribute_javaclasses(self.ctx.javaclass_dir)
python_bundle_dir = join('_python_bundle', '_python_bundle')
ensure_dir(python_bundle_dir)
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
join(self.dist_dir, python_bundle_dir), arch)
if 'sqlite3' not in self.ctx.recipe_build_order:
with open('blacklist.txt', 'a') as fileh:
fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n')
self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(ServiceOnlyBootstrap, self).run_distribute()
开发者ID:kronenpj,项目名称:python-for-android,代码行数:35,代码来源:__init__.py
示例13: run_distribute
def run_distribute(self):
info_main('# Creating Android project from build and {} bootstrap'.format(
self.name))
# src_path = join(self.ctx.root_dir, 'bootstrap_templates',
# self.name)
src_path = join(self.bootstrap_dir, 'build')
arch = self.ctx.archs[0]
if len(self.ctx.archs) > 1:
raise ValueError('built for more than one arch, but bootstrap cannot handle that yet')
info('Bootstrap running with arch {}'.format(arch))
with current_directory(self.dist_dir):
info('Creating initial layout')
for dirname in ('assets', 'bin', 'private', 'res', 'templates'):
if not exists(dirname):
shprint(sh.mkdir, dirname)
info('Copying default files')
shprint(sh.cp, '-a', join(self.build_dir, 'project.properties'), '.')
shprint(sh.cp, '-a', join(src_path, 'build.py'), '.')
shprint(sh.cp, '-a', join(src_path, 'buildlib'), '.')
shprint(sh.cp, '-a', join(src_path, 'src'), '.')
shprint(sh.cp, '-a', join(src_path, 'templates'), '.')
shprint(sh.cp, '-a', join(src_path, 'res'), '.')
shprint(sh.cp, '-a', join(src_path, 'blacklist.txt'), '.')
shprint(sh.cp, '-a', join(src_path, 'whitelist.txt'), '.')
with open('local.properties', 'w') as fileh:
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))
info('Copying python distribution')
python_bundle_dir = join('_python_bundle', '_python_bundle')
if 'python2legacy' in self.ctx.recipe_build_order:
# a special case with its own packaging location
python_bundle_dir = 'private'
# And also must had an install directory, make sure of that
self.ctx.python_recipe.create_python_install(self.dist_dir)
self.distribute_libs(
arch, [join(self.build_dir, 'libs', arch.arch),
self.ctx.get_libs_dir(arch.arch)])
self.distribute_aars(arch)
self.distribute_javaclasses(self.ctx.javaclass_dir)
ensure_dir(python_bundle_dir)
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
join(self.dist_dir, python_bundle_dir), arch)
if 'sqlite3' not in self.ctx.recipe_build_order:
with open('blacklist.txt', 'a') as fileh:
fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n')
self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(PygameBootstrap, self).run_distribute()
开发者ID:kivy,项目名称:python-for-android,代码行数:59,代码来源:__init__.py
示例14: distribute_libs
def distribute_libs(self, arch, src_dirs, wildcard='*', dest_dir="libs"):
'''Copy existing arch libs from build dirs to current dist dir.'''
info('Copying libs')
tgt_dir = join(dest_dir, arch.arch)
ensure_dir(tgt_dir)
for src_dir in src_dirs:
for lib in glob.glob(join(src_dir, wildcard)):
shprint(sh.cp, '-a', lib, tgt_dir)
开发者ID:kronenpj,项目名称:python-for-android,代码行数:8,代码来源:bootstrap.py
示例15: run_distribute
def run_distribute(self):
info_main("# Creating Android project ({})".format(self.name))
arch = self.ctx.archs[0]
python_install_dir = self.ctx.get_python_install_dir()
from_crystax = self.ctx.python_recipe.from_crystax
if len(self.ctx.archs) > 1:
raise ValueError("SDL2/gradle support only one arch")
info("Copying SDL2/gradle build for {}".format(arch))
shprint(sh.rm, "-rf", self.dist_dir)
shprint(sh.cp, "-r", self.build_dir, self.dist_dir)
# either the build use environment variable (ANDROID_HOME)
# or the local.properties if exists
with current_directory(self.dist_dir):
with open('local.properties', 'w') as fileh:
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))
with current_directory(self.dist_dir):
info("Copying Python distribution")
hostpython = sh.Command(self.ctx.hostpython)
if self.ctx.python_recipe.name == 'python2':
try:
shprint(hostpython, '-OO', '-m', 'compileall',
python_install_dir,
_tail=10, _filterout="^Listing")
except sh.ErrorReturnCode:
pass
if 'python2' in self.ctx.recipe_build_order and not exists('python-install'):
shprint(
sh.cp, '-a', python_install_dir, './python-install')
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
self.distribute_javaclasses(self.ctx.javaclass_dir,
dest_dir=join("src", "main", "java"))
python_bundle_dir = join('_python_bundle', '_python_bundle')
if 'python2' in self.ctx.recipe_build_order:
# Python 2 is a special case with its own packaging location
python_bundle_dir = 'private'
ensure_dir(python_bundle_dir)
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
join(self.dist_dir, python_bundle_dir), arch)
if 'sqlite3' not in self.ctx.recipe_build_order:
with open('blacklist.txt', 'a') as fileh:
fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n')
self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(SDL2GradleBootstrap, self).run_distribute()
开发者ID:KeyWeeUsr,项目名称:python-for-android,代码行数:55,代码来源:__init__.py
示例16: 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
示例17: get_recipe_env
def get_recipe_env(self, arch=None):
env = super(PygameRecipe, self).get_recipe_env(arch)
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
self.ctx.get_libs_dir(arch.arch))
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')
env['LIBLINK'] = 'NOTNONE'
env['NDKPLATFORM'] = self.ctx.ndk_platform
# Every recipe uses its own liblink path, object files are collected and biglinked later
liblink_path = join(self.get_build_container_dir(arch.arch), 'objects_{}'.format(self.name))
env['LIBLINK_PATH'] = liblink_path
ensure_dir(liblink_path)
return env
开发者ID:TangTab,项目名称:python-for-android,代码行数:13,代码来源:__init__.py
示例18: get_recipe_env
def get_recipe_env(self, arch, with_flags_in_cc=True):
env = super(CythonRecipe, self).get_recipe_env(arch, with_flags_in_cc)
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
self.ctx.get_libs_dir(arch.arch) +
' -L{} '.format(self.ctx.libs_dir) +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
arch.arch)))
if self.ctx.python_recipe.from_crystax:
env['LDFLAGS'] = (env['LDFLAGS'] +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)))
if self.ctx.python_recipe.name == 'python2legacy':
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink.sh')
else:
env['LDSHARED'] = env['CC'] + ' -shared'
# shprint(sh.whereis, env['LDSHARED'], _env=env)
env['LIBLINK'] = 'NOTNONE'
env['NDKPLATFORM'] = self.ctx.ndk_platform
if self.ctx.copy_libs:
env['COPYLIBS'] = '1'
# Every recipe uses its own liblink path, object files are
# collected and biglinked later
liblink_path = join(self.get_build_container_dir(arch.arch),
'objects_{}'.format(self.name))
env['LIBLINK_PATH'] = liblink_path
ensure_dir(liblink_path)
# Add crystax-specific site packages:
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')
if 'PYTHONPATH' in env:
env['PYTHONPATH'] = env['PYTHONPATH'] +\
':{}'.format(':'.join(site_packages_dirs))
else:
env['PYTHONPATH'] = ':'.join(site_packages_dirs)
while env['PYTHONPATH'].find("::") > 0:
env['PYTHONPATH'] = env['PYTHONPATH'].replace("::", ":")
if env['PYTHONPATH'].endswith(":"):
env['PYTHONPATH'] = env['PYTHONPATH'][:-1]
if env['PYTHONPATH'].startswith(":"):
env['PYTHONPATH'] = env['PYTHONPATH'][1:]
return env
开发者ID:PKRoma,项目名称:python-for-android,代码行数:47,代码来源:recipe.py
示例19: unpack
def unpack(self, arch):
info_main('Unpacking {} for {}'.format(self.name, arch))
build_dir = self.get_build_container_dir(arch)
user_dir = environ.get('P4A_{}_DIR'.format(self.name.lower()))
if user_dir is not None:
info("Installing KivyMD development versoion (from source)")
self.clean_build()
shprint(sh.rm, '-rf', build_dir)
shprint(sh.mkdir, '-p', build_dir)
shprint(sh.rmdir, build_dir)
ensure_dir(build_dir)
ensure_dir(build_dir + "/kivymd")
shprint(sh.cp, user_dir + '/setup.py', self.get_build_dir(arch) + "/setup.py")
shprint(sh.cp, '-a', user_dir + "/kivymd", self.get_build_dir(arch) + "/kivymd")
return
开发者ID:cruor99,项目名称:KivyMD,代码行数:17,代码来源:__init__.py
示例20: build_arch
def build_arch(self, arch):
# We don't have to actually build anything as CrystaX comes
# with the necessary modules. They are included by modifying
# the Android.mk in the jni folder.
# If the Python version to be used is not prebuilt with the CrystaX
# NDK, we do have to download it.
crystax_python_dir = join(self.ctx.ndk_dir, 'sources', 'python')
if not exists(join(crystax_python_dir, self.version)):
info(('The NDK does not have a prebuilt Python {}, trying '
'to obtain one.').format(self.version))
if self.version not in prebuilt_download_locations:
error(('No prebuilt version for Python {} could be found, '
'the built cannot continue.'))
exit(1)
with temp_directory() as td:
self.download_file(prebuilt_download_locations[self.version],
join(td, 'downloaded_python'))
shprint(sh.tar, 'xf', join(td, 'downloaded_python'),
'--directory', crystax_python_dir)
if not exists(join(crystax_python_dir, self.version)):
error(('Something went wrong, the directory at {} should '
'have been created but does not exist.').format(
join(crystax_python_dir, self.version)))
if not exists(join(
crystax_python_dir, self.version, 'libs', arch.arch)):
error(('The prebuilt Python for version {} does not contain '
'binaries for your chosen architecture "{}".').format(
self.version, arch.arch))
exit(1)
# TODO: We should have an option to build a new Python. This
# would also allow linking to openssl and sqlite from CrystaX.
dirn = self.ctx.get_python_install_dir()
ensure_dir(dirn)
# Instead of using a locally built hostpython, we use the
# user's Python for now. They must have the right version
# available. Using e.g. pyenv makes this easy.
self.ctx.hostpython = 'python{}'.format(self.version)
开发者ID:PKRoma,项目名称:python-for-android,代码行数:46,代码来源:__init__.py
注:本文中的pythonforandroid.util.ensure_dir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论