@@ -15,16 +15,20 @@ def argv_contains(t):
15
15
return False
16
16
17
17
18
- class BdistAPK (Command ):
18
+ class Bdist (Command ):
19
19
description = 'Create an APK with python-for-android'
20
20
21
21
user_options = []
22
22
23
+ @property
24
+ def package_type (self ):
25
+ raise NotImplemented ("Subclass must define package_type" )
26
+
23
27
def initialize_options (self ):
24
28
for option in self .user_options :
25
29
setattr (self , option [0 ].strip ('=' ).replace ('-' , '_' ), None )
26
30
27
- option_dict = self .distribution .get_option_dict ('apk' )
31
+ option_dict = self .distribution .get_option_dict (self . package_type )
28
32
29
33
# This is a hack, we probably aren't supposed to loop through
30
34
# the option_dict so early because distutils does exactly the
@@ -35,7 +39,7 @@ def initialize_options(self):
35
39
36
40
def finalize_options (self ):
37
41
38
- setup_options = self .distribution .get_option_dict ('apk' )
42
+ setup_options = self .distribution .get_option_dict (self . package_type )
39
43
for (option , (source , value )) in setup_options .items ():
40
44
if source == 'command line' :
41
45
continue
@@ -76,7 +80,7 @@ def run(self):
76
80
self .prepare_build_dir ()
77
81
78
82
from pythonforandroid .entrypoints import main
79
- sys .argv [1 ] = 'apk'
83
+ sys .argv [1 ] = self . package_type
80
84
main ()
81
85
82
86
def prepare_build_dir (self ):
@@ -128,6 +132,20 @@ def prepare_build_dir(self):
128
132
)
129
133
130
134
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
+
131
149
def _set_user_options ():
132
150
# This seems like a silly way to do things, but not sure if there's a
133
151
# better way to pass arbitrary options onwards to p4a
0 commit comments