8000 Added doc page about setup.py integration · suriyan/python-for-android@a4dc8d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4dc8d4

Browse files
committed
Added doc page about setup.py integration
1 parent bf1919d commit a4dc8d4

File tree

4 files changed

+83
-8
lines changed

4 files changed

+83
-8
lines changed

doc/source/distutils.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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.

doc/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Contents
2929
quickstart
3030
buildoptions
3131
commands
32+
distutils
3233
recipes
3334
bootstraps
3435
services

pythonforandroid/bdist_apk.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ def finalize_options(self):
7171
self.arch = arch
7272
sys.argv.append('--arch={}'.format(arch))
7373

74-
75-
76-
7774
def run(self):
7875

7976
self.prepare_build_dir()
@@ -140,5 +137,5 @@ def _set_user_options():
140137
user_options.append((arg[2:], None, None))
141138

142139
BdistAPK.user_options = user_options
143-
140+
144141
_set_user_options()

testapps/testapp_setup/setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
from pythonforandroid.bdist_apk import register_args
2+
from distutils.core import setup
3+
from setuptools import find_packages
34

45
options = {'apk': {'debug': None,
56
'requirements': 'sdl2,pyjnius,kivy,python2',
@@ -9,9 +10,6 @@
910
'ndk-version': '10.3.1',
1011
}}
1112

12-
from setuptools import setup, find_packages
13-
from distutils.extension import Extension
14-
1513
package_data = {'': ['*.py',
1614
'*.png']
1715
}

0 commit comments

Comments
 (0)
0