diff --git a/bin/check-env-state.py b/bin/check-env-state.py new file mode 100644 index 0000000000..e1b8b6cb39 --- /dev/null +++ b/bin/check-env-state.py @@ -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() diff --git a/pyproject.toml b/pyproject.toml index 91d3d79219..a9860b29ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,7 @@ dev-dependencies = [ "time-machine", "nox", "dirty-equals>=0.6.0", + "importlib-metadata>=6.7.0", "azure-identity >=1.14.1", "types-tqdm > 4" ] diff --git a/requirements-dev.lock b/requirements-dev.lock index 6df8805579..3e480ada33 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -11,7 +11,7 @@ annotated-types==0.6.0 anyio==4.1.0 argcomplete==3.1.2 attrs==23.1.0 -azure-core==1.29.5 +azure-core==1.29.6 azure-identity==1.15.0 black==23.3.0 certifi==2023.7.22 @@ -29,18 +29,19 @@ 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 msal==1.26.0 -msal-extensions==1.0.0 +msal-extensions==1.1.0 mypy==1.7.1 mypy-extensions==1.0.0 nodeenv==1.8.0 nox==2023.4.22 numpy==1.26.2 packaging==23.2 -pandas==2.1.3 -pandas-stubs==2.1.1.230928 +pandas==2.1.4 +pandas-stubs==2.1.4.231218 pathspec==0.11.2 platformdirs==3.11.0 pluggy==1.3.0 @@ -69,5 +70,6 @@ typing-extensions==4.8.0 tzdata==2023.3 urllib3==2.1.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