INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Copy existing javaclasses from build dir to current dist dir. | def distribute_javaclasses(self, javaclass_dir, dest_dir="src"):
'''Copy existing javaclasses from build dir to current dist dir.'''
info('Copying java files')
ensure_dir(dest_dir)
for filename in glob.glob(javaclass_dir):
shprint(sh.cp, '-a', filename, dest_dir) |
Process existing .aar bundles and copy to current dist dir. | def distribute_aars(self, arch):
'''Process existing .aar bundles and copy to current dist dir.'''
info('Unpacking aars')
for aar in glob.glob(join(self.ctx.aars_dir, '*.aar')):
self._unpack_aar(aar, arch) |
Unpack content of .aar bundle and copy to current dist dir. | 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(aa... |
Returns a set of modified recipes between the current branch and the one
in param. | def modified_recipes(branch='origin/master'):
"""
Returns a set of modified recipes between the current branch and the one
in param.
"""
# using the contrib version on purpose rather than sh.git, since it comes
# with a bunch of fixes, e.g. disabled TTY, see:
# https://stackoverflow.com/a/20... |
Builds an APK given a target Python and a set of requirements. | def build(target_python, requirements):
"""
Builds an APK given a target Python and a set of requirements.
"""
if not requirements:
return
testapp = 'setup_testapp_python2.py'
android_sdk_home = os.environ['ANDROID_SDK_HOME']
android_ndk_home = os.environ['ANDROID_NDK_HOME']
if t... |
- Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment.
- Moves all -l<lib> from LDFLAGS to LIBS environment.
- Fixes linker name (use cross compiler) and flags (appends LIBS) | def get_recipe_env(self, arch=None, with_flags_in_cc=True):
"""
- Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment.
- Moves all -l<lib> from LDFLAGS to LIBS environment.
- Fixes linker name (use cross compiler) and flags (appends LIBS)
"""
env = super(Geve... |
Extract localizable strings from the given template node. Per
default this function returns matches in babel style that means non string
parameters as well as keyword arguments are returned as `None`. This
allows Babel to figure out what you really meant if you are using
gettext functions that allow k... | def extract_from_ast(node, gettext_functions=GETTEXT_FUNCTIONS,
babel_style=True):
"""Extract localizable strings from the given template node. Per
default this function returns matches in babel style that means non string
parameters as well as keyword arguments are returned as `None`.... |
Babel extraction method for Jinja templates.
.. versionchanged:: 2.3
Basic support for translation comments was added. If `comment_tags`
is now set to a list of keywords for extraction, the extractor will
try to find the best preceeding comment that begins with one of the
keywords. Fo... | def babel_extract(fileobj, keywords, comment_tags, options):
"""Babel extraction method for Jinja templates.
.. versionchanged:: 2.3
Basic support for translation comments was added. If `comment_tags`
is now set to a list of keywords for extraction, the extractor will
try to find the best... |
Parse a translatable tag. | def parse(self, parser):
"""Parse a translatable tag."""
lineno = next(parser.stream).lineno
# find all the variables referenced. Additionally a variable can be
# defined in the body of the trans block too, but this is checked at
# a later state.
plural_expr = None
... |
Generates a useful node from the data provided. | def _make_node(self, singular, plural, variables, plural_expr):
"""Generates a useful node from the data provided."""
# singular only:
if plural_expr is None:
gettext = nodes.Name('gettext', 'load')
node = nodes.Call(gettext, [nodes.Const(singular)],
... |
Load the extensions from the list and bind it to the environment.
Returns a dict of instanciated environments. | def load_extensions(environment, extensions):
"""Load the extensions from the list and bind it to the environment.
Returns a dict of instanciated environments.
"""
result = {}
for extension in extensions:
if isinstance(extension, basestring):
extension = import_string(extension)
... |
Add the items to the instance of the environment if they do not exist
yet. This is used by :ref:`extensions <writing-extensions>` to register
callbacks and configuration values without breaking inheritance. | def extend(self, **attributes):
"""Add the items to the instance of the environment if they do not exist
yet. This is used by :ref:`extensions <writing-extensions>` to register
callbacks and configuration values without breaking inheritance.
"""
for key, value in attributes.iter... |
Internal parsing function used by `parse` and `compile`. | def _parse(self, source, name, filename):
"""Internal parsing function used by `parse` and `compile`."""
return Parser(self, source, name, _encode_filename(filename)).parse() |
Preprocesses the source with all extensions. This is automatically
called for all parsing and compiling methods but *not* for :meth:`lex`
because there you usually only want the actual source tokenized. | def preprocess(self, source, name=None, filename=None):
"""Preprocesses the source with all extensions. This is automatically
called for all parsing and compiling methods but *not* for :meth:`lex`
because there you usually only want the actual source tokenized.
"""
return reduce... |
Compile a node or template source code. The `name` parameter is
the load name of the template after it was joined using
:meth:`join_path` if necessary, not the filename on the file system.
the `filename` parameter is the estimated filename of the template on
the file system. If the tem... | def compile(self, source, name=None, filename=None, raw=False,
defer_init=False):
"""Compile a node or template source code. The `name` parameter is
the load name of the template after it was joined using
:meth:`join_path` if necessary, not the filename on the file system.
... |
Exception handling helper. This is used internally to either raise
rewritten exceptions or return a rendered traceback for the template. | def handle_exception(self, exc_info=None, rendered=False, source_hint=None):
"""Exception handling helper. This is used internally to either raise
rewritten exceptions or return a rendered traceback for the template.
"""
global _make_traceback
if exc_info is None:
ex... |
Creates a template object from compiled code and the globals. This
is used by the loaders and environment to create a template object. | def from_code(cls, environment, code, globals, uptodate=None):
"""Creates a template object from compiled code and the globals. This
is used by the loaders and environment to create a template object.
"""
namespace = {
'environment': environment,
'__file__': ... |
This method accepts the same arguments as the `dict` constructor:
A dict, a dict subclass or some keyword arguments. If no arguments
are given the context will be empty. These two calls do the same::
template.render(knights='that say nih')
template.render({'knights': 'that say... | def render(self, *args, **kwargs):
"""This method accepts the same arguments as the `dict` constructor:
A dict, a dict subclass or some keyword arguments. If no arguments
are given the context will be empty. These two calls do the same::
template.render(knights='that say nih')
... |
For very large templates it can be useful to not render the whole
template at once but evaluate each statement after another and yield
piece for piece. This method basically does exactly that and returns
a generator that yields one item after another as unicode strings.
It accepts the ... | def generate(self, *args, **kwargs):
"""For very large templates it can be useful to not render the whole
template at once but evaluate each statement after another and yield
piece for piece. This method basically does exactly that and returns
a generator that yields one item after anot... |
The template as module. This is used for imports in the
template runtime but is also useful if one wants to access
exported template variables from the Python layer:
>>> t = Template('{% macro foo() %}42{% endmacro %}23')
>>> unicode(t.module)
u'23'
>>> t.module.foo()
... | def module(self):
"""The template as module. This is used for imports in the
template runtime but is also useful if one wants to access
exported template variables from the Python layer:
>>> t = Template('{% macro foo() %}42{% endmacro %}23')
>>> unicode(t.module)
u'23'... |
The debug info mapping. | def debug_info(self):
"""The debug info mapping."""
return [tuple(map(int, x.split('='))) for x in
self._debug_info.split('&')] |
Dump the complete stream into a file or file-like object.
Per default unicode strings are written, if you want to encode
before writing specifiy an `encoding`.
Example usage::
Template('Hello {{ name }}!').stream(name='foo').dump('hello.html') | def dump(self, fp, encoding=None, errors='strict'):
"""Dump the complete stream into a file or file-like object.
Per default unicode strings are written, if you want to encode
before writing specifiy an `encoding`.
Example usage::
Template('Hello {{ name }}!').stream(name='... |
Disable the output buffering. | def disable_buffering(self):
"""Disable the output buffering."""
self._next = self._gen.next
self.buffered = False |
Enable buffering. Buffer `size` items before yielding them. | def enable_buffering(self, size=5):
"""Enable buffering. Buffer `size` items before yielding them."""
if size <= 1:
raise ValueError('buffer size too small')
def generator(next):
buf = []
c_size = 0
push = buf.append
while 1:
... |
Decorator for ToolchainCL methods. If present, the method will
automatically make sure a dist has been built before continuing
or, if no dists are present or can be obtained, will raise an
error. | def require_prebuilt_dist(func):
"""Decorator for ToolchainCL methods. If present, the method will
automatically make sure a dist has been built before continuing
or, if no dists are present or can be obtained, will raise an
error.
"""
@wraps(func)
def wrapper_func(self, args):
ctx ... |
Parses out any distribution-related arguments, and uses them to
obtain a Distribution class instance for the build. | def dist_from_args(ctx, args):
"""Parses out any distribution-related arguments, and uses them to
obtain a Distribution class instance for the build.
"""
return Distribution.get_distribution(
ctx,
name=args.dist_name,
recipes=split_argument_list(args.requirements),
ndk_ap... |
Parses out any bootstrap related arguments, and uses them to build
a dist. | def build_dist_from_args(ctx, dist, args):
"""Parses out any bootstrap related arguments, and uses them to build
a dist."""
bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
blacklist = getattr(args, "blacklist_requirements", "").split(",")
if len(blacklist) == 1 and blacklist[0] == "":
blac... |
Print warning messages for any deprecated arguments that were passed. | def warn_on_deprecated_args(self, args):
"""
Print warning messages for any deprecated arguments that were passed.
"""
# Output warning if setup.py is present and neither --ignore-setup-py
# nor --use-setup-py was specified.
if getattr(args, "private", None) is not None ... |
List all the bootstraps available to build with. | def bootstraps(self, _args):
"""List all the bootstraps available to build with."""
for bs in Bootstrap.list_bootstraps():
bs = Bootstrap.get_bootstrap(bs, self.ctx)
print('{Fore.BLUE}{Style.BRIGHT}{bs.name}{Style.RESET_ALL}'
.format(bs=bs, Fore=Out_Fore, Style=... |
Delete all compiled distributions in the internal distribution
directory. | def clean_dists(self, _args):
"""Delete all compiled distributions in the internal distribution
directory."""
ctx = self.ctx
if exists(ctx.dist_dir):
shutil.rmtree(ctx.dist_dir) |
Delete all build components; the package cache, package builds,
bootstrap builds and distributions. | def clean_all(self, args):
"""Delete all build components; the package cache, package builds,
bootstrap builds and distributions."""
self.clean_dists(args)
self.clean_builds(args)
self.clean_download_cache(args) |
Delete all the bootstrap builds. | def clean_bootstrap_builds(self, _args):
"""Delete all the bootstrap builds."""
if exists(join(self.ctx.build_dir, 'bootstrap_builds')):
shutil.rmtree(join(self.ctx.build_dir, 'bootstrap_builds')) |
Delete all build caches for each recipe, python-install, java code
and compiled libs collection.
This does *not* delete the package download cache or the final
distributions. You can also use clean_recipe_build to delete the build
of a specific recipe. | def clean_builds(self, _args):
"""Delete all build caches for each recipe, python-install, java code
and compiled libs collection.
This does *not* delete the package download cache or the final
distributions. You can also use clean_recipe_build to delete the build
of a specific... |
Deletes the build files of the given recipe.
This is intended for debug purposes. You may experience
strange behaviour or problems with some recipes if their
build has made unexpected state changes. If this happens, run
clean_builds, or attempt to clean other recipes until things
... | def clean_recipe_build(self, args):
"""Deletes the build files of the given recipe.
This is intended for debug purposes. You may experience
strange behaviour or problems with some recipes if their
build has made unexpected state changes. If this happens, run
clean_builds, or att... |
Deletes a download cache for recipes passed as arguments. If no
argument is passed, it'll delete *all* downloaded caches. ::
p4a clean_download_cache kivy,pyjnius
This does *not* delete the build caches or final distributions. | def clean_download_cache(self, args):
""" Deletes a download cache for recipes passed as arguments. If no
argument is passed, it'll delete *all* downloaded caches. ::
p4a clean_download_cache kivy,pyjnius
This does *not* delete the build caches or final distributions.
"""
... |
Copies a created dist to an output dir.
This makes it easy to navigate to the dist to investigate it
or call build.py, though you do not in general need to do this
and can use the apk command instead. | def export_dist(self, args):
"""Copies a created dist to an output dir.
This makes it easy to navigate to the dist to investigate it
or call build.py, though you do not in general need to do this
and can use the apk command instead.
"""
ctx = self.ctx
dist = dist... |
Create an APK using the given distribution. | def apk(self, args):
"""Create an APK using the given distribution."""
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 ... |
List the target architectures available to be built for. | def archs(self, _args):
"""List the target architectures available to be built for."""
print('{Style.BRIGHT}Available target architectures are:'
'{Style.RESET_ALL}'.format(Style=Out_Style))
for arch in self.ctx.archs:
print(' {}'.format(arch.arch)) |
Lists all distributions currently available (i.e. that have already
been built). | def distributions(self, _args):
"""Lists all distributions currently available (i.e. that have already
been built)."""
ctx = self.ctx
dists = Distribution.get_distributions(ctx)
if dists:
print('{Style.BRIGHT}Distributions currently installed are:'
... |
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. | 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
$P... |
Call the adb executable from the SDK, passing the given commands as
arguments. | 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,
us... |
Print the status of the specified build. | def build_status(self, _args):
"""Print the status of the specified build. """
print('{Style.BRIGHT}Bootstraps whose core components are probably '
'already built:{Style.RESET_ALL}'.format(Style=Out_Style))
bootstrap_dir = join(self.ctx.build_dir, 'bootstrap_builds')
if ex... |
Make the build and target directories | def prebuild_arch(self, arch):
"""Make the build and target directories"""
path = self.get_build_dir(arch.arch)
if not exists(path):
info("creating {}".format(path))
shprint(sh.mkdir, '-p', path) |
simple shared compile | def build_arch(self, arch):
"""simple shared compile"""
env = self.get_recipe_env(arch, with_flags_in_cc=False)
for path in (
self.get_build_dir(arch.arch),
join(self.ctx.python_recipe.get_build_dir(arch.arch), 'Lib'),
join(self.ctx.python_recipe.g... |
Looks up a variable like `__getitem__` or `get` but returns an
:class:`Undefined` object with the name of the name looked up. | def resolve(self, key):
"""Looks up a variable like `__getitem__` or `get` but returns an
:class:`Undefined` object with the name of the name looked up.
"""
if key in self.vars:
return self.vars[key]
if key in self.parent:
return self.parent[key]
r... |
Call the callable with the arguments and keyword arguments
provided but inject the active context or environment as first
argument if the callable is a :func:`contextfunction` or
:func:`environmentfunction`. | def call(__self, __obj, *args, **kwargs):
"""Call the callable with the arguments and keyword arguments
provided but inject the active context or environment as first
argument if the callable is a :func:`contextfunction` or
:func:`environmentfunction`.
"""
if __debug__:
... |
Regular callback function for undefined objects that raises an
`UndefinedError` on call. | def _fail_with_undefined_error(self, *args, **kwargs):
"""Regular callback function for undefined objects that raises an
`UndefinedError` on call.
"""
if self._undefined_hint is None:
if self._undefined_obj is missing:
hint = '%r is undefined' % self._undefine... |
Turn a dependency list into lowercase, and make sure all entries
that are just a string become a tuple of strings | def fix_deplist(deps):
""" Turn a dependency list into lowercase, and make sure all entries
that are just a string become a tuple of strings
"""
deps = [
((dep.lower(),)
if not isinstance(dep, (list, tuple))
else tuple([dep_entry.lower()
for dep_entry i... |
Get the dependencies of a recipe with filtered out blacklist, and
turned into tuples with fix_deplist() | def get_dependency_tuple_list_for_recipe(recipe, blacklist=None):
""" Get the dependencies of a recipe with filtered out blacklist, and
turned into tuples with fix_deplist()
"""
if blacklist is None:
blacklist = set()
assert(type(blacklist) == set)
if recipe.depends is None:
... |
For each possible recipe ordering, try to add the new recipe name
to that order. Recursively do the same thing with all the
dependencies of each recipe. | def recursively_collect_orders(
name, ctx, all_inputs, orders=None, blacklist=None
):
'''For each possible recipe ordering, try to add the new recipe name
to that order. Recursively do the same thing with all the
dependencies of each recipe.
'''
name = name.lower()
if orders is ... |
Do a topological sort on the dependency graph dict. | def find_order(graph):
'''
Do a topological sort on the dependency graph dict.
'''
while graph:
# Find all items without a parent
leftmost = [l for l, s in graph.items() if not s]
if not leftmost:
raise ValueError('Dependency cycle detected! %s' % graph)
# If ... |
This is a pre-flight check function that will completely ignore
recipe order or choosing an actual value in any of the multiple
choice tuples/dependencies, and just do a very basic obvious
conflict check. | def obvious_conflict_checker(ctx, name_tuples, blacklist=None):
""" This is a pre-flight check function that will completely ignore
recipe order or choosing an actual value in any of the multiple
choice tuples/dependencies, and just do a very basic obvious
conflict check.
"""
deps_we... |
Returns a string with the include folders | def include_flags(self, arch):
'''Returns a string with the include folders'''
openssl_includes = join(self.get_build_dir(arch.arch), 'include')
return (' -I' + openssl_includes +
' -I' + join(openssl_includes, 'internal') +
' -I' + join(openssl_includes, 'openssl... |
Takes care to properly link libraries with python depending on our
requirements and the attribute :attr:`opt_depends`. | def set_libs_flags(self, env, arch):
'''Takes care to properly link libraries with python depending on our
requirements and the attribute :attr:`opt_depends`.
'''
def add_flags(include_flags, link_dirs, link_libs):
env['CPPFLAGS'] = env.get('CPPFLAGS', '') + include_flags
... |
Compile the python files (recursively) for the python files inside
a given folder.
.. note:: python2 compiles the files into extension .pyo, but in
python3, and as of Python 3.5, the .pyo filename extension is no
longer used...uses .pyc (https://www.python.org/dev/peps/pep-0488) | def compile_python_files(self, dir):
'''
Compile the python files (recursively) for the python files inside
a given folder.
.. note:: python2 compiles the files into extension .pyo, but in
python3, and as of Python 3.5, the .pyo filename extension is no
longer us... |
Create a packaged python bundle in the target directory, by
copying all the modules and standard library to the right
place. | def create_python_bundle(self, dirn, arch):
"""
Create a packaged python bundle in the target directory, by
copying all the modules and standard library to the right
place.
"""
# Todo: find a better way to find the build libs folder
modules_build_dir = join(
... |
Adds openssl recipe to include and library path. | def get_recipe_env(self, arch, with_flags_in_cc=True):
"""
Adds openssl recipe to include and library path.
"""
env = super(ScryptRecipe, self).get_recipe_env(arch, with_flags_in_cc)
openssl_recipe = self.get_recipe('openssl', self.ctx)
env['CFLAGS'] += openssl_recipe.inc... |
Recursively walks all the files and directories in ``dirn``,
ignoring directories that match any pattern in ``invalid_dirns``
and files that patch any pattern in ``invalid_filens``.
``invalid_dirns`` and ``invalid_filens`` should both be lists of
strings to match. ``invalid_dir_patterns`` expects a lis... | def walk_valid_filens(base_dir, invalid_dir_names, invalid_file_patterns):
"""Recursively walks all the files and directories in ``dirn``,
ignoring directories that match any pattern in ``invalid_dirns``
and files that patch any pattern in ``invalid_filens``.
``invalid_dirns`` and ``invalid_filens`` sh... |
Handles a raised BuildInterruptingException by printing its error
message and associated instructions, if any, then exiting. | def handle_build_exception(exception):
"""
Handles a raised BuildInterruptingException by printing its error
message and associated instructions, if any, then exiting.
"""
error('Build failed: {}'.format(exception.message))
if exception.instructions is not None:
info('Instructions: {}'.f... |
Using jinja2, render `template` to the filename `dest`, supplying the
keyword arguments as template parameters. | def render(template, dest, **kwargs):
'''Using jinja2, render `template` to the filename `dest`, supplying the
keyword arguments as template parameters.
'''
dest_dir = dirname(dest)
if dest_dir and not exists(dest_dir):
makedirs(dest_dir)
template = environment.get_template(template)
... |
Search for all the python related files, and construct the pythonXX.zip
According to
# http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html
site-packages, config and lib-dynload will be not included. | def make_python_zip():
'''
Search for all the python related files, and construct the pythonXX.zip
According to
# http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html
site-packages, config and lib-dynload will be not included.
'''
if not exists('private'):
print... |
Make a zip file `fn` from the contents of source_dis. | def make_tar(tfn, source_dirs, ignore_path=[], optimize_python=True):
'''
Make a zip file `fn` from the contents of source_dis.
'''
# selector function
def select(fn):
rfn = realpath(fn)
for p in ignore_path:
if p.endswith('/'):
p = p[:-1]
if ... |
Compile *.py in directory `dfn` to *.pyo | def compile_dir(dfn, optimize_python=True):
'''
Compile *.py in directory `dfn` to *.pyo
'''
if PYTHON is None:
return
if int(PYTHON_VERSION[0]) >= 3:
args = [PYTHON, '-m', 'compileall', '-b', '-f', dfn]
else:
args = [PYTHON, '-m', 'compileall', '-f', dfn]
if optimi... |
Creates expected build and symlinks system Python version. | def build_arch(self, arch):
"""
Creates expected build and symlinks system Python version.
"""
self.ctx.hostpython = '/usr/bin/false'
# creates the sub buildir (used by other recipes)
# https://github.com/kivy/python-for-android/issues/1154
sub_build_dir = join(se... |
Using jinja2, render `template` to the filename `dest`, supplying the
keyword arguments as template parameters. | def render(template, dest, **kwargs):
'''Using jinja2, render `template` to the filename `dest`, supplying the
keyword arguments as template parameters.
'''
template = environment.get_template(template)
text = template.render(**kwargs)
f = open(dest, 'wb')
f.write(text.encode('utf-8'))
... |
Calculate the md5sum of a file. | def md5sum(filen):
'''Calculate the md5sum of a file.
'''
with open(filen, 'rb') as fileh:
md5 = hashlib.md5(fileh.read())
return md5.hexdigest() |
A property returning the url of the recipe with ``{version}``
replaced by the :attr:`url`. If accessing the url, you should use this
property, *not* access the url directly. | def versioned_url(self):
'''A property returning the url of the recipe with ``{version}``
replaced by the :attr:`url`. If accessing the url, you should use this
property, *not* access the url directly.'''
if self.url is None:
return None
return self.url.format(version... |
(internal) Download an ``url`` to a ``target``. | 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)... |
Apply a patch from the current recipe directory into the current
build directory.
.. versionchanged:: 0.6.0
Add ability to apply patch from any dir via kwarg `build_dir`''' | def apply_patch(self, filename, arch, build_dir=None):
"""
Apply a patch from the current recipe directory into the current
build directory.
.. versionchanged:: 0.6.0
Add ability to apply patch from any dir via kwarg `build_dir`'''
"""
info("Applying patch {}... |
Return archs of self.ctx that are valid build archs
for the Recipe. | def filtered_archs(self):
'''Return archs of self.ctx that are valid build archs
for the Recipe.'''
result = []
for arch in self.ctx.archs:
if not self.archs or (arch.arch in self.archs):
result.append(arch)
return result |
Checks what recipes are being built to see which of the alternative
and optional dependencies are being used,
and returns a list of these. | def check_recipe_choices(self):
'''Checks what recipes are being built to see which of the alternative
and optional dependencies are being used,
and returns a list of these.'''
recipes = []
built_recipes = self.ctx.recipe_build_order
for recipe in self.depends:
... |
Given the arch name, returns the directory where it will be
built.
This returns a different directory depending on what
alternative or optional dependencies are being built. | def get_build_container_dir(self, arch):
'''Given the arch name, returns the directory where it will be
built.
This returns a different directory depending on what
alternative or optional dependencies are being built.
'''
dir_name = self.get_dir_name()
return joi... |
Returns the local recipe directory or defaults to the core recipe
directory. | def get_recipe_dir(self):
"""
Returns the local recipe directory or defaults to the core recipe
directory.
"""
if self.ctx.local_recipes is not None:
local_recipe_dir = join(self.ctx.local_recipes, self.name)
if exists(local_recipe_dir):
re... |
Return the env specialized for the recipe | def get_recipe_env(self, arch=None, with_flags_in_cc=True, clang=False):
"""Return the env specialized for the recipe
"""
if arch is None:
arch = self.filtered_archs[0]
return arch.get_env(with_flags_in_cc=with_flags_in_cc, clang=clang) |
Run any pre-build tasks for the Recipe. By default, this checks if
any prebuild_archname methods exist for the archname of the current
architecture, and runs them if so. | def prebuild_arch(self, arch):
'''Run any pre-build tasks for the Recipe. By default, this checks if
any prebuild_archname methods exist for the archname of the current
architecture, and runs them if so.'''
prebuild = "prebuild_{}".format(arch.arch.replace('-', '_'))
if hasattr(s... |
Apply any patches for the Recipe.
.. versionchanged:: 0.6.0
Add ability to apply patches from any dir via kwarg `build_dir` | def apply_patches(self, arch, build_dir=None):
'''Apply any patches for the Recipe.
.. versionchanged:: 0.6.0
Add ability to apply patches from any dir via kwarg `build_dir`'''
if self.patches:
info_main('Applying patches for {}[{}]'
.format(self.na... |
Run any build tasks for the Recipe. By default, this checks if
any build_archname methods exist for the archname of the current
architecture, and runs them if so. | def build_arch(self, arch):
'''Run any build tasks for the Recipe. By default, this checks if
any build_archname methods exist for the archname of the current
architecture, and runs them if so.'''
build = "build_{}".format(arch.arch)
if hasattr(self, build):
getattr(s... |
Run any post-build tasks for the Recipe. By default, this checks if
any postbuild_archname methods exist for the archname of the
current architecture, and runs them if so. | def postbuild_arch(self, arch):
'''Run any post-build tasks for the Recipe. By default, this checks if
any postbuild_archname methods exist for the archname of the
current architecture, and runs them if so.
'''
postbuild = "postbuild_{}".format(arch.arch)
if hasattr(self,... |
Deletes all the build information of the recipe.
If arch is not None, only this arch dir is deleted. Otherwise
(the default) all builds for all archs are deleted.
By default, this just deletes the main build dir. If the
recipe has e.g. object files biglinked, or .so files stored
... | def clean_build(self, arch=None):
'''Deletes all the build information of the recipe.
If arch is not None, only this arch dir is deleted. Otherwise
(the default) all builds for all archs are deleted.
By default, this just deletes the main build dir. If the
recipe has e.g. objec... |
Returns the Recipe with the given name, if it exists. | def get_recipe(cls, name, ctx):
'''Returns the Recipe with the given name, if it exists.'''
name = name.lower()
if not hasattr(cls, "recipes"):
cls.recipes = {}
if name in cls.recipes:
return cls.recipes[name]
recipe_file = None
for recipes_dir in... |
The name of the build folders containing this recipe. | def folder_name(self):
'''The name of the build folders containing this recipe.'''
name = self.site_packages_name
if name is None:
name = self.name
return name |
Install the Python module by calling setup.py install with
the target Python dir. | def build_arch(self, arch):
'''Install the Python module by calling setup.py install with
the target Python dir.'''
super(PythonRecipe, self).build_arch(arch)
self.install_python_package(arch) |
Automate the installation of a Python package (or a cython
package where the cython components are pre-built). | 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... |
Build any cython components, then install the Python module by
calling setup.py install with the target Python dir. | def build_arch(self, arch):
'''Build any cython components, then install the Python module by
calling setup.py install with the target Python dir.
'''
Recipe.build_arch(self, arch)
self.build_compiled_components(arch)
self.install_python_package(arch) |
Build any cython components, then install the Python module by
calling setup.py install with the target Python dir. | def build_arch(self, arch):
'''Build any cython components, then install the Python module by
calling setup.py install with the target Python dir.
'''
Recipe.build_arch(self, arch)
self.build_cython_components(arch)
self.install_python_package(arch) |
Recursively renames all files named XXX.cpython-...-linux-gnu.so"
to "XXX.so", i.e. removing the erroneous architecture name
coming from the local system. | def reduce_object_file_names(self, dirn):
"""Recursively renames all files named XXX.cpython-...-linux-gnu.so"
to "XXX.so", i.e. removing the erroneous architecture name
coming from the local system.
"""
py_so_files = shprint(sh.find, dirn, '-iname', '*.so')
filens = py_s... |
Decorator to create automatically a :class:`Runnable` object with the
function. The function will be delayed and call into the Activity thread. | def run_on_ui_thread(f):
'''Decorator to create automatically a :class:`Runnable` object with the
function. The function will be delayed and call into the Activity thread.
'''
def f2(*args, **kwargs):
Runnable(f)(*args, **kwargs)
return f2 |
Gets the channel with the given number. | def Channel(n):
"""
Gets the channel with the given number.
"""
rv = channels.get(n, None)
if rv is None:
rv = ChannelImpl(n)
channels[n] = rv
return rv |
Generate the python source for a node tree. | def generate(node, environment, name, filename, stream=None,
defer_init=False):
"""Generate the python source for a node tree."""
if not isinstance(node, nodes.Template):
raise TypeError('Can\'t compile non template nodes')
generator = CodeGenerator(environment, name, filename, stream, ... |
Register a special name like `loop`. | def add_special(self, name):
"""Register a special name like `loop`."""
self.undeclared.discard(name)
self.declared.add(name) |
Check if a name is declared in this or an outer scope. | def is_declared(self, name, local_only=False):
"""Check if a name is declared in this or an outer scope."""
if name in self.declared_locally or name in self.declared_parameter:
return True
if local_only:
return False
return name in self.declared |
Create a copy of the current one. | def copy(self):
"""Create a copy of the current one."""
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.identifiers = object.__new__(self.identifiers.__class__)
rv.identifiers.__dict__.update(self.identifiers.__dict__)
return rv |
Find all the shadowed names. extra is an iterable of variables
that may be defined with `add_special` which may occour scoped. | def find_shadowed(self, extra=()):
"""Find all the shadowed names. extra is an iterable of variables
that may be defined with `add_special` which may occour scoped.
"""
i = self.identifiers
return (i.declared | i.outer_undeclared) & \
(i.declared_locally | i.decla... |
Visit a list of nodes as block in a frame. If the current frame
is no buffer a dummy ``if 0: yield None`` is written automatically
unless the force_generator parameter is set to False. | def blockvisit(self, nodes, frame):
"""Visit a list of nodes as block in a frame. If the current frame
is no buffer a dummy ``if 0: yield None`` is written automatically
unless the force_generator parameter is set to False.
"""
if frame.buffer is None:
self.writeline... |
Pull all the references identifiers into the local scope. | def pull_locals(self, frame):
"""Pull all the references identifiers into the local scope."""
for name in frame.identifiers.undeclared:
self.writeline('l_%s = context.resolve(%r)' % (name, name)) |
Disable Python optimizations for the frame. | def unoptimize_scope(self, frame):
"""Disable Python optimizations for the frame."""
# XXX: this is not that nice but it has no real overhead. It
# mainly works because python finds the locals before dead code
# is removed. If that breaks we have to add a dummy function
# that ... |
This function returns all the shadowed variables in a dict
in the form name: alias and will write the required assignments
into the current scope. No indentation takes place.
This also predefines locally declared variables from the loop
body because under some circumstances it may be t... | def push_scope(self, frame, extra_vars=()):
"""This function returns all the shadowed variables in a dict
in the form name: alias and will write the required assignments
into the current scope. No indentation takes place.
This also predefines locally declared variables from the loop
... |
Restore all aliases and delete unused variables. | def pop_scope(self, aliases, frame):
"""Restore all aliases and delete unused variables."""
for name, alias in aliases.iteritems():
self.writeline('l_%s = %s' % (name, alias))
to_delete = set()
for name in frame.identifiers.declared_locally:
if name not in aliases... |
In Jinja a few statements require the help of anonymous
functions. Those are currently macros and call blocks and in
the future also recursive loops. As there is currently
technical limitation that doesn't allow reading and writing a
variable in a scope where the initial value is comin... | def function_scoping(self, node, frame, children=None,
find_special=True):
"""In Jinja a few statements require the help of anonymous
functions. Those are currently macros and call blocks and in
the future also recursive loops. As there is currently
technical l... |
Dump the function def of a macro or call block. | def macro_body(self, node, frame, children=None):
"""Dump the function def of a macro or call block."""
frame = self.function_scoping(node, frame, children)
# macros are delayed, they never require output checks
frame.require_output_check = False
args = frame.arguments
# ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.