Skip to content

Commit

Permalink
Fix generation of version in python code. Clean up Makefiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Nov 20, 2024
1 parent 7093cbe commit 0f5ef0f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion py/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifeq ($(PLATFORM), windows)
PY=py -
PY=py
endif
ifeq ($(PLATFORM), linux)
PY=python
Expand Down
2 changes: 0 additions & 2 deletions py/src/pycodata/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions scripts/gen_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -82,3 +85,4 @@ def run(fpath_ast: str, fpath_code: str)->None:
args = parser.parse_args()

run(args.ast, args.code)
write_version()

0 comments on commit 0f5ef0f

Please sign in to comment.