8000 Uv python manager by skyf0l · Pull Request #469 · ThePorgs/Exegol-images · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Uv python manager #469

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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

Conversation

skyf0l 8000
Copy link
Contributor
@skyf0l skyf0l commented Mar 13, 2025

Initially I wanted to completely replace pyenv with uv, but I'm going to take things one step at a time.

https://astral.sh/blog/uv
TL;DR: uv is an extremely fast Python package installer and resolver, written in Rust, and designed as a drop-in replacement for pip and pip-tools workflows.

I found that uv tool install does not shallow git repos (e.g. with --depth=1). In short, all git history is cloned, which is fairly negligible in general, but it was problematic for MobSF, given its heavy history.

It's OK to clone all the history with uv because only the sources are kept (the history is deleted post-install). Only the install takes a little longer, but given the benchmark below, it's negligible (except for MobSF, of course, which is why I shallow clone the repo first). I'll suggest this improvement to uv.

Plus, here, uv doesn't benefit at all from its cache (between several uv tool install).

The install_uv step took only 6s and 44MiB of disk + ~20MiB by python version if not found on system/pyenv.

Faster and lighter (metrics are generated using #451):

Package with pip with uv
cloudmapper 780s, 779MiB 31s, 502MiB
MobSF 83s , 961MiB 52s, 597MiB (without prior shallow clone: 109s)
ldeep 87s, 87MiB 74s, 69MiB
divideandscan 36s, 449MiB 8s, 411MiB

@skyf0l skyf0l mentioned this pull request Mar 15, 2025
8 tasks
# yara-python-dex is be needed for ARM64
uv tool install /tmp/MobSF --with setuptools \
--with git+https://github.com/MobSF/yara-python-dex.git \
--with xmlsec==1.3.14
Copy link
Contributor

Choose a reason for hiding this comment

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

Add $(uv tool dir)/mobsf/bin/python $(uv tool dir)/mobsf/lib/python3.11/site-packages/mobsf/MobSF/tools_download.py /root/.MobSF so the built-in jadx is downloaded for offline use.

fi
add-history mobsf
add-test-command "/opt/tools/MobSF/venv/bin/python -c 'from mobsf.MobSF.settings import VERSION; print(VERSION)'"
add-test-command "$(uv tool dir)/mobsf/bin/python -c 'from mobsf.MobSF.settings import VERSION; print(VERSION)'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Use $(uv 8000 tool dir)/mobsf/bin/python -c 'from mobsf.MobSF.init import VERSION; print(VERSION)' so first-run is not triggered (see #505).

@compass-dexter
Copy link
Contributor

If we don't care about /root/.MobSF/secret being generated during build time (I'm not sure what it is for), we can also just run $(uv tool dir)/mobsf/bin/python $(uv tool dir)/mobsf/lib/python3.11/site-packages/mobsf/MobSF/settings.py during installation to populate the /root/.MobSF directory. This also downloads the expected version of JADX there.

@compass-dexter
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0