Skip to content

Commit 432d8a7

Browse files
committed
wip
1 parent 9e60168 commit 432d8a7

File tree

12 files changed

+115
-96
lines changed

12 files changed

+115
-96
lines changed

.evergreen/run-tests.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ else
2626
fi
2727

2828
# Start the test runner.
29-
uv run ${UV_ARGS} --reinstall .evergreen/scripts/run_tests.py "$@"
29+
set -x
30+
env | grep UV
31+
uv sync ${UV_ARGS}
32+
git status
33+
# uv run ${UV_ARGS} python .evergreen/scripts/run_tests.py "$@"
3034

3135
popd

.evergreen/scripts/run_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030

3131

3232
def list_packages():
33-
packages = dict()
33+
packages = set()
3434
for distribution in importlib_metadata.distributions():
35-
packages[distribution.name] = distribution
35+
packages.add(distribution.name)
3636
print("Package Version URL")
3737
print("------------------- ----------- ----------------------------------------------------")
3838
for name in sorted(packages):
39-
distribution = packages[name]
39+
distribution = importlib_metadata.distribution(name)
4040
url = ""
4141
if distribution.origin is not None:
4242
url = distribution.origin.url

.evergreen/scripts/setup_tests.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def handle_test_env() -> None:
160160

161161
write_env("PIP_QUIET") # Quiet by default.
162162
write_env("PIP_PREFER_BINARY") # Prefer binary dists by default.
163-
write_env("UV_FROZEN") # Do not modify lock files.
164163

165164
# Set an environment variable for the test name and sub test name.
166165
write_env(f"TEST_{test_name.upper()}")
@@ -236,7 +235,7 @@ def handle_test_env() -> None:
236235
if is_set("MONGODB_URI"):
237236
write_env("PYMONGO_MUST_CONNECT", "true")
238237

239-
if is_set("DISABLE_TEST_COMMANDS") or opts.disable_test_commands:
238+
if opts.disable_test_commands:
240239
write_env("PYMONGO_DISABLE_TEST_COMMANDS", "1")
241240

242241
if test_name == "enterprise_auth":
@@ -380,7 +379,7 @@ def handle_test_env() -> None:
380379
if sub_test_name == "pyopenssl":
381380
UV_ARGS.append("--extra ocsp")
382381

383-
if is_set("TEST_CRYPT_SHARED") or opts.crypt_shared:
382+
if opts.crypt_shared:
384383
config = read_env(f"{DRIVERS_TOOLS}/mo-expansion.sh")
385384
CRYPT_SHARED_DIR = Path(config["CRYPT_SHARED_LIB_PATH"]).parent.as_posix()
386385
LOGGER.info("Using crypt_shared_dir %s", CRYPT_SHARED_DIR)
@@ -450,14 +449,14 @@ def handle_test_env() -> None:
450449

451450
# Add coverage if requested.
452451
# Only cover CPython. PyPy reports suspiciously low coverage.
453-
if (is_set("COVERAGE") or opts.cov) and platform.python_implementation() == "CPython":
452+
if opts.cov and platform.python_implementation() == "CPython":
454453
# Keep in sync with combine-coverage.sh.
455454
# coverage >=5 is needed for relative_files=true.
456455
UV_ARGS.append("--group coverage")
457456
TEST_ARGS = f"{TEST_ARGS} --cov"
458457
write_env("COVERAGE")
459458

460-
if is_set("GREEN_FRAMEWORK") or opts.green_framework:
459+
if opts.green_framework:
461460
framework = opts.green_framework or os.environ["GREEN_FRAMEWORK"]
462461
UV_ARGS.append(f"--group {framework}")
463462

.evergreen/scripts/utils.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class Distro:
6060
"ocsp",
6161
]
6262

63+
# Mapping of env variables to options
64+
OPTION_TO_ENV_VAR = {"cov": "COVERAGE", "crypt_shared": "TEST_CRYPT_SHARED"}
65+
6366

6467
def get_test_options(
6568
description, require_sub_test_name=True, allow_extra_opts=False
@@ -94,6 +97,9 @@ def get_test_options(
9497
)
9598
parser.add_argument("--auth", action="store_true", help="Whether to add authentication.")
9699
parser.add_argument("--ssl", action="store_true", help="Whether to add TLS configuration.")
100+
parser.add_argument(
101+
"--test-min-deps", action="store_true", help="Test against minimum dependency versions"
102+
)
97103

98104
# Add the test modifiers.
99105
if require_sub_test_name:
@@ -121,35 +127,51 @@ def get_test_options(
121127
parser.add_argument(
122128
"--disable-test-commands", action="store_true", help="Disable test commands."
123129
)
124-
parser.add_argument(
125-
"--test-min-deps", action="store_true", help="Test against minimum dependency versions"
126-
)
127130

128131
# Get the options.
129132
if not allow_extra_opts:
130133
opts, extra_opts = parser.parse_args(), []
131134
else:
132135
opts, extra_opts = parser.parse_known_args()
133-
if opts.verbose:
134-
LOGGER.setLevel(logging.DEBUG)
135-
elif opts.quiet:
136-
LOGGER.setLevel(logging.WARNING)
137136

138137
# Handle validation and environment variable overrides.
139138
test_name = opts.test_name
140139
sub_test_name = opts.sub_test_name if require_sub_test_name else ""
141140
if require_sub_test_name and test_name in SUB_TEST_REQUIRED and not sub_test_name:
142141
raise ValueError(f"Test '{test_name}' requires a sub_test_name")
143-
if "auth" in test_name or os.environ.get("AUTH") == "auth":
142+
handle_env_overrides(opts)
143+
if "auth" in test_name:
144144
opts.auth = True
145145
# 'auth_aws ecs' shouldn't have extra auth set.
146146
if test_name == "auth_aws" and sub_test_name == "ecs":
147147
opts.auth = False
148-
if os.environ.get("SSL") == "ssl":
149-
opts.ssl = True
148+
if opts.verbose:
149+
LOGGER.setLevel(logging.DEBUG)
150+
elif opts.quiet:
151+
LOGGER.setLevel(logging.WARNING)
150152
return opts, extra_opts
151153

152154

155+
def handle_env_overrides(opts: argparse.Namespace) -> None:
156+
# Get the options, and then allow environment variable overrides.
157+
for key in vars(opts):
158+
if key in OPTION_TO_ENV_VAR:
159+
env_var = OPTION_TO_ENV_VAR[key]
160+
else:
161+
env_var = key.upper()
162+
if env_var in os.environ:
163+
if env_var == "AUTH":
164+
opts.auth = os.environ.get("AUTH") == "auth"
165+
elif env_var == "SSL":
166+
ssl_opt = os.environ.get("SSL", "")
167+
opts.ssl = ssl_opt and ssl_opt.lower() != "nossl"
168+
elif isinstance(getattr(opts, key), bool):
169+
if os.environ[env_var]:
170+
setattr(opts, key, True)
171+
else:
172+
setattr(opts, key, os.environ[env_var])
173+
174+
153175
def read_env(path: Path | str) -> dict[str, str]:
154176
config = dict()
155177
with Path(path).open() as fid:

justfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# See https://just.systems/man/en/ for instructions
22
set shell := ["bash", "-c"]
3-
# Do not modify the lock file when running justfile commands.
4-
export UV_FROZEN := "1"
53

64
# Commonly used command segments.
75
typing_run := "uv run --group typing --extra aws --extra encryption --extra ocsp --extra snappy --extra test --extra zstd"
@@ -16,7 +14,7 @@ default:
1614

1715
[private]
1816
resync:
19-
@uv sync --quiet --frozen
17+
@uv sync --quiet
2018

2119
install:
2220
bash .evergreen/scripts/setup-dev-env.sh

pyproject.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,22 @@ Tracker = "https://jira.mongodb.org/projects/PYTHON/issues"
4949
dev = [
5050
"pre-commit>=4.0"
5151
]
52-
pip = ["pip"]
53-
# TODO: PYTHON-5464
54-
gevent = ["gevent", "cffi>=2.0.0b1;python_version=='3.14'"]
55-
eventlet = ["eventlet"]
52+
pip = ["pip>23.0"]
53+
gevent = ["gevent>=20.9"]
54+
eventlet = ["eventlet>0.29"]
5655
coverage = [
57-
"pytest-cov",
56+
"pytest-cov>=2.9.0",
5857
"coverage>=5,<=7.10.6"
5958
]
6059
mockupdb = [
6160
"mockupdb@git+https://github.com/mongodb-labs/mongo-mockup-db@master"
6261
]
63-
perf = ["simplejson"]
62+
perf = ["simplejson>3.17"]
6463
typing = [
65-
"mypy==1.18.1",
64+
"mypy==1.17.1",
6665
"pyright==1.1.405",
67-
"typing_extensions",
68-
"pip"
66+
"typing_extensions>3.10",
67+
"pip>23.0"
6968
]
7069

7170
# Used to call hatch_build.py
@@ -131,6 +130,7 @@ markers = [
131130
"auth: tests that rely on authentication",
132131
"ocsp: tests that rely on ocsp",
133132
"atlas_connect: tests that rely on an atlas connection",
133+
"data_lake: tests that rely on atlas data lake",
134134
"perf: benchmark tests",
135135
"search_index: search index helper tests",
136136
"kms: client-side field-level encryption tests using kms",
@@ -235,7 +235,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|dummy.*)$"
235235

236236
[tool.ruff.lint.per-file-ignores]
237237
"pymongo/__init__.py" = ["E402"]
238-
".evergreen/scripts/*.py" = ["T201"]
238+
".evergreen/scripts/run_tests.py" = ["T201"]
239239
"test/*.py" = ["PT", "E402", "PLW", "SIM", "E741", "PTH", "S", "B904", "E722", "T201",
240240
"RET", "ARG", "F405", "B028", "PGH001", "B018", "F403", "RUF015", "E731", "B007",
241241
"UP031", "F401", "B023", "F811"]

requirements/encryption.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pymongo-auth-aws>=1.1.0,<2.0.0
22
pymongocrypt>=1.13.0,<2.0.0
3-
certifi;os.name=='nt' or sys_platform=='darwin'
3+
certifi>=2022.5.18.1;os.name=='nt' or sys_platform=='darwin'

requirements/gssapi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pykerberos;os.name!='nt'
1+
pykerberos>=1.2.4;os.name!='nt'
22
winkerberos>=0.5.0;os.name=='nt'

requirements/ocsp.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# Fallback to certifi on Windows if we can't load CA certs from the system
66
# store and just use certifi on macOS.
77
# https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths
8-
certifi;os.name=='nt' or sys_platform=='darwin'
8+
certifi>=2022.5.18.1;os.name=='nt' or sys_platform=='darwin'
99
pyopenssl>=17.2.0
10-
requests<3.0.0
10+
requests>2.23,<3.0.0
1111
cryptography>=2.5
1212
service_identity>=18.1.0

requirements/snappy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-snappy
1+
python-snappy>=0.6.0

0 commit comments

Comments
 (0)