zappa / Zappa

Serverless Python
https://zappa.ws/zappa
MIT License
3.35k stars 362 forks source link

Use UV to install packages much faster #1350

Open tugoavenza opened 2 months ago

tugoavenza commented 2 months ago

Use UV - An extremely fast Python package and project manager, written in Rust to speed up the installation of dependencies https://github.com/astral-sh/uv

Context

Zappa creates a virtual env with all the dependencies for the app for Lambda handler, and zips it. UV is 10-100x faster than pip. We could see a great speed boost.

sridhar562345 commented 2 months ago

Use UV - An extremely fast Python package and project manager, written in Rust to speed up the installation of dependencies https://github.com/astral-sh/uv

Context

Zappa creates a virtual env with all the dependencies for the app for Lambda handler, and zips it. UV is 10-100x faster than pip. We could see a great speed boost.

Zappa doesn't install the packages in virtual env itself, it zips the already installed packages in virtual env. So, I don't see UV has anything to do with Zappa.

So you can use UV to install packages in your virtual env instead of pip.

audioboxer217 commented 1 month ago

I can confirm this. I use uv instead of pip now and it works fine.

Steps

  1. uv init
    • or setup your 'pyproject.toml' and '.python-version' manually
  2. uv add zappa
    • then repeat uv add for any other dependencies
    • add --dev for Dev-only dependencies
  3. uv run zappa ... for any zappa commands
    • you could also do source .venv/bin/activate as uv sets up the venv, but it's not really the way uv was intended to run.