Commands

This page documents all the commands and options that can be passed to toolchain.py.

Commands index

The commands available are the methods of the ToolchainCL class, documented below. They may have options of their own, or you can always pass general arguments or distribution arguments to any command (though if irrelevant they may not have an effect).

class toolchain.ToolchainCL[source]
adb(args)[source]

Runs the adb binary from the detected SDK directory, passing all arguments straight to it. This is intended as a convenience function if adb is not in your $PATH.

apk(args)[source]

Create an APK using the given distribution.

bootstraps(args)[source]

List all the bootstraps available to build with.

clean_all(args)[source]

Delete all build components; the package cache, package builds, bootstrap builds and distributions.

clean_builds(args)[source]

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.

clean_dists(args)[source]

Delete all compiled distributions in the internal distribution directory.

clean_download_cache(args)[source]

Deletes any downloaded recipe packages.

This does not delete the build caches or final distributions.

clean_recipe_build(args)[source]

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 done unexpected state changes). If this happens, run clean_builds, or attempt to clean other recipes until things work again.

create(args)[source]

Create a distribution directory if it doesn’t already exist, run any recipes if necessary, and build the apk.

distributions(args)[source]

Lists all distributions currently available (i.e. that have already been built).

dists(args)[source]

The same as distributions().

export_dist(args)[source]

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.

logcat(args)[source]

Runs adb logcat using the adb binary from the detected SDK directory. All extra args are passed as arguments to logcat.

print_context_info(args)[source]

Prints some debug information about which system paths python-for-android will internally use for package building, along with information about where the Android SDK and NDK will be called from.

sdk_tools(args)[source]

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.

Symlinks 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.

General arguments

These arguments may be passed to any command in order to modify its behaviour, though not all commands make use of them.

--debug
Print extra debug information about the build, including all compilation output.
--sdk_dir
The filepath where the Android SDK is installed. This can alternatively be set in several other ways.
--android_api
The Android API level to target; python-for-android will check if the platform tools for this level are installed.
--ndk_dir
The filepath where the Android NDK is installed. This can alternatively be set in several other ways.
--ndk_version
The version of the NDK installed, important because the internal filepaths to build tools depend on this. This can alternatively be set in several other ways, or if your NDK dir contains a RELEASE.TXT containing the version this is automatically checked so you don’t need to manually set it.

Distribution arguments

p4a supports several arguments used for specifying which compiled Android distribution you want to use. You may pass any of these arguments to any command, and if a distribution is required they will be used to load, or compile, or download this as necessary.

None of these options are essential, and in principle you need only supply those that you need.

--name NAME
The name of the distribution. Only one distribution with a given name can be created.
--requirements LIST,OF,REQUIREMENTS
The recipes that your distribution must contain, as a comma separated list. These must be names of recipes or the pypi names of Python modules.
--force_build BOOL
Whether the distribution must be compiled from scratch.

Note

These options are preliminary. Others will include toggles for allowing downloads, and setting additional directories from which to load user dists.