From 0f5ef0f0079c83d1fc5a05cab30c85a967c2afb2 Mon Sep 17 00:00:00 2001 From: Milan Skocic Date: Wed, 20 Nov 2024 17:24:38 +0100 Subject: [PATCH] Fix generation of version in python code. Clean up Makefiles. --- py/Makefile | 2 +- py/src/pycodata/Makefile | 2 -- scripts/gen_python.py | 4 ++++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/py/Makefile b/py/Makefile index fe5c95b..5bcfdca 100644 --- a/py/Makefile +++ b/py/Makefile @@ -1,5 +1,5 @@ ifeq ($(PLATFORM), windows) - PY=py - + PY=py endif ifeq ($(PLATFORM), linux) PY=python diff --git a/py/src/pycodata/Makefile b/py/src/pycodata/Makefile index 7d690e9..b0b5769 100644 --- a/py/src/pycodata/Makefile +++ b/py/src/pycodata/Makefile @@ -37,8 +37,6 @@ constants_2018.py: $(AST_DIR)/codata_2018.toml constants_2022.py: $(AST_DIR)/codata_2022.toml $(PY) $(GENPY) $< $@ -version.py: ../../VERSION - clean: rm -rf $(CPYTHON) rm -rf $(PYTHON) diff --git a/scripts/gen_python.py b/scripts/gen_python.py index 3643788..0b8d812 100644 --- a/scripts/gen_python.py +++ b/scripts/gen_python.py @@ -66,11 +66,14 @@ def run(fpath_ast: str, fpath_code: str)->None: fast.close() fcode.close() +def write_version()->None: + version = None with open("../../VERSION", "r") as f: version = f.read().strip() fobj = open('version.py', "w") + fobj.write("\"\"\"Version\"\"\"" + newline) fobj.write(f"__version__ = \"{version:s}\"") fobj.close @@ -82,3 +85,4 @@ def run(fpath_ast: str, fpath_code: str)->None: args = parser.parse_args() run(args.ast, args.code) + write_version()