-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(internal): add bin script (#292)
- Loading branch information
1 parent
5e7e29e
commit c45ea92
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ dev-dependencies = [ | |
"time-machine", | ||
"nox", | ||
"dirty-equals>=0.6.0", | ||
"importlib-metadata>=6.7.0", | ||
|
||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters