Skip to content

Commit

Permalink
chore(internal): add bin script (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Dec 21, 2023
1 parent 3ad4e8b commit 99ffbda
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
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 @@ -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"
]
Expand Down
10 changes: 6 additions & 4 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 99ffbda

Please sign in to comment.