Skip to content

Commit 1e3d533

Browse files
broccoliboysam-ti
andauthored
Android sdkmanager proxy config (#1899)
* pass proxy config from env to sdkmanager to allow updating android sdk on corporate networks * look in both http and https env vars for proxy settings to pass through to sdkmanager * fix tox errors * remove if statement since try/except will handle proxy=None case * consolidate --------- Co-authored-by: Sam Martin <martins@ti.com>
1 parent da7dde3 commit 1e3d533

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

buildozer/targets/android.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ def _sdkmanager(self, *args, **kwargs):
200200
kwargs['cwd'] = kwargs.get('cwd', android_sdk_dir)
201201
command = [self.sdkmanager_path, f"--sdk_root={android_sdk_dir}", *args]
202202

203+
# Attempt to pass proxy settings to sdkmanager command using the --proxy, --proxy_host,
204+
# and --proxy_port arguments by checking common environment variables for proxy settings.
205+
# Sdkmanager only supports proxy types `http` and `socks`, so even if proxy url is https,
206+
# only pass host and port with `http` type.
207+
for key in ['HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'https_proxy']:
208+
try:
209+
host, port = os.environ.get(key).split(':')[-2:]
210+
command.extend(['--proxy=http', f'--proxy_host={host.strip("/")}', f'--proxy_port={port}'])
211+
break
212+
except:
213+
pass
214+
203215
if kwargs.pop('return_child', False):
204216
return buildops.cmd_expect(
205217
command, env=self.buildozer.environ, **kwargs)

0 commit comments

Comments
 (0)