Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change fprettify path if invoked from spack #184

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
change fprettify path if invoked from spack
  • Loading branch information
abishekg7 committed Mar 31, 2023
commit aac61bd353f6e0e427ff2a04ae3e262d7bfb3da7
5 changes: 4 additions & 1 deletion pyutils/src/icon4py/icon4pygen/bindings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def calc_num_neighbors(dim_list: list[Dimension], includes_center: bool) -> int:
def format_fortran_code(source: str) -> str:
"""Format fortran code using fprettify."""
bin_path = Path(PYTHON_PATH).parent
fprettify_path = bin_path / "fprettify"
if "spack" not in bin_path:
fprettify_path = bin_path / "fprettify"
else:
fprettify_path = "fprettify"
args = [str(fprettify_path)]
p1 = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
return p1.communicate(source.encode("UTF-8"))[0].decode("UTF-8").rstrip()