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

[Spack] format_fortran_code set wrong path for fprettify when using preinstalled Python from upstream #194

Closed
jonasjucker opened this issue Apr 20, 2023 · 1 comment

Comments

@jonasjucker
Copy link
Contributor

def format_fortran_code(source: str) -> str:
    """Format fortran code using fprettify.

    The path to fprettify needs to be set explicitly for the
    non-Spack build process as Liskov does not activate a virtual environment.
    However, the PYTHON_PATH does not contain fprettify in a Spack build, hence the need for a special condition
    """
    bin_path = Path(PYTHON_PATH).parent
    if "spack" not in str(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()

is not correct, because PYTHONPATH points to /mch-environment/v3/linux-sles15-zen3/gcc-11.3.0/python-3.10.6-2df2crgellbveze7swvwq53xixcjle3i/bin/fprettify where fprettify does not exist.
Rather you find it in another location, since it is a separate Python module.

Why this work in case we install Python in the same build as icon4py is not known to me.

A possible solution could be to use some sort of which fprettify since it should be put in the build-env by Spack

@jonasjucker
Copy link
Contributor Author

Fixed in #191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant