@@ -123,10 +123,11 @@ This is the core of what's necessary to write a recipe, but has not
123123covered any of the details of how one actually writes code to compile
124124for android. This is covered in the next sections, including the
125125`standard mechanisms <standard_mechanisms _>`_ used as part of the
126- build, and the details of specific recipe classes for Python, Cython,
127- and some generic compiled recipes. If your module is one of the
128- latter, you should use these later classes rather than reimplementing
129- the functionality from scratch.
126+ build, and the details of specific recipe classes for modern Python
127+ packages, older setup.py-based packages, Cython, and some generic
128+ compiled recipes. If your module is one of the latter, you should use
129+ these later classes rather than reimplementing the functionality from
130+ scratch.
130131
131132.. _standard_mechanisms :
132133
@@ -310,6 +311,10 @@ For reference, the code that accomplishes this is the following::
310311This combines techniques and tools from the above documentation to
311312create a generic mechanism for all Python modules.
312313
314+ For Python packages that use ``pyproject.toml ``, you should normally use
315+ ``PyProjectRecipe `` instead. ``PythonRecipe `` is based on the older
316+ ``setup.py install `` flow.
317+
313318.. note :: The hostpython is the path to the Python binary that should
314319 be used for any kind of installation. You *must * run Python
315320 in a similar way if you need to do so in any of your own
@@ -380,6 +385,40 @@ patching to remove this import or make it fail quietly.
380385Other than this, these methods follow the techniques in the above
381386documentation to make a generic recipe for most cython based modules.
382387
388+ Using a PyProjectRecipe
389+ -----------------------
390+
391+ For modern Python packages that contain ``pyproject.toml ``, you should
392+ normally use ``PyProjectRecipe ``. It builds and installs packages as
393+ wheels, which matches current Python packaging tools more closely than
394+ the older ``setup.py install `` flow.
395+
396+ For instance::
397+
398+ from pythonforandroid.recipe import PyProjectRecipe
399+
400+ class ExampleRecipe(PyProjectRecipe):
401+ version = '1.2.3'
402+ url = 'https://example.com/example-{version}.tar.gz'
403+ depends = ['python3']
404+
405+ recipe = ExampleRecipe()
406+
407+ The base class uses a wheel-oriented build and install flow. It can use
408+ a compatible prebuilt Android wheel when that path is enabled and a
409+ matching wheel is available. Otherwise, it installs the host build
410+ requirements, runs ``python -m build --wheel ``, applies Android platform
411+ tags to the built wheel, optionally copies the wheel to configured
412+ wheel-save directories, and installs the selected wheel into the target
413+ Python install directory.
414+
415+ You may still need to add normal recipe metadata such as ``depends `` for
416+ libraries or Python packages that must be built first. Packages with
417+ extra host-side build requirements can add ``hostpython_prerequisites ``.
418+ Packages that need Android-specific changes may still need patches or a
419+ ``get_recipe_env() `` override to adjust compiler flags, include paths, or
420+ other build environment variables.
421+
383422Using a CompiledComponentsPythonRecipe
384423--------------------------------------
385424
@@ -506,6 +545,3 @@ how to create your own Recipe subclass.
506545.. autoclass :: toolchain.Recipe
507546 :members:
508547 :member-order: bysource
509-
510-
511-
0 commit comments