grackle-project / grackle

The Grackle chemistry and cooling library for astrophysical simulations and models.
Other
26 stars 50 forks source link

Fixup query_version.py #242

Closed mabruzzo closed 1 month ago

mabruzzo commented 2 months ago

This consists of 2 commits:

  1. The first tries to modify the logic for querying git information. This is mostly an attempt to try to address an issue @ChristopherBignamini was encountering.
  2. The second commit reformats a bunch of code in order to try to satisfy flake8 (I also applied ruff format)
brittonsmith commented 2 months ago

Perhaps it would be simpler to switch to the gitpython module. For example, git rev-parse HEAD could be replaced with the following:

import git
repo = git.Repo(search_parent_directories=True)
sha = repo.head.object.hexsha
mabruzzo commented 2 months ago

Perhaps it would be simpler to switch to the gitpython module. For example, git rev-parse HEAD could be replaced with the following:

import git
repo = git.Repo(search_parent_directories=True)
sha = repo.head.object.hexsha

I'm a little hesitant to do this for the single reason that this script is run during configuration of the core Grackle c library (and I'm not sure it's a great idea to require people to manually install a python dependency to do this...). But, maybe a compromise is that we use git-python if it's available?

Honestly, I think the existing system seems fine for 99% of cases. The only reason I proposed this change was because @ChristopherBignamini mentioned that he encountered an issue about 2 weeks ago. I'm not entirely sure what his issue is, so I'm not completely sure if my change even fixes it. (But, he did mention that they encounter similar issues on that system when trying to compile other software that tries to access git during the build-process)