From 3b7b96d4518613040796fad29a3c2482f825dee6 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 3 May 2022 15:07:38 +0200 Subject: [PATCH] Read the version string from the _version.py file --- python/pyqmckl/__init__.py | 1 + python/pyqmckl/_version.py | 1 + python/setup.py | 29 +++++++++++++++++++++-------- 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 python/pyqmckl/_version.py diff --git a/python/pyqmckl/__init__.py b/python/pyqmckl/__init__.py index 7e8cb3b..e797b17 100644 --- a/python/pyqmckl/__init__.py +++ b/python/pyqmckl/__init__.py @@ -1 +1,2 @@ from .pyqmckl import * +from ._version import __version__ diff --git a/python/pyqmckl/_version.py b/python/pyqmckl/_version.py new file mode 100644 index 0000000..d3ec452 --- /dev/null +++ b/python/pyqmckl/_version.py @@ -0,0 +1 @@ +__version__ = "0.2.0" diff --git a/python/setup.py b/python/setup.py index c3138a4..2cf89db 100644 --- a/python/setup.py +++ b/python/setup.py @@ -6,30 +6,44 @@ setup.py file for pyqmckl package from setuptools import setup, Extension from os.path import join + +# Read the long description with open("README.md", "r") as fh: long_description = fh.read() +# Read the version string from the file +VERSIONFILE = "pyqmckl/_version.py" +try: + exec(open(VERSIONFILE).read()) +except: + raise IOError("Could not open the version file %s." % (VERSIONFILE, )) + +version_r = __version__ +if not version_r: + raise RuntimeError("Unable to find a version string in %s." % (VERSIONFILE, )) + + +# Define the name of the Python package mod_name = 'pyqmckl' -# Define pyqmckl extension module based on TREXIO source codes + SWIG-generated wrapper -pyqmckl_module = Extension(name = f'{mod_name}._{mod_name}', #f'_{mod_name}', - #sources = [ join('src', mod_name + '_wrap.c') ], - sources = [ join('src', f'{mod_name}.i') ], +# Define pyqmckl extension module based on SWIG interface file (requires qmckl.h) +pyqmckl_module = Extension(name = mod_name + '._' + mod_name, + sources = [ join('src', mod_name + '_wrap.c') ], #include_dirs = [numpy_includedir], #library_dirs = [], #runtime_library_dirs = [], libraries = ['qmckl'], extra_compile_args = ['-Wall'], #extra_link_args = [h5_ldflags], - swig_opts = ['-py3'], + #swig_opts = ['-py3' , '-builtin'], depends = [ join('src', 'qmckl.h') ], language = 'c' ) setup(name = mod_name, - version = '0.2.0', + version = version_r, author = "TREX-CoE", author_email = "posenitskiy@irsamc.ups-tlse.fr", description = """Python API of the QMCkl library""", @@ -37,8 +51,7 @@ setup(name = mod_name, long_description_content_type = "text/markdown", ext_modules = [pyqmckl_module], py_modules = [mod_name], - #package_dir = {"" : "src"}, - packages = ['pyqmckl'], + packages = [mod_name], url = 'https://github.com/TREX-CoE/qmckl', license = 'BSD', classifiers=[