Skip to content

Commit 2045eb1

Browse files
committed
aar entrypoint for setup.py
1 parent 48e7c1f commit 2045eb1

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

pythonforandroid/bdistapk.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ def argv_contains(t):
1515
return False
1616

1717

18-
class BdistAPK(Command):
18+
class Bdist(Command):
1919
description = 'Create an APK with python-for-android'
2020

2121
user_options = []
2222

23+
@property
24+
def package_type(self):
25+
raise NotImplemented("Subclass must define package_type")
26+
2327
def initialize_options(self):
2428
for option in self.user_options:
2529
setattr(self, option[0].strip('=').replace('-', '_'), None)
2630

27-
option_dict = self.distribution.get_option_dict('apk')
31+
option_dict = self.distribution.get_option_dict(self.package_type)
2832

2933
# This is a hack, we probably aren't supposed to loop through
3034
# the option_dict so early because distutils does exactly the
@@ -35,7 +39,7 @@ def initialize_options(self):
3539

3640
def finalize_options(self):
3741

38-
setup_options = self.distribution.get_option_dict('apk')
42+
setup_options = self.distribution.get_option_dict(self.package_type)
3943
for (option, (source, value)) in setup_options.items():
4044
if source == 'command line':
4145
continue
@@ -76,7 +80,7 @@ def run(self):
7680
self.prepare_build_dir()
7781

7882
from pythonforandroid.entrypoints import main
79-
sys.argv[1] = 'apk'
83+
sys.argv[1] = self.package_type
8084
main()
8185

8286
def prepare_build_dir(self):
@@ -128,6 +132,20 @@ def prepare_build_dir(self):
128132
)
129133

130134

135+
class BdistAPK(Bdist):
136+
""""""
137+
@property
138+
def package_type(self):
139+
return "apk"
140+
141+
142+
class BdistAAR(Bdist):
143+
""""""
144+
@property
145+
def package_type(self):
146+
return "aar"
147+
148+
131149
def _set_user_options():
132150
# This seems like a silly way to do things, but not sure if there's a
133151
# better way to pass arbitrary options onwards to p4a

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def recursively_include(results, directory, patterns):
100100
],
101101
'distutils.commands': [
102102
'apk = pythonforandroid.bdistapk:BdistAPK',
103+
'aar = pythonforandroid.bdistapk:BdistAAR',
103104
],
104105
},
105106
classifiers = [

0 commit comments

Comments
 (0)