Skip to content

Commit

Permalink
[SCons] Get git commit from environment variable
Browse files Browse the repository at this point in the history
In some build environments, particularly conda forge, we use archives of
the Cantera source code downloaded from GitHub. These archives do not
include the .git folder, so we cannot use the git CLI to retrieve the
commit information. This change reads the commit hash from the
CT_GIT_COMMIT environment variable if its set. This will allow us to
bring the output from all our packages closer together.
  • Loading branch information
bryanwweber committed Aug 19, 2024
1 parent c16cbe6 commit 50f2896
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,16 @@ cantera_version = "3.1.0a4"
cantera_pure_version = re.match(r'(\d+\.\d+\.\d+)', cantera_version).group(0)
cantera_short_version = re.match(r'(\d+\.\d+)', cantera_version).group(0)

try:
cantera_git_commit = get_command_output("git", "rev-parse", "--short", "HEAD")
cantera_git_commit = os.environ.get("CT_GIT_COMMIT")
if not cantera_git_commit:
try:
cantera_git_commit = get_command_output("git", "rev-parse", "--short", "HEAD")
logger.info(f"Building Cantera from git commit {cantera_git_commit!r}")
except (subprocess.CalledProcessError, FileNotFoundError):
cantera_git_commit = "unknown"
else:
logger.info(f"Building Cantera from git commit {cantera_git_commit!r}")
except (subprocess.CalledProcessError, FileNotFoundError):
cantera_git_commit = "unknown"


# Python Package Settings
python_min_version = parse_version("3.8")
Expand Down

0 comments on commit 50f2896

Please sign in to comment.