forked from openai/openai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
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 (openai#1001)
- Loading branch information
1 parent
c5fd85c
commit b71258a
Showing
3 changed files
with
47 additions
and
4 deletions.
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
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