generate version.py with cmake

This commit is contained in:
mhochsteger@cerbsim.com 2022-02-04 17:49:23 +01:00
parent 1222356cf4
commit 4f4a3f7c92
4 changed files with 15 additions and 7 deletions

View File

@ -49,6 +49,15 @@ endif()
set(NETGEN_VERSION_LONG ${NETGEN_VERSION_SHORT}-${NETGEN_VERSION_TWEAK}-${NETGEN_VERSION_HASH})
if(NOT NETGEN_VERSION_GIT)
set(NETGEN_VERSION_GIT ${NETGEN_VERSION_LONG})
endif()
if(NOT NETGEN_VERSION_PYTHON)
set(NETGEN_VERSION_PYTHON ${NETGEN_VERSION_TWEAK})
endif()
set(version_file ${BDIR}/netgen_version.hpp)
set(new_version_file_string "\
#ifndef NETGEN_VERSION_HPP_INCLUDED

View File

@ -5,9 +5,12 @@ if(have_options)
endif(have_options)
configure_file(config_template.py ${CMAKE_CURRENT_BINARY_DIR}/config.py @ONLY)
configure_file(version_template.py ${CMAKE_CURRENT_BINARY_DIR}/version.py @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/config.py __main__.py __init__.py
${CMAKE_CURRENT_BINARY_DIR}/config.py
${CMAKE_CURRENT_BINARY_DIR}/version.py
__main__.py __init__.py
meshing.py csg.py geom2d.py stl.py gui.py NgOCC.py occ.py read_gmsh.py
webgui.py
DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX}

View File

@ -0,0 +1,2 @@
__version__ = "@NETGEN_VERSION_PYTHON@"
__package_name__ = "@NETGEN_PYTHON_PACKAGE_NAME@"

View File

@ -31,8 +31,6 @@ if len(version)>2:
version = version[:2]
version = '.dev'.join(version)
version_file = os.path.join(os.path.dirname(__file__), "python", "version.py")
py_install_dir = get_python_lib(1,0,'').replace('\\','/')
name = "netgen-mesher"
@ -88,10 +86,6 @@ cmake_args += [
if 'PYDIR' in os.environ:
cmake_args += [f'-DCMAKE_PREFIX_PATH={os.environ["PYDIR"]}']
with open(version_file, "w") as f:
f.write(f'__version__ = "{version}"\n')
f.write(f'__package_name__ = "{name}"\n')
setup(
name=name,
version=version,