Skip to content

Commit c5a5ef5

Browse files
authored
Use uv to install androguard if possible (#463)
1 parent 7385417 commit c5a5ef5

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Version 0.57.9
44
**Bugfixes**
55
- Fix empty release notes text usage for Google Play release tracks. [PR #462](https://github.com/codemagic-ci-cd/cli-tools/pull/462)
66

7+
**Improvements**
8+
- Speed up Androguard installation with `codemagic-cli-tools ensure-androgurad` on hosts where `uv` is present. [PR #463](https://github.com/codemagic-ci-cd/cli-tools/pull/463)s
9+
710
Version 0.57.8
811
-------------
912

src/codemagic/tools/codemagic_cli_tools.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,22 @@ def installed_tools(self):
3232
self.echo(f"{executable} installed at {shutil.which(executable) or executable}")
3333

3434
def _install_androguard(self):
35-
commands = [
36-
[sys.executable, "-m", "ensurepip"],
37-
[sys.executable, "-m", "pip", "install", "androguard"],
38-
]
35+
# Try to install with uv if possible as it is a lot faster than standard pip interface.
36+
if uv := shutil.which("uv"):
37+
command = (uv, "pip", "install", "--python", sys.executable, "androguard")
38+
uv_process = self.execute(command, show_output=False)
39+
if uv_process.returncode == 0:
40+
return
41+
# Installation with uv failed, try again with regular pip.
42+
43+
# Just call ensurepip and ignore its returncode.
44+
# ensurepip module can be disabled on Linuxes when using system Python as pip is
45+
# managed by apt, deb etc. Exit code 1 doesn't necessarily mean that pip is not available.
46+
self.execute((sys.executable, "-m", "ensurepip"), show_output=False)
47+
3948
try:
40-
for command in commands:
41-
cli_process = self.execute(command, show_output=False)
42-
cli_process.raise_for_returncode()
49+
pip_process = self.execute((sys.executable, "-m", "pip", "install", "androguard"), show_output=False)
50+
pip_process.raise_for_returncode()
4351
except subprocess.CalledProcessError:
4452
self.logger.error(Colors.RED("ERROR: Installing Androguard failed."))
4553
raise

0 commit comments

Comments
 (0)