36 lines
1.1 KiB
Python
36 lines
1.1 KiB
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 runpy
|
|
import sys
|
|
|
|
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", ".")
|
|
old_argv = sys.argv
|
|
old_cwd = os.getcwd()
|
|
try:
|
|
sys.argv = ["poetry", "check", "--lock"]
|
|
os.chdir(REPO_ROOT)
|
|
runpy.run_module("poetry", run_name="__main__")
|
|
except SystemExit as e:
|
|
if e.code not in (None, 0):
|
|
raise
|
|
finally:
|
|
sys.argv = old_argv
|
|
os.chdir(old_cwd)
|
|
|
|
# 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.""")
|