Skip to content
Merged
Changes from 5 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
14 changes: 14 additions & 0 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@ def _sdkmanager(self, *args, **kwargs):
kwargs['cwd'] = kwargs.get('cwd', android_sdk_dir)
command = [self.sdkmanager_path, f"--sdk_root={android_sdk_dir}", *args]

# Attempt to pass proxy settings to sdkmanager command using the --proxy, --proxy_host,
# and --proxy_port arguments by checking common environment variables for proxy settings.
# Sdkmanager only supports proxy types `http` and `socks`, so even if proxy url is https,
# only pass host and port with `http` type.
for key in ['HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'https_proxy']:
proxy = os.environ.get(key)
try:
host, port = proxy.split(':')[-2:]
Copy link
Contributor

Choose a reason for hiding this comment

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

proxy = os.environ.get(key) could be set directly with host, port = proxy.split(':')[-2:] so it becomes host, port = os.environ.get(key).split(':')[-2:]

host = host.strip('/')
command.extend(['--proxy=http', f'--proxy_host={host}', f'--proxy_port={port}'])
break
except:
pass

if kwargs.pop('return_child', False):
return buildops.cmd_expect(
command, env=self.buildozer.environ, **kwargs)
Expand Down