From ec9c234add32b9f57d83bbb8723ca9da7609f6bf Mon Sep 17 00:00:00 2001 From: q-posev Date: Thu, 25 May 2023 18:53:35 +0200 Subject: [PATCH] Fix pip install from sdist tarball --- python/MANIFEST.in | 1 + python/setup.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/python/MANIFEST.in b/python/MANIFEST.in index 2d44f50..6dd4749 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -4,6 +4,7 @@ include examples/notebooks/* include examples/README.md include requirements.txt tools/set_NUMPY_INCLUDEDIR.sh include test/benzene_data.py +include test/conftest.py exclude examples/LICENSE exclude examples/requirements.txt diff --git a/python/setup.py b/python/setup.py index 19c8ac5..2134e92 100644 --- a/python/setup.py +++ b/python/setup.py @@ -96,30 +96,33 @@ if h5_present: # Define pytrexio extension module based on TREXIO source codes + SWIG-generated wrapper c_files.append('pytrexio_wrap.c') +compile_args = [ + '-std=c99', + '-Wno-discarded-qualifiers', + '-Wno-unused-variable', + '-Wno-unused-but-set-variable' + ] +# if config.h is present then we are building via Autotools +if os.path.isfile(os.path.join(srcpath, "config.h")): + compile_args.append('-DHAVE_CONFIG_H') +# explicit hack needed when building from sdist tarball +if h5_present: + compile_args.append('-DHAVE_HDF5') +# define C extension module if h5_present: pytrexio_module = Extension('pytrexio._pytrexio', sources = [os.path.join(srcpath, code) for code in c_files], include_dirs = [h5_cflags, srcpath, numpy_includedir], libraries = ['hdf5' ], - extra_compile_args = [ - '-std=c99', - '-Wno-discarded-qualifiers', - '-Wno-unused-variable', - '-Wno-unused-but-set-variable' - ], + extra_compile_args = compile_args, extra_link_args = [h5_ldflags] ) else: pytrexio_module = Extension('pytrexio._pytrexio', sources = [os.path.join(srcpath, code) for code in c_files], include_dirs = [srcpath, numpy_includedir], - extra_compile_args = [ - '-std=c99', - '-Wno-discarded-qualifiers', - '-Wno-unused-variable', - '-Wno-unused-but-set-variable' - ] + extra_compile_args = compile_args )