|
| 1 | + |
| 2 | +distutils/setuptools integration |
| 3 | +===============
8000
================= |
| 4 | + |
| 5 | +Instead of running p4a via the command line, you can integrate with |
| 6 | +distutils and setup.py. |
| 7 | + |
| 8 | +The base command is:: |
| 9 | + |
| 10 | + python setup.py apk |
| 11 | + |
| 12 | +The files included in the APK will be all those specified in the |
| 13 | +``package_data`` argument to setup. For instance, the following |
| 14 | +example will include all .py and .png files in the ``testapp`` |
| 15 | +folder:: |
| 16 | + |
| 17 | + from distutils.core import setup |
| 18 | + from setup |
| 19 | + |
| 20 | + setup( |
| 21 | + name='testapp_setup', |
| 22 | + version='1.1', |
| 23 | + description='p4a setup.py example', |
| 24 | + author='Your Name', |
| 25 | + author_email='youremail@address.com', |
| 26 | + packages=find_packages(), |
| 27 | + options=options, |
| 28 | + package_data={'testapp': ['*.py', '*.png']} |
| 29 | + ) |
| 30 | + |
| 31 | +The app name and version will also be read automatically from the |
| 32 | +setup.py. |
| 33 | + |
| 34 | +The Android package name uses ``org.test.lowercaseappname`` |
| 35 | +if not set explicitly. |
| 36 | + |
| 37 | +The ``--private`` argument is set automatically using the |
| 38 | +package_data, you should *not* set this manually. |
| 39 | + |
| 40 | +The target architecture defaults to ``--armeabi``. |
| 41 | + |
| 42 | +All of these automatic arguments can be overridden by passing them manually on the command line, e.g.:: |
| 43 | + |
| 44 | + python setup.py apk --name="Testapp Setup" --version=2.5 |
| 45 | + |
| 46 | +Adding p4a arguments in setup.py |
| 47 | +-------------------------------- |
| 48 | + |
| 49 | +Instead of providing extra arguments on the command line, you can |
| 50 | +store them in setup.py by passing the ``options`` parameter to |
| 51 | +:code:`setup`. For instance:: |
| 52 | + |
| 53 | + from distutils.core import setup |
| 54 | + from setuptools import find_packages |
| 55 | + |
| 56 | + options = {'apk': {'debug': None, # use None for arguments that don't pass a value |
| 57 | + 'requirements': 'sdl2,pyjnius,kivy,python2', |
| 58 | + 'android-api': 19, |
| 59 | + 'ndk-dir': '/path/to/ndk', |
| 60 | + 'dist-name': 'bdisttest', |
| 61 | + }} |
| 62 | + |
| 63 | + packages = find_packages() |
| 64 | + print('packages are', packages) |
| 65 | + |
| 66 | + setup( |
| 67 | + name='testapp_setup', |
| 68 | + version='1.1', |
| 69 | + description='p4a setup.py example', |
| 70 | + author='Your Name', |
| 71 | + author_email='youremail@address.com', |
| 72 | + packages=find_packages(), |
| 73 | + options=options, |
| 74 | + package_data={'testapp': ['*.py', '*.png']} |
| 75 | + ) |
| 76 | + |
| 77 | +These options will be automatically included when you run ``python |
| 78 | +setup.py apk``. Any options passed on the command line will override |
| 79 | +these values. |
0 commit comments