Files
mongo/buildscripts/poetry_lock_check.py
Zac 0f12f16e00 SERVER-107602 Move lint poetry lock to bazel run lint (#38999)
GitOrigin-RevId: 8cb267d093a5e92b07e91a6176d39f2deab41c0b
2025-07-24 18:36:23 +00:00

26 lines
970 B
Python

#!/usr/bin/env python3
"""
Check to make sure poetry.lock is synced with pyproject.toml.
Returns nonzero if poetry.lock and pyproject.toml are not synced
"""
import os
import subprocess
POETRY_LOCK_V200 = (
"""# This file is automatically @generated by Poetry 2.0.0 and should not be changed by hand."""
)
REPO_ROOT = os.environ.get("BUILD_WORKSPACE_DIRECTORY", ".")
# This has a great error message as part of the failure case
subprocess.run(["python", "-m", "poetry", "check", "--lock"], check=True, cwd=REPO_ROOT)
# Check if the poetry lock file was generated with poetry 2.0.0
with open(f"{REPO_ROOT}/poetry.lock", "r") as poetry_lock:
if POETRY_LOCK_V200 not in poetry_lock.read(len(POETRY_LOCK_V200)):
raise Exception("""Poetry lockfile was not generated by poetry 2.0.0.
Make sure to have poetry 2.0.0 installed when running poetry lock.
If you are seeing this message please follow the poetry install steps in docs/building.md.""")