Skip to content

Commit f9e7638

Browse files
Merge pull request #1141 from Backblaze/uv
Migrate from pdm to uv
2 parents 25eafa4 + 45cd3a8 commit f9e7638

9 files changed

Lines changed: 2534 additions & 2154 deletions

File tree

.github/workflows/cd.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88
CD: "true"
99
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1010
PYTHON_DEFAULT_VERSION: "3.12"
11+
UV_VERSION: "0.8.24"
1112

1213
jobs:
1314
deploy:
@@ -35,11 +36,16 @@ jobs:
3536
uses: actions/setup-python@v6
3637
with:
3738
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
39+
- uses: astral-sh/setup-uv@v7
40+
with:
41+
version: ${{ env.UV_VERSION }}
42+
enable-cache: true
3843
- name: Install dependencies
39-
run: python -m pip install --upgrade nox pdm==2.26.4
44+
run: |
45+
uv sync --locked --group nox
4046
- name: Build the distribution
4147
id: build
42-
run: nox -vs build
48+
run: uv run nox -vs build
4349
- name: Read the Changelog
4450
id: read-changelog
4551
uses: mindsers/changelog-reader-action@v2
@@ -75,21 +81,25 @@ jobs:
7581
uses: deadsnakes/action@v3.2.0 # staticx doesn't work with python installed by setup-python action
7682
with:
7783
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
84+
- uses: astral-sh/setup-uv@v7
85+
with:
86+
version: ${{ env.UV_VERSION }}
87+
enable-cache: true
7888
- name: Install dependencies
7989
run: |
8090
sudo apt-get -y update
8191
sudo apt-get -y install patchelf scons
82-
python -m pip install --upgrade nox pdm==2.26.4
92+
uv sync --python ${{ env.PYTHON_DEFAULT_VERSION }} --locked --group nox
8393
git config --global --add safe.directory '*'
8494
- name: Bundle the distribution
8595
id: bundle
86-
run: nox -vs bundle
96+
run: uv run nox -vs bundle
8797
- name: Sign the bundle
8898
id: sign
89-
run: nox -vs sign
99+
run: uv run nox -vs sign
90100
- name: Generate hashes
91101
id: hashes
92-
run: nox -vs make_dist_digest
102+
run: uv run nox -vs make_dist_digest
93103
- name: Upload the bundle to the GitHub release
94104
uses: softprops/action-gh-release@v2
95105
with:
@@ -113,12 +123,17 @@ jobs:
113123
uses: actions/setup-python@v6
114124
with:
115125
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
126+
- uses: astral-sh/setup-uv@v7
127+
with:
128+
version: ${{ env.UV_VERSION }}
129+
enable-cache: true
116130
- name: Install dependencies
117-
run: python -m pip install --upgrade nox pdm==2.26.4
131+
run: |
132+
uv sync --locked --group nox
118133
- name: Bundle the distribution
119134
id: bundle
120135
shell: bash
121-
run: nox -vs bundle
136+
run: uv run nox -vs bundle
122137
- name: Install client for code signing with Software Trust Manager
123138
uses: digicert/ssm-code-signing@v1.1.0
124139
env:
@@ -131,10 +146,10 @@ jobs:
131146
shell: bash
132147
- name: Sign the bundle using a keypair alias
133148
id: sign
134-
run: nox -vs sign -- '${{ secrets.SM_KEYPAIR_ALIAS }}' '${{ secrets.SM_CERT_FINGERPRINT }}'
149+
run: uv run nox -vs sign -- '${{ secrets.SM_KEYPAIR_ALIAS }}' '${{ secrets.SM_CERT_FINGERPRINT }}'
135150
- name: Generate hashes
136151
id: hashes
137-
run: nox -vs make_dist_digest
152+
run: uv run nox -vs make_dist_digest
138153
- name: Create GitHub release and upload the distribution
139154
id: create-release
140155
uses: softprops/action-gh-release@v2
@@ -158,10 +173,15 @@ jobs:
158173
uses: actions/setup-python@v6
159174
with:
160175
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
176+
- uses: astral-sh/setup-uv@v7
177+
with:
178+
version: ${{ env.UV_VERSION }}
179+
enable-cache: true
161180
- name: Install dependencies
162-
run: python -m pip install --upgrade nox pdm==2.26.4
181+
run: |
182+
uv sync --locked --group nox
163183
- name: Build Dockerfile
164-
run: nox -vs generate_dockerfile
184+
run: uv run nox -vs generate_dockerfile
165185
- name: Set up QEMU
166186
uses: docker/setup-qemu-action@v3
167187
- name: Set up Docker Buildx

.github/workflows/ci.yml

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
env:
1010
PYTHON_DEFAULT_VERSION: "3.12"
11+
UV_VERSION: "0.8.24"
1112

1213
jobs:
1314
lint:
@@ -24,16 +25,21 @@ jobs:
2425
uses: actions/setup-python@v6
2526
with:
2627
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
28+
- uses: astral-sh/setup-uv@v7
29+
with:
30+
version: ${{ env.UV_VERSION }}
31+
enable-cache: true
2732
- name: Install dependencies
28-
run: python -m pip install --upgrade nox pdm==2.26.4
33+
run: |
34+
uv sync --locked --group nox
2935
- name: Run linters
30-
run: nox -vs lint
36+
run: uv run nox -vs lint
3137
- name: Validate new changelog entries
3238
if: (contains(github.event.pull_request.labels.*.name, '-changelog') == false) && (github.event.pull_request.base.ref != '')
3339
run: if [ -z "$(git diff --diff-filter=A --name-only origin/${{ github.event.pull_request.base.ref }} changelog.d)" ];
3440
then echo no changelog item added; exit 1; fi
3541
- name: Changelog validation
36-
run: nox -vs towncrier_check
42+
run: uv run nox -vs towncrier_check
3743
build:
3844
timeout-minutes: 30
3945
needs: lint
@@ -46,10 +52,15 @@ jobs:
4652
uses: actions/setup-python@v6
4753
with:
4854
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
55+
- uses: astral-sh/setup-uv@v7
56+
with:
57+
version: ${{ env.UV_VERSION }}
58+
enable-cache: true
4959
- name: Install dependencies
50-
run: python -m pip install --upgrade nox pdm==2.26.4
60+
run: |
61+
uv sync --locked --group nox
5162
- name: Build the distribution
52-
run: nox -vs build
63+
run: uv run nox -vs build
5364
cleanup_buckets:
5465
timeout-minutes: 30
5566
needs: lint
@@ -68,12 +79,18 @@ jobs:
6879
with:
6980
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
7081
cache: "pip"
82+
- uses: astral-sh/setup-uv@v7
83+
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
84+
with:
85+
version: ${{ env.UV_VERSION }}
86+
enable-cache: true
7187
- name: Install dependencies
7288
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
73-
run: python -m pip install --upgrade nox pdm==2.26.4
89+
run: |
90+
uv sync --locked --group nox
7491
- name: Find and remove old buckets
7592
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
76-
run: nox -vs cleanup_buckets
93+
run: uv run nox -vs cleanup_buckets
7794
test:
7895
timeout-minutes: 90
7996
needs: cleanup_buckets
@@ -100,6 +117,10 @@ jobs:
100117
uses: actions/setup-python@v6
101118
with:
102119
python-version: ${{ matrix.python-version }}
120+
- uses: astral-sh/setup-uv@v7
121+
with:
122+
version: ${{ env.UV_VERSION }}
123+
enable-cache: true
103124
- name: Install test binary dependencies
104125
if: startsWith(matrix.os, 'ubuntu')
105126
run: |
@@ -111,15 +132,16 @@ jobs:
111132
run: |
112133
brew install fish
113134
- name: Install dependencies
114-
run: python -m pip install --upgrade nox pdm==2.26.4
135+
run: |
136+
uv sync --locked --group nox
115137
- name: Run unit tests
116-
run: nox -vs unit -p ${{ matrix.python-version }}
138+
run: uv run nox -vs unit -p ${{ matrix.python-version }}
117139
- name: Run integration tests (without secrets)
118-
run: nox -vs integration -p ${{ matrix.python-version }} -- -m "not require_secrets"
140+
run: uv run nox -vs integration -p ${{ matrix.python-version }} -- -m "not require_secrets"
119141
- name: Run integration tests (with secrets)
120142
# Limit CI workload by running integration tests with secrets only on edge Python versions.
121143
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' && contains(fromJSON('["3.9", "pypy3.10", "3.14"]'), matrix.python-version) }}
122-
run: nox -vs integration -p ${{ matrix.python-version }} -- -m "require_secrets" --cleanup
144+
run: uv run nox -vs integration -p ${{ matrix.python-version }} -- -m "require_secrets" --cleanup
123145
test-docker:
124146
timeout-minutes: 90
125147
needs: cleanup_buckets
@@ -136,10 +158,15 @@ jobs:
136158
uses: actions/setup-python@v6
137159
with:
138160
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
161+
- uses: astral-sh/setup-uv@v7
162+
with:
163+
version: ${{ env.UV_VERSION }}
164+
enable-cache: true
139165
- name: Install dependencies
140-
run: python -m pip install --upgrade nox pdm==2.26.4
166+
run: |
167+
uv sync --locked --group nox
141168
- name: Generate Dockerfile
142-
run: nox -vs generate_dockerfile
169+
run: uv run nox -vs generate_dockerfile
143170
- name: Set up QEMU
144171
uses: docker/setup-qemu-action@v3
145172
- name: Set up Docker Buildx
@@ -153,7 +180,7 @@ jobs:
153180
platforms: linux/amd64
154181
- name: Run tests with docker
155182
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }}
156-
run: nox -vs docker_test -- backblazeit/b2:test
183+
run: uv run nox -vs docker_test -- backblazeit/b2:test
157184
test-linux-bundle:
158185
timeout-minutes: 90
159186
needs: cleanup_buckets
@@ -174,24 +201,28 @@ jobs:
174201
uses: deadsnakes/action@v3.2.0 # staticx doesn't work with python installed by setup-python action
175202
with:
176203
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
204+
- uses: astral-sh/setup-uv@v7
205+
with:
206+
version: ${{ env.UV_VERSION }}
207+
enable-cache: true
177208
- name: Install dependencies
178209
run: |
179210
sudo apt-get -y update
180211
sudo apt-get -y install patchelf scons
181-
python -m pip install --upgrade nox pdm==2.26.4
212+
uv sync --python ${{ env.PYTHON_DEFAULT_VERSION }} --locked --group nox
182213
git config --global --add safe.directory '*'
183214
- name: Bundle the distribution
184215
id: bundle
185216
shell: bash
186-
run: nox -vs bundle
217+
run: uv run nox -vs bundle
187218
- name: Generate hashes
188219
id: hashes
189-
run: nox -vs make_dist_digest
220+
run: uv run nox -vs make_dist_digest
190221
- name: Run integration tests (without secrets)
191-
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
222+
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
192223
- name: Run integration tests (with secrets)
193224
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }}
194-
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
225+
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
195226
- name: Upload assets
196227
if: failure()
197228
uses: actions/upload-artifact@v4
@@ -216,20 +247,25 @@ jobs:
216247
uses: actions/setup-python@v6
217248
with:
218249
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
250+
- uses: astral-sh/setup-uv@v7
251+
with:
252+
version: ${{ env.UV_VERSION }}
253+
enable-cache: true
219254
- name: Install dependencies
220-
run: python -m pip install --upgrade nox pdm==2.26.4
255+
run: |
256+
uv sync --locked --group nox
221257
- name: Bundle the distribution
222258
id: bundle
223259
shell: bash
224-
run: nox -vs bundle
260+
run: uv run nox -vs bundle
225261
- name: Generate hashes
226262
id: hashes
227-
run: nox -vs make_dist_digest
263+
run: uv run nox -vs make_dist_digest
228264
- name: Run integration tests (without secrets)
229-
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
265+
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
230266
- name: Run integration tests (with secrets)
231267
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }}
232-
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
268+
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
233269
- name: Upload assets
234270
if: failure()
235271
uses: actions/upload-artifact@v4
@@ -250,12 +286,16 @@ jobs:
250286
uses: actions/setup-python@v6
251287
with:
252288
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
289+
- uses: astral-sh/setup-uv@v7
290+
with:
291+
version: ${{ env.UV_VERSION }}
292+
enable-cache: true
253293
- name: Install dependencies
254294
env:
255295
DEBIAN_FRONTEND: noninteractive
256296
run: |
257297
sudo apt-get update -y
258298
sudo apt-get install -y graphviz plantuml
259-
python -m pip install --upgrade nox pdm==2.26.4
299+
uv sync --locked --group nox
260300
- name: Build the docs
261-
run: nox --non-interactive -vs doc
301+
run: uv run nox --non-interactive -vs doc

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ for a given github issue).
5555

5656
## Developer Info
5757

58-
You'll need to have [nox](https://github.com/theacodes/nox) and [pdm](https://pdm-project.org/) installed:
58+
You'll need to have [nox](https://github.com/theacodes/nox) and [uv](https://docs.astral.sh/uv/) installed:
5959

60-
* `pip install nox pdm`
60+
* `pip install nox uv`
6161

6262
With `nox`, you can run different sessions (default are `lint` and `test`):
6363

@@ -106,10 +106,10 @@ Given Python interpreters should be installed in the operating system or via [py
106106

107107
## Managing dependencies
108108

109-
We use [pdm](https://pdm-project.org/) for managing dependencies and developing locally.
109+
We use [uv](https://docs.astral.sh/uv/) for managing dependencies and developing locally.
110110
If you want to change any of the project requirements (or requirement bounds) in `pyproject.toml`,
111-
make sure that `pdm.lock` file reflects those changes by using `pdm add`, `pdm update` or other
112-
commands - see [documentation](https://pdm-project.org/latest/). You can verify that lock file
111+
make sure that `uv.lock` file reflects those changes by using `uv add`, `uv lock` or other
112+
commands - see [documentation](https://docs.astral.sh/uv/). You can verify that lock file
113113
is up to date by running the linter.
114114

115115
## Linting
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Migrate from pdm to uv.

docker/Dockerfile.template

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
FROM python:${python_version}-slim as builder
22

3-
RUN apt-get update -y && apt-get install git patchelf -y && pip install -U pdm
3+
RUN apt-get update -y && apt-get install git patchelf -y && pip install -U uv==0.8.24
44

55
WORKDIR /b2
66
COPY ./b2 /b2/b2
7-
COPY pyproject.toml pdm.lock LICENSE README.md /b2/
7+
COPY pyproject.toml uv.lock LICENSE README.md /b2/
88

9-
ENV PDM_BUILD_SCM_VERSION=${version}
10-
RUN pdm install --prod --group license
11-
RUN pdm run b2 license --dump --with-packages
12-
# Run pdm in PEP 582 mode, install packaged to __pypackages__, not virtualenv
13-
RUN rm -r .venv && mkdir __pypackages__ && pdm install --prod --group full --no-editable
9+
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${version}
10+
RUN uv sync --locked --no-dev --extra license
11+
RUN uv run b2 license --dump --with-packages
12+
RUN rm -r .venv && mkdir __pypackages__
13+
RUN uv export --locked --no-dev --extra full --no-hashes --no-editable -o requirements.txt
14+
RUN uv pip install --compile-bytecode --python /usr/local/bin/python --prefix __pypackages__ -r requirements.txt
1415

1516
FROM python:${python_version}-slim
1617

@@ -26,8 +27,8 @@ LABEL build-date-iso8601="${build_date}"
2627
ENV B2_CLI_DOCKER=1
2728
ENV PYTHONPATH=/opt/b2
2829
COPY ./docker/entrypoint.sh /entrypoint.sh
29-
COPY --from=builder /b2/__pypackages__/${python_version}/lib /opt/b2
30-
COPY --from=builder /b2/__pypackages__/${python_version}/bin/* /bin/
30+
COPY --from=builder /b2/__pypackages__/lib/python${python_version}/site-packages /opt/b2
31+
COPY --from=builder /b2/__pypackages__/bin/* /bin/
3132

3233
WORKDIR /root
3334
ENTRYPOINT ["/entrypoint.sh"]

0 commit comments

Comments
 (0)