Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for working in WSL #740

Merged
merged 1 commit into from
Nov 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
if sys.platform == 'win32':
raise NotImplementedError('Windows platform not yet working for Android')

from platform import uname
WSL = 'Microsoft' in uname()[2]

ANDROID_API = '19'
ANDROID_MINAPI = '9'
ANDROID_SDK_VERSION = '20'
Expand All @@ -22,6 +25,7 @@
import io
import re
import ast
import sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we may want to add the sh dependency to the setup.py requirement

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed!

from pipes import quote
from sys import platform, executable
from buildozer import BuildozerException
Expand Down Expand Up @@ -410,7 +414,36 @@ def _install_android_packages(self):
'android.skip_update', False)
if 'tools' in packages or 'platform-tools' in packages:
if not skip_upd:
if WSL:
# WSL (Windows Subsystem for Linux) allows running
# linux from windows 10, but some windows
# limitations still apply, namely you can't rename a
# directory that a program was started from, which
# is what the tools updates cause, and we end up
# with an empty dir, so we need to run from a
# different place, and the updater is still looking
# for things in tools, and specifically renames the
# tool dir, hence, moving and making a symlink
# works.
sh.mv(
join(self.android_sdk_dir, 'tools'),
join(self.android_sdk_dir, 'tools.save')
)
sh.ln(
'-s',
join(self.android_sdk_dir, 'tools.save'),
join(self.android_sdk_dir, 'tools')
)
old_android_cmd = self.android_cmd
self.android_cmd = join(
self.android_sdk_dir,
'tools.save',
self.android_cmd.split('/')[-1]
)
self._android_update_sdk('tools,platform-tools')
self.android_cmd = old_android_cmd
if WSL:
sh.rm('-rf', join(self.android_sdk_dir, 'tools.save'))
else:
self.buildozer.info('Skipping Android SDK update due to spec file setting')

Expand Down