Skip to content

Commit

Permalink
Merge pull request #167 from nekStab/166_update_version_from_toml
Browse files Browse the repository at this point in the history
added version update
  • Loading branch information
loiseaujc authored Feb 6, 2025
2 parents a83b74e + c0acf51 commit a3a77c5
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion deployment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import fypp
import argparse
import toml
from glob import glob


Expand All @@ -27,6 +28,25 @@ def apply_command(folder, with_qp, with_xqp, with_hp):
tool.process_file(source_file, target_file)


def replace_version(lk_file, toml_file, prefix=None):
# Get current version from toml
config = toml.load(toml_file)
version = config["version"]
# Update version in lightkrylov.fypp
with open(lk_file, "r") as file:
lines = file.readlines()
with open(lk_file, "w") as file:
for line in lines:
if "Version --" in line:
if prefix is not None:
version = prefix + ' ' + version
file.write(
f" write (*, *) \"Version -- {version}\"\n")
else:
file.write(line)
print(f"Version in {lk_file} updated to {version}.")


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Preprocess LightKrylov source files.')
Expand All @@ -38,6 +58,8 @@ def apply_command(folder, with_qp, with_xqp, with_hp):
# help="Include WITH_HP in the command")

args = parser.parse_args()
# apply_command(args.with_qp, args.with_xqp, args.with_hp)
# first update the version in LightKrylov.fypp
replace_version('src/LightKrylov.fypp', 'fpm.toml', prefix='beta')
# apply_command(args.with_qp, args.with_xqp, args.with_hp)\
apply_command("./src/", False, False, False)
apply_command("./test/", False, False, False)

0 comments on commit a3a77c5

Please sign in to comment.