Skip to content

Commit d150c68

Browse files
NoahStappCopilot
andauthored
PYTHON-5862 - Remove usage of uv lock file (#2902)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent b814548 commit d150c68

9 files changed

Lines changed: 48 additions & 2914 deletions

File tree

.evergreen/run-tests.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,10 @@ else
2626
exit 1
2727
fi
2828

29-
cleanup_tests() {
30-
# Avoid leaving the lock file in a changed state when we change the resolution type.
31-
if [ -n "${TEST_MIN_DEPS:-}" ]; then
32-
git checkout uv.lock || true
33-
fi
34-
cd $PREV_DIR
35-
}
36-
37-
trap "cleanup_tests" SIGINT ERR
38-
3929
# Start the test runner.
4030
echo "Running tests with UV_PYTHON=${UV_PYTHON:-}..."
4131
echo "UV_ARGS=${UV_ARGS}"
4232
uv run ${UV_ARGS} --reinstall-package pymongo .evergreen/scripts/run_tests.py "$@"
4333
echo "Running tests with UV_PYTHON=${UV_PYTHON:-}... done."
4434

45-
cleanup_tests
35+
cd $PREV_DIR

.evergreen/scripts/configure-env.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ UV_TOOL_DIR=$PROJECT_DIRECTORY/.local/uv/tools
1818
UV_CACHE_DIR=$PROJECT_DIRECTORY/.local/uv/cache
1919
DRIVERS_TOOLS_BINARIES="$DRIVERS_TOOLS/.bin"
2020
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
21+
# GNU date on Linux and Windows, BSD date on macOS.
22+
UV_EXCLUDE_NEWER="$(date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d)"
23+
if [ -z "$UV_EXCLUDE_NEWER" ]; then
24+
echo "Failed to compute UV_EXCLUDE_NEWER" >&2
25+
exit 1
26+
fi
2127

2228
# On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME.
2329
if [ "${CI:-}" == "true" ]; then
@@ -65,6 +71,8 @@ export CARGO_HOME="$CARGO_HOME"
6571
export UV_TOOL_DIR="$UV_TOOL_DIR"
6672
export UV_CACHE_DIR="$UV_CACHE_DIR"
6773
export UV_TOOL_BIN_DIR="$DRIVERS_TOOLS_BINARIES"
74+
export UV_NO_LOCK=1
75+
export UV_EXCLUDE_NEWER="$UV_EXCLUDE_NEWER"
6876
export PYMONGO_BIN_DIR="$PYMONGO_BIN_DIR"
6977
export PATH="$PATH_EXT"
7078
# shellcheck disable=SC2154
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Set UV_EXCLUDE_NEWER
2+
description: >-
3+
Export UV_EXCLUDE_NEWER as 7 days before the current UTC date so uv
4+
resolution ignores packages published in the last week.
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Set UV_EXCLUDE_NEWER
9+
shell: bash
10+
run: |
11+
set -euo pipefail
12+
# GNU date on Linux and Windows, BSD date on macOS.
13+
value="$(date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d)"
14+
if [ -z "$value" ]; then
15+
echo "Failed to compute UV_EXCLUDE_NEWER" >&2
16+
exit 1
17+
fi
18+
echo "UV_EXCLUDE_NEWER=$value" >> "$GITHUB_ENV"

.github/workflows/test-python.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ defaults:
1717
permissions:
1818
contents: read
1919

20+
env:
21+
UV_NO_LOCK: "1"
22+
2023
jobs:
2124

2225
static:
@@ -25,6 +28,7 @@ jobs:
2528
- uses: actions/checkout@v7.0.0
2629
with:
2730
persist-credentials: false
31+
- uses: ./.github/actions/set-uv-exclude-newer
2832
- name: Install uv
2933
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
3034
with:
@@ -70,6 +74,7 @@ jobs:
7074
- uses: actions/checkout@v7.0.0
7175
with:
7276
persist-credentials: false
77+
- uses: ./.github/actions/set-uv-exclude-newer
7378
- name: Install uv
7479
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
7580
with:
@@ -92,6 +97,7 @@ jobs:
9297
- uses: actions/checkout@v7.0.0
9398
with:
9499
persist-credentials: false
100+
- uses: ./.github/actions/set-uv-exclude-newer
95101
- name: Install uv
96102
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
97103
with:
@@ -120,6 +126,7 @@ jobs:
120126
- uses: actions/checkout@v7.0.0
121127
with:
122128
persist-credentials: false
129+
- uses: ./.github/actions/set-uv-exclude-newer
123130
- name: Install uv
124131
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
125132
with:
@@ -145,6 +152,7 @@ jobs:
145152
- uses: actions/checkout@v7.0.0
146153
with:
147154
persist-credentials: false
155+
- uses: ./.github/actions/set-uv-exclude-newer
148156
- name: Install uv
149157
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
150158
with:
@@ -167,6 +175,7 @@ jobs:
167175
- uses: actions/checkout@v7.0.0
168176
with:
169177
persist-credentials: false
178+
- uses: ./.github/actions/set-uv-exclude-newer
170179
- name: Install uv
171180
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
172181
with:
@@ -188,6 +197,7 @@ jobs:
188197
- uses: actions/checkout@v7.0.0
189198
with:
190199
persist-credentials: false
200+
- uses: ./.github/actions/set-uv-exclude-newer
191201
- name: Install uv
192202
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
193203
with:
@@ -278,6 +288,7 @@ jobs:
278288
- uses: actions/checkout@v7.0.0
279289
with:
280290
persist-credentials: false
291+
- uses: ./.github/actions/set-uv-exclude-newer
281292
- name: Install uv
282293
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
283294
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ xunit-results/
4545
coverage.xml
4646
server.log
4747
.coverage
48+
49+
# uv lockfiles
50+
uv.lock

.pre-commit-config.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,3 @@ repos:
133133
language: python
134134
require_serial: true
135135
additional_dependencies: ["shrub.py>=3.10.0", "pyyaml>=6.0.2"]
136-
137-
- id: uv-lock
138-
name: uv-lock
139-
entry: uv lock
140-
language: python
141-
require_serial: true
142-
files: ^(uv\.lock|pyproject\.toml|requirements.txt|requirements/.*\.txt)$
143-
pass_filenames: false
144-
fail_fast: true
145-
additional_dependencies:
146-
- "uv>=0.8.4"

CONTRIBUTING.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,4 @@ From the spawn host or Ubuntu image, do the following:
566566
## Dependabot updates
567567

568568
Dependabot will raise PRs at most once per week, grouped by GitHub Actions updates and Python requirement
569-
file updates. We have a pre-commit hook that will update the `uv.lock` file when requirements change.
570-
To update the lock file on a failing PR, you can use a method like `gh pr checkout <pr number>`, then run
571-
`just lint uv-lock` to update the lock file, and then push the changes. If a typing dependency has changed,
572-
also run `just typing` and handle any new findings.
569+
file updates. If a typing dependency has changed, run `just typing` and handle any new findings.

justfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# See https://just.systems/man/en/ for instructions
22
set shell := ["bash", "-c"]
33

4+
# Don't let `uv` create or read uv.lock.
5+
export UV_NO_LOCK := "1"
6+
# Match CI's resolution window so local installs agree.
7+
# GNU date on Linux and Windows, BSD date on macOS.
8+
export UV_EXCLUDE_NEWER := `date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d`
9+
410
# Commonly used command segments.
511
typing_run := "uv run --group typing --extra aws --extra encryption --with numpy --extra ocsp --extra snappy --extra test --extra zstd"
612
docs_run := "uv run --extra docs"

0 commit comments

Comments
 (0)