Skip to content

Commit dfc8ab3

Browse files
committed
Fixed relative path references for user code dir
1 parent c99a5fa commit dfc8ab3

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pythonforandroid/toolchain.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
import sh
4141
from colorama import Style, Fore
4242

43-
curdir = dirname(__file__)
44-
sys.path.insert(0, join(curdir, "tools", "external"))
43+
user_dir = dirname(realpath(os.path.curdir))
44+
toolchain_dir = dirname(__file__)
45+
sys.path.insert(0, join(toolchain_dir, "tools", "external"))
4546

4647

4748
DEFAULT_ANDROID_API = 15
@@ -2401,6 +2402,7 @@ class ToolchainCL(object):
24012402
def __init__(self):
24022403
self._ctx = None
24032404

2405+
24042406
parser = argparse.ArgumentParser(
24052407
description="Tool for managing the Android / Python toolchain",
24062408
usage="""toolchain <command> [<args>]
@@ -2716,21 +2718,22 @@ def apk(self, args):
27162718

27172719
ctx = self.ctx
27182720
dist = self._dist
2719-
# dist = dist_from_args(ctx, self.dist_args)
2720-
# if dist.needs_build:
2721-
# info('No dist exists that meets your requirements, so one will '
2722-
# 'be built.')
2723-
# args = build_dist_from_args(ctx, dist, args)
2721+
2722+
# Manually fixing these arguments at the string stage is
2723+
# unsatisfactory and should probably be changed somehow, but
2724+
# we can't leave it until later as the build.py scripts assume
2725+
# they are in the current directory.
2726+
for i, arg in enumerate(args[:-1]):
2727+
if arg in ('--dir', '--private'):
2728+
args[i+1] = realpath(expanduser(args[i+1]))
27242729

27252730
build = imp.load_source('build', join(dist.dist_dir, 'build.py'))
27262731
with current_directory(dist.dist_dir):
27272732
build.parse_args(args)
2728-
27292733
shprint(sh.ant, 'debug')
27302734

27312735
# AND: This is very crude, needs improving. Also only works
27322736
# for debug for now.
2733-
27342737
info_main('# Copying APK to current directory')
27352738
apks = glob.glob(join(dist.dist_dir, 'bin', '*-*-debug.apk'))
27362739
if len(apks) == 0:

0 commit comments

Comments
 (0)