-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
19 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
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,36 @@ | ||
# Distributed under the MIT License. | ||
# See LICENSE.txt for details. | ||
|
||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import git | ||
|
||
|
||
def check_spec_import(contains_commit: Optional[str] = None): | ||
"""Check that the SpEC Python modules can be imported. | ||
Arguments: | ||
contains_commit: If specified, check that the SpEC repository contains | ||
the specified commit. This can be used as a version check to ensure | ||
that the installed SpEC version is compatible with the code that is | ||
importing it. | ||
""" | ||
try: | ||
import Utils as spec_utils | ||
except ImportError: | ||
raise ImportError( | ||
"Importing from SpEC failed. Make sure you have pointed " | ||
"'-D SPEC_ROOT' to a SpEC installation when configuring the build " | ||
"with CMake." | ||
) | ||
if contains_commit: | ||
spec_repo = git.Repo(Path(spec_utils.__file__).parent.parent.parent) | ||
try: | ||
assert spec_repo.is_ancestor(contains_commit, spec_repo.head.commit) | ||
except (AssertionError, git.exc.GitCommandError): | ||
raise ImportError( | ||
"SpEC version mismatch: requested revision" | ||
f" {contains_commit} is not in the SpEC repository at" | ||
f" {spec_repo.working_dir}." | ||
) |
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