-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: migrate Python dependency management from Poetry to uv #3025
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
Closed
+318
−23,018
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,49 +35,16 @@ jobs: | |
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow | ||
# from installing Poetry every time, which can be slow. Note the use of the Poetry version | ||
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache | ||
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be | ||
# mildly cleaner by using an environment variable, but I don't really care. | ||
- name: cache poetry install | ||
uses: actions/cache@v3 | ||
# Install uv for fast Python package management | ||
- name: Install uv | ||
uses: astral-sh/setup-uv@v4 | ||
with: | ||
path: ~/.local | ||
key: poetry-1.7.1 | ||
# Install Poetry. You could do this manually, or there are several actions that do this. | ||
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to | ||
# Poetry's default install script, which feels correct. I pin the Poetry version here | ||
# because Poetry does occasionally change APIs between versions and I don't want my | ||
# actions to break if it does. | ||
# | ||
# The key configuration value here is `virtualenvs-in-project: true`: this creates the | ||
# venv as a `.venv` in your testing directory, which allows the next step to easily | ||
# cache it. | ||
- uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.7.1 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache | ||
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include | ||
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock. | ||
- name: cache deps | ||
id: cache-deps | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: pydeps-${{ hashFiles('**/poetry.lock') }} | ||
# Install dependencies. `--no-root` means "install all dependencies but not the project | ||
# itself", which is what you want to avoid caching _your_ code. The `if` statement | ||
# ensures this only runs on a cache miss. | ||
- run: poetry install --no-interaction --no-root | ||
if: steps.cache-deps.outputs.cache-hit != 'true' | ||
# Now install _your_ project. This isn't necessary for many types of projects -- particularly | ||
# things like Django apps don't need this. But it's a good idea since it fully-exercises the | ||
# pyproject.toml and makes that if you add things like console-scripts at some point that | ||
# they'll be installed and working. | ||
- run: poetry install --no-interaction | ||
enable-cache: true | ||
# Create virtual environment and install dependencies | ||
- name: Create virtual environment and install dependencies | ||
run: | | ||
uv venv | ||
uv pip install -e .[dev] | ||
# Finally, run pre-commit. | ||
- name: Run all pre-commit hooks | ||
uses: pre-commit/[email protected] | ||
|
@@ -102,14 +69,18 @@ jobs: | |
AZURE_GPT4O_MINI_API_VERSION: "dummy" | ||
AWS_REGION: "us-east-1" | ||
ENABLE_BEDROCK: "true" | ||
run: poetry run ./run_alembic_check.sh | ||
run: | | ||
source .venv/bin/activate | ||
./run_alembic_check.sh | ||
- name: trigger tests | ||
env: | ||
ENABLE_OPENAI: "true" | ||
OPENAI_API_KEY: "sk-dummy" | ||
AWS_ACCESS_KEY_ID: "dummy" | ||
AWS_SECRET_ACCESS_KEY: "dummy" | ||
run: poetry run pytest | ||
run: | | ||
source .venv/bin/activate | ||
pytest | ||
fe-lint-build: | ||
name: Frontend Lint and Build | ||
runs-on: ubuntu-latest | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# Migration from Poetry to uv | ||
|
||
This document outlines the migration from Poetry to uv for dependency management in the Skyvern project. | ||
|
||
## What Changed | ||
|
||
### 1. Project Configuration | ||
- **pyproject.toml**: Updated from Poetry format to standard PEP 621 format with uv/hatchling | ||
- **Build system**: Switched from `poetry.core.masonry.api` to `hatchling.build` | ||
- **Dependencies**: Converted from Poetry's caret notation (`^1.0.0`) to standard version specifiers (`>=1.0.0`) | ||
|
||
### 2. CI/CD Workflows | ||
- **GitHub Actions**: Replaced `snok/install-poetry` with `astral-sh/setup-uv` | ||
- **Dependency installation**: Changed from `poetry install` to `uv pip install -e .[dev]` | ||
- **Build commands**: Updated from `poetry build` to `uv build` | ||
|
||
### 3. Docker | ||
- **Multi-stage build**: Updated to use uv for requirements export instead of Poetry | ||
- **Dependency installation**: Now uses `uv export` instead of `poetry export` | ||
|
||
### 4. Development Scripts | ||
- **run_skyvern.sh**: Updated to use uv for virtual environment management | ||
- **Virtual environment**: Now uses `.venv` directory created by uv | ||
|
||
## Benefits of uv | ||
|
||
1. **Speed**: uv is significantly faster than Poetry for dependency resolution and installation | ||
2. **Standards compliance**: Better adherence to Python packaging standards (PEP 621, PEP 517) | ||
3. **Simpler toolchain**: Reduced complexity with fewer moving parts | ||
4. **Better caching**: More efficient dependency caching in CI/CD | ||
|
||
## Developer Migration Guide | ||
|
||
### Prerequisites | ||
Install uv if you haven't already: | ||
```bash | ||
# macOS/Linux | ||
curl -LsSf https://astral.sh/uv/install.sh | sh | ||
|
||
# Windows | ||
powershell -c "irm https://astral.sh/uv/install.ps1 | iex" | ||
|
||
# pip | ||
pip install uv | ||
``` | ||
|
||
### Local Development Setup | ||
|
||
1. **Remove existing Poetry environment** (optional): | ||
```bash | ||
rm -rf .venv | ||
``` | ||
|
||
2. **Create new virtual environment with uv**: | ||
```bash | ||
uv venv | ||
``` | ||
|
||
3. **Install dependencies**: | ||
```bash | ||
# Install all dependencies including dev dependencies | ||
uv pip install -e .[dev] | ||
|
||
# Or just main dependencies | ||
uv pip install -e . | ||
``` | ||
|
||
4. **Activate virtual environment**: | ||
```bash | ||
source .venv/bin/activate # Linux/macOS | ||
# or | ||
.venv\\Scripts\\activate # Windows | ||
``` | ||
|
||
### Common Commands | ||
|
||
| Poetry Command | uv Equivalent | | ||
|----------------|---------------| | ||
| `poetry install` | `uv pip install -e .[dev]` | | ||
| `poetry add package` | `uv add package` | | ||
| `poetry remove package` | `uv remove package` | | ||
| `poetry build` | `uv build` | | ||
| `poetry run command` | `command` (after activating venv) | | ||
| `poetry shell` | `source .venv/bin/activate` | | ||
| `poetry export -f requirements.txt` | `uv export --format requirements-txt` | | ||
|
||
### Integration Packages | ||
|
||
The integration packages (`integrations/langchain` and `integrations/llama_index`) have also been migrated: | ||
|
||
```bash | ||
# For langchain integration | ||
cd integrations/langchain | ||
uv pip install -e .[dev] | ||
|
||
# For llama_index integration | ||
cd integrations/llama_index | ||
uv pip install -e .[dev] | ||
``` | ||
|
||
## Troubleshooting | ||
|
||
### Virtual Environment Issues | ||
If you encounter issues with the virtual environment: | ||
```bash | ||
# Remove and recreate | ||
rm -rf .venv | ||
uv venv | ||
uv pip install -e .[dev] | ||
``` | ||
|
||
### Dependency Resolution Issues | ||
If you encounter dependency conflicts: | ||
```bash | ||
# Clear uv cache | ||
uv cache clean | ||
|
||
# Try installing with verbose output | ||
uv pip install -e .[dev] --verbose | ||
``` | ||
|
||
### CI/CD Issues | ||
The CI/CD workflows have been updated to use uv. If you encounter issues: | ||
1. Check that the `astral-sh/setup-uv@v4` action is being used | ||
2. Ensure virtual environment activation with `source .venv/bin/activate` | ||
3. Use `uv pip install -e .[dev]` for dependency installation | ||
|
||
## Rollback Plan | ||
|
||
If you need to rollback to Poetry temporarily: | ||
|
||
1. Restore the previous `pyproject.toml` format | ||
2. Run `poetry install` to recreate the Poetry environment | ||
3. Update CI/CD workflows to use Poetry actions | ||
|
||
However, the migration to uv provides significant benefits and is recommended for long-term maintenance. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pin the uv version instead of using 'latest' to ensure reproducible Docker builds.