Skip to content

Commit 20c9c87

Browse files
authored
chore: Migrate from pip/setuptools to uv package manager (#380)
Migrate to uv for Python package management with `exclude-newer = "1 week"` to prevent supply chain attacks. - Consolidate `setup.py`/`setup.cfg`/`requirements.txt` into `pyproject.toml` - Add `uv.lock` for reproducible installs - Update CI workflows to use `astral-sh/setup-uv` - Update Dockerfile to use uv - Update Makefile to use `uv run`
1 parent 9940a93 commit 20c9c87

12 files changed

Lines changed: 862 additions & 112 deletions

File tree

.github/workflows/lint.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8
19+
with:
20+
version: "0.11.2"
1721
- name: Set up Python
1822
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
1923
with:
2024
python-version: "3.13"
2125
- name: Install dependencies
22-
run: |
23-
pip install --upgrade pip
24-
pip install -r requirements.txt
26+
run: uv sync --frozen
2527
- name: Check formatting
2628
run: make fmt-check

.github/workflows/publish.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ jobs:
1717
steps:
1818
- name: Checkout
1919
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8
22+
with:
23+
version: "0.11.2"
2024
- name: Set up Python
2125
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
2226
with:
2327
python-version: "3.13"
24-
- name: Install dependencies
25-
run: |
26-
pip install --upgrade pip
27-
pip install -r requirements.txt
28-
pip install build
2928
- name: Build package
30-
run: python -m build
29+
run: uv build
3130
- name: Publish package distributions to PyPI
3231
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/unittests.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ jobs:
1818
- # Required for the package command tests to work
1919
name: Set up Docker Buildx
2020
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8
23+
with:
24+
version: "0.11.2"
2125
- name: Set up Python
2226
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
2327
with:
2428
python-version: "3.13"
2529
- name: Install dependencies
26-
run: |
27-
pip install --upgrade pip
28-
pip install -r requirements.txt
30+
run: uv sync --frozen
2931
- name: Run tests
3032
run: make test

Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
FROM python:3.13-slim
22

3+
COPY --from=ghcr.io/astral-sh/uv:0.11.2 /uv /uvx /bin/
4+
35
WORKDIR /app
46

5-
# Copy the code and install dependencies
6-
COPY requirements.txt .
7-
COPY setup.cfg .
8-
COPY setup.py .
7+
# Copy dependency files and install
8+
COPY pyproject.toml uv.lock ./
9+
RUN uv sync --frozen --no-dev --no-install-project
10+
11+
# Copy the code and install the project
912
COPY cloudquery cloudquery
1013
COPY main.py .
11-
RUN pip3 install --no-cache-dir -r requirements.txt
14+
RUN uv sync --frozen --no-dev
1215

1316
EXPOSE 7777
1417

15-
ENTRYPOINT ["python3", "main.py"]
18+
ENTRYPOINT ["uv", "run", "python3", "main.py"]
1619

17-
CMD ["serve", "--address", "[::]:7777", "--log-format", "json", "--log-level", "info"]
20+
CMD ["serve", "--address", "[::]:7777", "--log-format", "json", "--log-level", "info"]

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
test:
2-
pytest .
2+
uv run pytest .
33

44
fmt:
5-
black .
5+
uv run black .
66

77
fmt-check:
8-
black --check .
8+
uv run black --check .

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is the high-level package to use for developing CloudQuery plugins in Pytho
55
## Installation
66

77
```commandline
8-
pip install cloudquery-plugin-sdk
8+
uv add cloudquery-plugin-sdk
99
```
1010

1111
## Links

pyproject.toml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[build-system]
2+
requires = ["setuptools>=75.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "cloudquery-plugin-sdk"
7+
version = "0.1.54"
8+
description = "CloudQuery Plugin SDK for Python"
9+
readme = "README.md"
10+
license = "MPL-2.0"
11+
requires-python = ">=3.11"
12+
authors = [
13+
{ name = "CloudQuery LTD", email = "[email protected]" },
14+
]
15+
classifiers = [
16+
"Intended Audience :: Developers",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"Programming Language :: Python :: 3.13",
22+
"Operating System :: OS Independent",
23+
"Topic :: Internet",
24+
]
25+
dependencies = [
26+
"cloudquery-plugin-pb>=0.0.54",
27+
"grpcio>=1.78.0",
28+
"grpcio-tools>=1.78.0",
29+
"Jinja2>=3.1.6",
30+
"MarkupSafe>=3.0.3",
31+
"numpy>=2.4.2",
32+
"packaging>=26.0",
33+
"pandas>=3.0.0",
34+
"protobuf>=6.31.1",
35+
"pyarrow>=23.0.0",
36+
"python-dateutil>=2.8.1",
37+
"pytz>=2025.2",
38+
"six>=1.17.0",
39+
"structlog>=25.5.0",
40+
"tomli>=2.4.0",
41+
"tzdata>=2025.3",
42+
]
43+
44+
[project.urls]
45+
Homepage = "https://github.com/cloudquery/plugin-sdk-python"
46+
47+
[dependency-groups]
48+
dev = [
49+
"black>=26.3.1",
50+
"pytest>=9.0.2",
51+
]
52+
53+
[tool.setuptools.packages.find]
54+
include = ["cloudquery*"]
55+
56+
[tool.setuptools.package-data]
57+
cloudquery = ["sdk/py.typed"]
58+
59+
[tool.pytest.ini_options]
60+
python_files = "tests/*.py"
61+
62+
[tool.uv]
63+
exclude-newer = "1 week"

pytest.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements.txt

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

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)