Skip to content

Commit c606dc8

Browse files
committed
PYTHON-5539 Fix installation of pymongocrypt from source
1 parent eca38b7 commit c606dc8

File tree

6 files changed

+82
-56
lines changed

6 files changed

+82
-56
lines changed

.evergreen/run-tests.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ else
2525
exit 1
2626
fi
2727

28-
# List the packages.
29-
uv sync ${UV_ARGS} --reinstall --quiet
30-
uv pip list
31-
3228
# Start the test runner.
33-
uv run ${UV_ARGS} .evergreen/scripts/run_tests.py "$@"
29+
uv run ${UV_ARGS} --reinstall .evergreen/scripts/run_tests.py "$@"
3430

3531
popd

.evergreen/scripts/run_tests.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
from pathlib import Path
1111
from shutil import which
1212

13+
try:
14+
import importlib_metadata
15+
except ImportError:
16+
from importlib import metadata as importlib_metadata
17+
18+
1319
import pytest
1420
from utils import DRIVERS_TOOLS, LOGGER, ROOT, run_command
1521

@@ -23,6 +29,21 @@
2329
SUB_TEST_NAME = os.environ.get("SUB_TEST_NAME")
2430

2531

32+
def list_packages():
33+
packages = dict()
34+
for distribution in importlib_metadata.distributions():
35+
packages[distribution.name] = distribution
36+
print("Package Version URL")
37+
print("------------------- ----------- ----------------------------------------------------")
38+
for name in sorted(packages):
39+
distribution = packages[name]
40+
url = ""
41+
if distribution.origin is not None:
42+
url = distribution.origin.url
43+
print(f"{name:20s}{distribution.version:12s}{url}")
44+
print("------------------- ----------- ----------------------------------------------------\n")
45+
46+
2647
def handle_perf(start_time: datetime):
2748
end_time = datetime.now()
2849
elapsed_secs = (end_time - start_time).total_seconds()
@@ -121,6 +142,9 @@ def handle_aws_lambda() -> None:
121142

122143

123144
def run() -> None:
145+
# List the installed packages.
146+
list_packages()
147+
124148
# Handle green framework first so they can patch modules.
125149
if GREEN_FRAMEWORK:
126150
handle_green_framework()

.evergreen/scripts/setup_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ def handle_test_env() -> None:
356356
setup_libmongocrypt()
357357

358358
# TODO: Test with 'pip install pymongocrypt'
359-
UV_ARGS.append("--group pymongocrypt_source")
359+
UV_ARGS.append(
360+
"--with pymongocrypt@git+https://github.com/mongodb/libmongocrypt@master#subdirectory=bindings/python"
361+
)
360362

361363
# Use the nocrypto build to avoid dependency issues with older windows/python versions.
362364
BASE = ROOT / "libmongocrypt/nocrypto"

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ coverage = [
6060
mockupdb = [
6161
"mockupdb@git+https://github.com/mongodb-labs/mongo-mockup-db@master"
6262
]
63-
pymongocrypt_source = [
64-
"pymongocrypt@git+https://github.com/mongodb/libmongocrypt@master#subdirectory=bindings/python"
65-
]
6663
perf = ["simplejson"]
6764
typing = [
6865
"mypy==1.18.1",
@@ -239,6 +236,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|dummy.*)$"
239236

240237
[tool.ruff.lint.per-file-ignores]
241238
"pymongo/__init__.py" = ["E402"]
239+
".evergreen/scripts/*.py" = ["T201"]
242240
"test/*.py" = ["PT", "E402", "PLW", "SIM", "E741", "PTH", "S", "B904", "E722", "T201",
243241
"RET", "ARG", "F405", "B028", "PGH001", "B018", "F403", "RUF015", "E731", "B007",
244242
"UP031", "F401", "B023", "F811"]

requirements/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pytest>=8.2
22
pytest-asyncio>=0.24.0
3+
importlib_metadata>=7.0;python_version < "3.13"

0 commit comments

Comments
 (0)