-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jose Borreguero <borreguero@gmail.com>
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 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
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,30 @@ | ||
# standard imports | ||
import logging | ||
import os | ||
import re | ||
import sys | ||
|
||
script_dir: str = os.path.dirname(os.path.realpath(__file__)) | ||
repo_dir: str = os.path.dirname(script_dir) | ||
|
||
|
||
def check_dependencies_synced(): | ||
r"""Check that the dependencies of environment.yml and requirements.txt are in sync""" | ||
|
||
conda_env = open(os.path.join(repo_dir, "environment.yml"), "r").read() | ||
reqs_env = open(os.path.join(repo_dir, "requirements.txt"), "r").read() | ||
|
||
# check for LiquidsReflectometer versions | ||
lr_conda = re.search(r'LiquidsReflectometer\.git@([^#]+)', conda_env).group(1) | ||
lr_reqs = re.search(r'LiquidsReflectometer\.git@([^#]+)', reqs_env).group(1) | ||
if lr_conda != lr_reqs: | ||
raise RuntimeError("environment.yml and requirements.txt ask different versions of LiquidsReflectometer") | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
check_dependencies_synced() | ||
except RuntimeError as e: | ||
logging.error(f"{e}") | ||
sys.exit(1) | ||
sys.exit(0) |