Skip to content

Commit 4709476

Browse files
committed
Made sure whole build process accesses dist_dir correctly
1 parent 5f99bcd commit 4709476

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

pythonforandroid/bootstrap.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import shlex
99
import shutil
1010

11-
from pythonforandroid.logger import (warning, shprint, info, logger,
12-
debug)
13-
from pythonforandroid.util import (current_directory, ensure_dir,
14-
temp_directory)
11+
from pythonforandroid.logger import (shprint, info, logger, debug)
12+
from pythonforandroid.util import (
13+
current_directory, ensure_dir, temp_directory, BuildInterruptingException)
1514
from pythonforandroid.recipe import Recipe
1615

1716

@@ -75,7 +74,6 @@ class Bootstrap(object):
7574
bootstrap_dir = None
7675

7776
build_dir = None
78-
dist_dir = None
7977
dist_name = None
8078
distribution = None
8179

@@ -97,9 +95,9 @@ class Bootstrap(object):
9795
def dist_dir(self):
9896
'''The dist dir at which to place the finished distribution.'''
9997
if self.distribution is None:
100-
warning('Tried to access {}.dist_dir, but {}.distribution '
101-
'is None'.format(self, self))
102-
exit(1)
98+
raise BuildInterruptingException(
99+
'Tried to access {}.dist_dir, but {}.distribution '
100+
'is None'.format(self, self))
103101
return self.distribution.dist_dir
104102

105103
@property
@@ -158,7 +156,7 @@ def prepare_build_dir(self):
158156
with open('project.properties', 'w') as fileh:
159157
fileh.write('target=android-{}'.format(self.ctx.android_api))
160158

161-
def prepare_dist_dir(self, name):
159+
def prepare_dist_dir(self):
162160
ensure_dir(self.dist_dir)
163161

164162
def run_distribute(self):

pythonforandroid/build.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ class Context(object):
9292
# in which bootstraps are copied for building
9393
# and recipes are built
9494
build_dir = None
95+
96+
distribution = None
97+
"""The Distribution object representing the current build target location."""
98+
9599
# the Android project folder where everything ends up
96100
dist_dir = None
101+
97102
# where Android libs are cached after build
98103
# but before being placed in dists
99104
libs_dir = None
@@ -106,7 +111,6 @@ class Context(object):
106111

107112
ndk_platform = None # the ndk platform directory
108113

109-
dist_name = None # should be deprecated in favour of self.dist.dist_name
110114
bootstrap = None
111115
bootstrap_build_dir = None
112116

@@ -485,9 +489,8 @@ def prepare_bootstrap(self, bs):
485489
self.bootstrap.prepare_build_dir()
486490
self.bootstrap_build_dir = self.bootstrap.build_dir
487491

488-
def prepare_dist(self, name):
489-
self.dist_name = name
490-
self.bootstrap.prepare_dist_dir(self.dist_name)
492+
def prepare_dist(self):
493+
self.bootstrap.prepare_dist_dir()
491494

492495
def get_site_packages_dir(self, arch=None):
493496
'''Returns the location of site-packages in the python-install build

pythonforandroid/distribution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def save_info(self, dirn):
242242
with current_directory(dirn):
243243
info('Saving distribution info')
244244
with open('dist_info.json', 'w') as fileh:
245-
json.dump({'dist_name': self.ctx.dist_name,
245+
json.dump({'dist_name': self.name,
246246
'bootstrap': self.ctx.bootstrap.name,
247247
'archs': [arch.arch for arch in self.ctx.archs],
248248
'ndk_api': self.ctx.ndk_api,

pythonforandroid/python.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,11 @@ def create_python_bundle(self, dirn, arch):
341341
python_lib_name = 'libpython' + self.major_minor_version_string
342342
if self.major_minor_version_string[0] == '3':
343343
python_lib_name += 'm'
344-
shprint(sh.cp, join(python_build_dir, python_lib_name + '.so'),
345-
join(self.ctx.dist_dir, self.ctx.dist_name, 'libs', arch.arch))
344+
shprint(
345+
sh.cp,
346+
join(python_build_dir, python_lib_name + '.so'),
347+
join(self.ctx.bootstrap.dist_dir, 'libs', arch.arch)
348+
)
346349

347350
info('Renaming .so files to reflect cross-compile')
348351
self.reduce_object_file_names(join(dirn, 'site-packages'))

pythonforandroid/toolchain.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ def build_dist_from_args(ctx, dist, args):
196196
info('Dist will also contain modules ({}) installed from pip'.format(
197197
', '.join(ctx.python_modules)))
198198

199-
ctx.dist_name = bs.distribution.name
199+
ctx.distribution = dist
200200
ctx.prepare_bootstrap(bs)
201201
if dist.needs_build:
202-
ctx.prepare_dist(ctx.dist_name)
202+
ctx.prepare_dist()
203203

204204
build_recipes(build_order, python_modules, ctx,
205205
getattr(args, "private", None),
@@ -212,7 +212,7 @@ def build_dist_from_args(ctx, dist, args):
212212

213213
info_main('# Your distribution was created successfully, exiting.')
214214
info('Dist can be found at (for now) {}'
215-
.format(join(ctx.dist_dir, ctx.dist_name)))
215+
.format(join(ctx.dist_dir, ctx.distribution.dist_dir)))
216216

217217

218218
def split_argument_list(l):
@@ -913,6 +913,7 @@ def export_dist(self, args):
913913
def _dist(self):
914914
ctx = self.ctx
915915
dist = dist_from_args(ctx, self.args)
916+
ctx.distribution = dist
916917
return dist
917918

918919
@require_prebuilt_dist

0 commit comments

Comments
 (0)