Skip to content

Commit 442a66a

Browse files
authored
Migrate to uv for python package management (#590)
* Migrate from pip/setup.py to uv for package management - Replace setup.py with pyproject.toml using hatchling build backend - Consolidate requirements.txt and dev-requirements.txt into pyproject.toml - Update Makefile to use uv commands instead of venv/pip - Update GitHub Actions workflows to use astral-sh/setup-uv@v4 - Remove MANIFEST.in (handled by hatch) - Update .gitignore for uv artifacts * update uv install action version * Fix uv migration: add missing msgpack dep, commit lockfile * update documentation and examples post migration
1 parent af8ce43 commit 442a66a

File tree

15 files changed

+3795
-257
lines changed

15 files changed

+3795
-257
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: checkout
15-
uses: actions/checkout@v3
16-
- name: Set up Python 3.9
17-
uses: actions/setup-python@v4
15+
uses: actions/checkout@v4
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v7
1818
with:
19-
python-version: 3.9
19+
python-version: "3.9"
20+
- name: Install dependencies
21+
run: uv sync --all-extras
2022
- name: Linting
21-
run: |
22-
python -m pip install --upgrade pip
23-
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
24-
pre-commit run --all-files
23+
run: uv run pre-commit run --all-files
24+
2525
build-n-test:
2626
name: Build and test
2727
runs-on: ubuntu-latest
@@ -34,23 +34,14 @@ jobs:
3434
uses: actions/checkout@v4
3535
with:
3636
fetch-depth: 0
37-
- name: Set up Python ${{ matrix.python-version }} (minimum supported python version for deltaCAT is 3.9)
38-
uses: actions/setup-python@v4
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v7
3939
with:
4040
python-version: ${{ matrix.python-version }}
41-
- name: Install pypa/build
42-
run: >-
43-
python -m
44-
pip install
45-
build
46-
--user
4741
- name: Install dependencies
48-
run: |
49-
python -m pip install --upgrade pip
50-
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
42+
run: uv sync --all-extras
5143
- name: Run unit tests + benchmarks
52-
run: >-
53-
python -m pytest -m "not integration" --benchmark-json output.json
44+
run: uv run pytest -m "not integration" --benchmark-json output.json
5445
# Download previous benchmark result from cache (if exists)
5546
- name: Download previous benchmark data
5647
uses: actions/cache@v4

.github/workflows/publish-to-pypi.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,21 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout
11-
uses: actions/checkout@main
11+
uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
14-
- name: Set up Python 3.9 (minimum supported python version for deltaCAT)
15-
uses: actions/setup-python@v4
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v7
1616
with:
1717
python-version: "3.9"
18-
- name: Install pypa/build
19-
run: >-
20-
python -m
21-
pip install
22-
build
23-
--user
2418
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install pytest
28-
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
19+
run: uv sync --all-extras
2920
- name: Run unit tests
30-
run: >-
31-
python -m pytest -m "not integration"
21+
run: uv run pytest -m "not integration"
3222
- name: Echo release tag
3323
run: echo ${{ github.ref_name }}
34-
- name: Build a binary wheel and a source tarball
35-
run: >-
36-
python setup.py sdist bdist_wheel
24+
- name: Build
25+
run: uv build
3726
- name: Publish distribution to PyPI
3827
if: startsWith(github.ref, 'refs/tags')
3928
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# uv
2+
.venv/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,30 @@
1-
venv:
2-
if [ ! -d "venv" ]; then \
3-
if [[ '$(shell uname -m)' == 'arm64' ]]; then \
4-
/usr/bin/python3 -m venv venv; \
5-
else \
6-
python -m venv venv; \
7-
fi \
8-
fi
1+
.PHONY: install lint test unit-test build clean clean-build type-mappings benchmark benchmark-aws test-converter-integration test-integration-rebuild publish
92

10-
clean-build:
11-
rm -rf dist
12-
rm -rf build
13-
rm -rf deltacat.egg-info
3+
install:
4+
uv sync --all-extras
145

15-
clean-venv:
16-
rm -rf venv
6+
clean-build:
7+
rm -rf dist build deltacat.egg-info
178

18-
clean: clean-build clean-venv
9+
clean: clean-build
10+
rm -rf .venv
1911

20-
build: venv
21-
venv/bin/python setup.py sdist bdist_wheel
12+
build:
13+
uv build
2214

2315
rebuild: clean-build build
2416

2517
deploy-s3:
2618
./dev/deploy/aws/scripts/s3-build-and-deploy.sh
2719

28-
install: venv
29-
venv/bin/pip install --upgrade pip
30-
venv/bin/pip install -r dev-requirements.txt
31-
3220
lint: install
33-
venv/bin/pre-commit run --all-files
21+
uv run pre-commit run --all-files
3422

3523
test: install
36-
venv/bin/pytest -m "not integration"
24+
uv run pytest -m "not integration"
3725

3826
unit-test: install
39-
venv/bin/pytest -m "not integration and not benchmark"
27+
uv run pytest -m "not integration and not benchmark"
4028

4129
test-converter-integration: install
4230
docker-compose -f dev/iceberg-integration/docker-compose-integration.yml kill
@@ -45,27 +33,27 @@ test-converter-integration: install
4533
sleep 3
4634
docker-compose -f dev/iceberg-integration/docker-compose-integration.yml exec -T spark-iceberg ipython ./provision.py
4735
export SPARK_LOCAL_IP="127.0.0.1"
48-
venv/bin/python -m pytest deltacat/tests/compute/converter/integration -vv
36+
uv run pytest deltacat/tests/compute/converter/integration -vv
4937

5038
test-integration-rebuild:
5139
docker-compose -f dev/iceberg-integration/docker-compose-integration.yml kill
5240
docker-compose -f dev/iceberg-integration/docker-compose-integration.yml rm -f
5341
docker-compose -f dev/iceberg-integration/docker-compose-integration.yml build --no-cache
5442

5543
benchmark-aws: install
56-
venv/bin/pytest deltacat/benchmarking/benchmark_parquet_reads.py --benchmark-only --benchmark-group-by=group,param:name
44+
uv run pytest deltacat/benchmarking/benchmark_parquet_reads.py --benchmark-only --benchmark-group-by=group,param:name
5745

5846
benchmark: install
59-
pytest -m benchmark deltacat/benchmarking
47+
uv run pytest -m benchmark deltacat/benchmarking
6048

6149
type-mappings: install
6250
@echo "Generating type mappings..."
63-
venv/bin/python deltacat/docs/autogen/schema/inference/generate_type_mappings.py
51+
uv run python deltacat/docs/autogen/schema/inference/generate_type_mappings.py
6452
@echo "Parsing type mappings to markdown..."
65-
venv/bin/python deltacat/docs/autogen/schema/inference/parse_json_type_mappings.py generate_type_mappings_results.json
53+
uv run python deltacat/docs/autogen/schema/inference/parse_json_type_mappings.py generate_type_mappings_results.json
6654
@echo "Generating Python compatibility mapping..."
67-
venv/bin/python deltacat/docs/autogen/schema/inference/parse_json_type_mappings.py generate_type_mappings_results.json --python
55+
uv run python deltacat/docs/autogen/schema/inference/parse_json_type_mappings.py generate_type_mappings_results.json --python
6856
@echo "Type mappings generation complete!"
6957

70-
publish: test test-integration rebuild
71-
twine upload dist/*
58+
publish: test build
59+
uv publish

README-development.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ make lint
2020
We use `make` to automate common development tasks. If you feel that any recurring development routine is
2121
missing from the current set of Makefile targets, please propose a new one!
2222

23-
#### venv
24-
```shell
25-
make venv
26-
```
27-
Creates a virtual environment in the `venv` directory with all required development dependencies installed. You usually
28-
don't need to run this command directly, since it will be invoked automatically by any other target that needs it.
29-
30-
#### clean-venv
31-
```shell
32-
make clean-venv
33-
```
34-
Removes all artifacts created by the `venv` Makefile target.
35-
3623
#### build
3724
```shell
3825
make build
@@ -55,7 +42,7 @@ Runs `clean-build` followed by `build`.
5542
```shell
5643
make clean
5744
```
58-
Removes all artifacts created by the `build` and `venv` Makefile targets.
45+
Removes all artifacts created by the `build` target and removes the virtual environment.
5946

6047
#### deploy-s3
6148
```shell
@@ -67,7 +54,7 @@ Builds and uploads a wheel to S3. See [Build and Deploy an S3 Wheel](#build-and-
6754
```shell
6855
make install
6956
```
70-
Installs all developer requirements from `dev-requirements.txt` in your virtual environment.
57+
Creates a virtual environment if it doesn't exist and installs all build and runtime dependencies from pyproject.toml.
7158

7259
#### lint
7360
```shell

deltacat/benchmarking/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
All the dependencies needed to test are in dev-requirements.txt
1+
All the dependencies needed to test are in pyproject.toml
22

33
You can run these tests via:
44

deltacat/examples/compactor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you're working from DeltaCAT source code, you may want to install and activat
1111
make install
1212

1313
# Activate the virtual environment
14-
source venv/bin/activate
14+
source .venv/bin/activate
1515

1616
# Navigate to examples
1717
cd deltacat/examples/compactor

deltacat/examples/experimental/iceberg/converter/beam/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Run the following commands from the DeltaCAT project root directory
5050
make install
5151

5252
# Activate virtual environment
53-
source venv/bin/activate
53+
source .venv/bin/activate
5454

5555
# Navigate to example directory
5656
cd deltacat/examples/experimental/iceberg/converter/beam

deltacat/examples/experimental/iceberg/iceberg_bucket_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def run(warehouse="s3://my-bucket/my/key/prefix", **kwargs):
4545
2. retrieve the IAM Role AWS Credential and cache locally in ~/.aws/credentials
4646
3. run below command to execute the example
4747
```
48-
make venv && source venv/bin/activate
48+
make install && source .venv/bin/activate
4949
python -m deltacat.examples.iceberg.iceberg_bucket_writer --warehouse=s3://<YOUR_S3_LOCATION>
5050
```
5151

0 commit comments

Comments
 (0)