Skip to content

Commit d6f0254

Browse files
Migrate project from Poetry to uv (#32)
* chore: migrate project from Poetry to uv * ci: switch workflows to uv
1 parent 6f0846c commit d6f0254

File tree

8 files changed

+2897
-3159
lines changed

8 files changed

+2897
-3159
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,24 @@ jobs:
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20-
21-
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: ${{ matrix.python-version }}
25-
26-
- name: Install Poetry
27-
uses: snok/install-poetry@v1.3.4
28-
with:
29-
version: latest
30-
virtualenvs-create: true
31-
virtualenvs-in-project: true
32-
33-
- name: Load cached venv
34-
id: cached-poetry-dependencies
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v1
23+
24+
- name: Ensure Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Cache virtual environment
28+
id: cache-uv-venv
3529
uses: actions/cache@v4
3630
with:
3731
path: .venv
38-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
39-
40-
- name: Install dependencies
41-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
42-
run: poetry install --no-interaction --no-root --extras "all"
43-
44-
- name: Install project
45-
run: poetry install --no-interaction --extras "all"
46-
47-
- name: Run tests
48-
run: poetry run pytest tests/ -v
49-
32+
key: uv-venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
33+
34+
- name: Sync dependencies
35+
run: uv sync --all-extras --python ${{ matrix.python-version }}
36+
5037
- name: Run tests with coverage
5138
run: |
52-
poetry run pytest tests/ --cov=pyspark_datasources --cov-report=xml --cov-report=term-missing
39+
uv run pytest tests/ --cov=pyspark_datasources --cov-report=xml --cov-report=term-missing
5340

.github/workflows/docs.yml

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,25 @@ jobs:
2929
steps:
3030
- name: Checkout
3131
uses: actions/checkout@v4
32-
33-
- name: Set up Python
34-
uses: actions/setup-python@v5
35-
with:
36-
python-version: '3.11'
37-
38-
- name: Install Poetry
39-
run: |
40-
curl -sSL https://install.python-poetry.org | python - -y
41-
echo "$HOME/.local/bin" >> $GITHUB_PATH
42-
43-
- name: Configure Poetry
44-
run: |
45-
poetry config virtualenvs.create true
46-
poetry config virtualenvs.in-project true
47-
48-
- name: Load cached venv
49-
id: cached-poetry-dependencies
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v1
35+
36+
- name: Ensure Python 3.11
37+
run: uv python install 3.11
38+
39+
- name: Cache virtual environment
40+
id: cache-uv-venv
5041
uses: actions/cache@v4
5142
with:
5243
path: .venv
53-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
54-
55-
- name: Install dependencies
56-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
57-
run: poetry install --no-interaction --no-root
58-
59-
- name: Install project
60-
run: poetry install --no-interaction
61-
44+
key: uv-venv-${{ runner.os }}-3.11-${{ hashFiles('uv.lock') }}
45+
46+
- name: Sync dependencies
47+
run: uv sync --python 3.11 --group dev
48+
6249
- name: Build MkDocs
63-
run: poetry run mkdocs build
50+
run: uv run mkdocs build
6451

6552
- name: Setup Pages
6653
uses: actions/configure-pages@v5

contributing/DEVELOPMENT.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Prerequisites
66
- Python 3.9-3.12
7-
- Poetry for dependency management
7+
- [uv](https://docs.astral.sh/uv/) for dependency management
88
- Apache Spark 4.0+ (or Databricks Runtime 15.4 LTS+)
99

1010
### Installation
@@ -14,14 +14,14 @@
1414
git clone https://github.com/allisonwang-db/pyspark-data-sources.git
1515
cd pyspark-data-sources
1616

17-
# Install dependencies
18-
poetry install
17+
# Install dependencies (creates .venv/ automatically)
18+
uv sync
1919

2020
# Install with all optional dependencies
21-
poetry install --extras all
21+
uv sync --extra all
2222

23-
# Activate virtual environment
24-
poetry shell
23+
# Activate virtual environment (optional)
24+
source .venv/bin/activate
2525
```
2626

2727
### macOS Setup
@@ -84,27 +84,27 @@ This project uses [Ruff](https://github.com/astral-sh/ruff) for code formatting
8484

8585
```bash
8686
# Format code
87-
poetry run ruff format .
87+
uv run ruff format .
8888

8989
# Run linter
90-
poetry run ruff check .
90+
uv run ruff check .
9191

9292
# Run linter with auto-fix
93-
poetry run ruff check . --fix
93+
uv run ruff check . --fix
9494

9595
# Check specific file
96-
poetry run ruff check pyspark_datasources/fake.py
96+
uv run ruff check pyspark_datasources/fake.py
9797
```
9898

9999
### Pre-commit Hooks (Optional)
100100

101101
```bash
102102
# Install pre-commit hooks
103-
poetry add --group dev pre-commit
104-
pre-commit install
103+
uv add --dev pre-commit
104+
uv run pre-commit install
105105

106106
# Run manually
107-
pre-commit run --all-files
107+
uv run pre-commit run --all-files
108108
```
109109

110110
## Documentation
@@ -245,24 +245,24 @@ Add your data source to the table in README.md with examples.
245245

246246
```bash
247247
# Add required dependency
248-
poetry add requests
248+
uv add requests
249249

250250
# Add optional dependency
251-
poetry add --optional faker
251+
uv add --optional faker faker
252252

253253
# Add dev dependency
254-
poetry add --group dev pytest-cov
254+
uv add --dev pytest-cov
255255

256256
# Update dependencies
257-
poetry update
257+
uv sync --upgrade
258258
```
259259

260260
### Managing Extras
261261

262262
Edit `pyproject.toml` to add optional dependency groups:
263263

264264
```toml
265-
[tool.poetry.extras]
265+
[project.optional-dependencies]
266266
mynewsource = ["special-library"]
267267
all = ["faker", "datasets", "special-library", ...]
268268
```
@@ -363,17 +363,18 @@ import os
363363
os.environ["OBJC_DISABLE_INITIALIZE_FORK_SAFETY"] = "YES"
364364
```
365365

366-
### Poetry Issues
366+
### uv Troubleshooting
367367

368368
```bash
369369
# Clear cache
370-
poetry cache clear pypi --all
370+
uv cache clean
371371

372-
# Update lock file
373-
poetry lock --no-update
372+
# Check that the lockfile matches pyproject
373+
uv lock --check
374374

375-
# Reinstall
376-
poetry install --remove-untracked
375+
# Recreate the virtual environment
376+
rm -rf .venv
377+
uv sync
377378
```
378379

379380
### Spark Session Issues

0 commit comments

Comments
 (0)