Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions bin/check-env-state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Script that exits 1 if the current environment is not
in sync with the `requirements-dev.lock` file.
"""

from pathlib import Path

import importlib_metadata


def should_run_sync() -> bool:
dev_lock = Path(__file__).parent.parent.joinpath("requirements-dev.lock")

for line in dev_lock.read_text().splitlines():
if not line or line.startswith("#") or line.startswith("-e"):
continue

dep, lock_version = line.split("==")

try:
version = importlib_metadata.version(dep)

if lock_version != version:
print(f"mismatch for {dep} current={version} lock={lock_version}")
return True
except Exception:
print(f"could not import {dep}")
return True

return False


def main() -> None:
if should_run_sync():
exit(1)
else:
exit(0)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ dev-dependencies = [
"time-machine",
"nox",
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",

]

Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ h11==0.14.0
httpcore==1.0.2
httpx==0.25.2
idna==3.4
importlib-metadata==7.0.0
iniconfig==2.0.0
isort==5.10.1
mypy==1.7.1
Expand All @@ -50,5 +51,6 @@ time-machine==2.9.0
tomli==2.0.1
typing-extensions==4.8.0
virtualenv==20.24.5
zipp==3.17.0
# The following packages are considered to be unsafe in a requirements file:
setuptools==68.2.2