serverless-python-requirements-uv
v1.2.0
Published
Generate requirements.txt with uv before packaging with serverless-python-requirements
Maintainers
Readme
Serverless Python Requirements uv
This plugin allows you to use uv in your Serverless Python projects. It automatically generates a requirements.txt file based on your uv.lock file.
Installation
To install the plugin, add it with your favorite package manager:
yarn add --dev serverless-python-requirements-uvThen put it in the plugins list above the serverless-python-requirements plugin in your serverless.yml:
plugins:
- serverless-python-requirements-uv
- serverless-python-requirementsYou might also want to consider adding requirements.txt to your .gitignore file,
as it will be generated automatically.
echo "/requirements.txt" >> .gitignoreUsage
Whenever your uv.lock file is changed more recently than your requirements.txt file,
the plugin will regenerate the requirements.txt file based on the contents of the uv.lock file.
To regenerate the requirements.txt file manually, you can run:
touch uv.lockThis will update the timestamp of the uv.lock file, causing the plugin to regenerate the requirements.txt file
the next time you deploy or package your service.
The plugin regenerates the file by running:
uv export --no-dev --no-emit-project --no-emit-workspace --output-file requirements.txt--no-dev leaves your development dependencies out of the deployment package. --no-emit-project omits your own
project from the output and --no-emit-workspace omits any sibling workspace members, since
serverless-python-requirements only needs to install third-party packages. These entries would
normally be exported when using uv workspaces and cause pip to refuse the requirements.txt due
to mixing dependencies with and without hashes.
Configuration
All options live under custom.pythonRequirements in your serverless.yml — the same block
serverless-python-requirements reads, so both plugins can be configured in one place.
| Option | Default | Description |
|----------|---------|-----------------------------------|
| uvPath | uv | Path to the uv binary to invoke |
Set uvPath when uv is not on your PATH, or when you need to pin a specific installation:
custom:
pythonRequirements:
uvPath: /opt/homebrew/bin/uv