Skip to content

Commit 4936fe9

Browse files
authored
PYTHON-5539 Fix installation of pymongocrypt from source (mongodb#2541)
1 parent dba0aa9 commit 4936fe9

File tree

8 files changed

+47
-21
lines changed

8 files changed

+47
-21
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/generate_config_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def generate_yaml(tasks=None, variants=None):
273273
out = ShrubService.generate_yaml(project)
274274
# Dedent by two spaces to match what we use in config.yml
275275
lines = [line[2:] for line in out.splitlines()]
276-
print("\n".join(lines)) # noqa: T201
276+
print("\n".join(lines))
277277

278278

279279
##################

.evergreen/scripts/resync-all-specs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None:
1313
"""Actually sync the specs"""
14-
print("Beginning to sync specs") # noqa: T201
14+
print("Beginning to sync specs")
1515
for spec in os.scandir(directory):
1616
if not spec.is_dir():
1717
continue
@@ -27,11 +27,11 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None:
2727
)
2828
except CalledProcessError as exc:
2929
errored[spec.name] = exc.stderr
30-
print("Done syncing specs") # noqa: T201
30+
print("Done syncing specs")
3131

3232

3333
def apply_patches():
34-
print("Beginning to apply patches") # noqa: T201
34+
print("Beginning to apply patches")
3535
subprocess.run(["bash", "./.evergreen/remove-unimplemented-tests.sh"], check=True) # noqa: S603, S607
3636
subprocess.run(
3737
["git apply -R --allow-empty --whitespace=fix ./.evergreen/spec-patch/*"], # noqa: S607
@@ -95,7 +95,7 @@ def write_summary(errored: dict[str, str], new: list[str], filename: Optional[st
9595
pr_body += "\n"
9696
if pr_body != "":
9797
if filename is None:
98-
print(f"\n{pr_body}") # noqa: T201
98+
print(f"\n{pr_body}")
9999
else:
100100
with open(filename, "w") as f:
101101
# replacements made for proper json

.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
@@ -346,7 +346,9 @@ def handle_test_env() -> None:
346346
setup_libmongocrypt()
347347

348348
# TODO: Test with 'pip install pymongocrypt'
349-
UV_ARGS.append("--group pymongocrypt_source")
349+
UV_ARGS.append(
350+
"--with pymongocrypt@git+https://github.com/mongodb/libmongocrypt@master#subdirectory=bindings/python"
351+
)
350352

351353
# Use the nocrypto build to avoid dependency issues with older windows/python versions.
352354
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",
@@ -238,6 +235,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|dummy.*)$"
238235

239236
[tool.ruff.lint.per-file-ignores]
240237
"pymongo/__init__.py" = ["E402"]
238+
".evergreen/scripts/*.py" = ["T201"]
241239
"test/*.py" = ["PT", "E402", "PLW", "SIM", "E741", "PTH", "S", "B904", "E722", "T201",
242240
"RET", "ARG", "F405", "B028", "PGH001", "B018", "F403", "RUF015", "E731", "B007",
243241
"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"

uv.lock

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)