adapt setup.py
This commit is contained in:
parent
5a5e2fe59b
commit
53ec4a1276
2 changed files with 33 additions and 39 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
.eggs/
|
||||
build/
|
||||
dist/
|
||||
cnorxz.egg-info/
|
||||
*.so
|
||||
|
|
71
setup.py
71
setup.py
|
@ -1,47 +1,56 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#import numpy
|
||||
# imports:
|
||||
|
||||
import setuptools
|
||||
from distutils.core import setup, Extension
|
||||
import os
|
||||
import sysconfig
|
||||
import subprocess
|
||||
|
||||
# basic variables:
|
||||
|
||||
libname = "cnorxz"
|
||||
author = "Christian Zimmermann"
|
||||
author_email = "chizeta@f3l.de"
|
||||
path_to_cnorxz = "/home/chizeta/repos/cnorxz/install"
|
||||
expected_cnorxz_version = "1.0.0" # dummy for now; in the future this is supposed to be the c++ version which is guaranteed to be compatible with py cnorxz
|
||||
path_to_cnorxz = ""
|
||||
if 'CNORXZ' in os.environ:
|
||||
path_to_cnorxz = os.environ['CNORXZ']
|
||||
version = "0.0.0"
|
||||
have_numpy = True
|
||||
|
||||
git_hash = subprocess.run(['git','rev-parse','HEAD'],stdout=subprocess.PIPE).stdout.decode('ascii')[:-1]
|
||||
git_tags = subprocess.run(['git', 'tag', '-l', '--sort=refname', 'v*'],stdout=subprocess.PIPE).stdout.decode('ascii').split()
|
||||
# flags:
|
||||
|
||||
extra_compile_args = sysconfig.get_config_var('CFLAGS').split()
|
||||
cnorxz_version = subprocess.run([path_to_cnorxz+"/bin/cnorxz-config",'--version'],stdout=subprocess.PIPE).stdout.decode('ascii')[:-1]
|
||||
cnorxz_flags = subprocess.run([path_to_cnorxz+"/bin/cnorxz-config",'--flags'],stdout=subprocess.PIPE).stdout.decode('ascii').split()
|
||||
cnorxz_definitions = subprocess.run([path_to_cnorxz+"/bin/cnorxz-config",'--definitions'],stdout=subprocess.PIPE).stdout.decode('ascii').split()
|
||||
cnorxz_flags.remove("-Werror")
|
||||
cnorxz_flags.append("-Wno-write-strings")
|
||||
extra_compile_args += cnorxz_flags
|
||||
|
||||
# includes:
|
||||
|
||||
assert len(git_tags) != 0, "no version tags found"
|
||||
git_tag = git_tags[-1]
|
||||
version = git_tag[1:] + 'dev'
|
||||
git_hash_tag = subprocess.run(['git','rev-list','-n','1',git_tag],stdout=subprocess.PIPE).stdout.decode('ascii')[:-1]
|
||||
if git_hash_tag == git_hash and expected_cnorxz_version != cnorxz_version:
|
||||
version = git_tag[1:]
|
||||
|
||||
inc_dirs = list()
|
||||
if path_to_cnorxz != "":
|
||||
inc_dirs.append( path_to_cnorxz + "/include/cnorxz" )
|
||||
inc_dirs.append( "cnorxz/core/include" )
|
||||
#inc_dirs.append( numpy.get_include() )
|
||||
inc_dirs.append( "/home/chizeta/my_env/lib/python3.11/site-packages/numpy/core/include" )
|
||||
|
||||
|
||||
# library dirs:
|
||||
|
||||
lib_dirs = list()
|
||||
lib_dirs.append( "/usr/lib" )
|
||||
lib_dirs.append( "/usr/local/lib" )
|
||||
if path_to_cnorxz != "":
|
||||
inc_dirs.append( path_to_cnorxz + "/lib" )
|
||||
lib_dirs.append( "/home/chizeta/repos/cnorxz/install/lib" )
|
||||
lib_dirs.append( path_to_cnorxz + "/lib" )
|
||||
|
||||
extra_compile_args = sysconfig.get_config_var('CFLAGS').split()
|
||||
cnorxz_flags = subprocess.run([path_to_cnorxz+"/bin/cnorxz-config",'--flags'],stdout=subprocess.PIPE).stdout.decode('ascii').split()
|
||||
cnorxz_flags.remove("-Werror")
|
||||
cnorxz_flags.append("-Wno-write-strings")
|
||||
extra_compile_args += cnorxz_flags
|
||||
# optional dependencies:
|
||||
|
||||
if have_numpy:
|
||||
import numpy
|
||||
inc_dirs.append( numpy.get_include() )
|
||||
|
||||
# main
|
||||
|
||||
default_extension_args = dict(
|
||||
language = "c++",
|
||||
|
@ -49,6 +58,7 @@ default_extension_args = dict(
|
|||
libraries = [libname],
|
||||
library_dirs = lib_dirs,
|
||||
extra_compile_args = extra_compile_args,
|
||||
define_macros = [(mac,None) for mac in cnorxz_definitions]
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -59,21 +69,6 @@ if __name__ == "__main__":
|
|||
for d in lib_dirs:
|
||||
print("\t",d)
|
||||
|
||||
#extensions = list()
|
||||
#extensions.append(
|
||||
# setuptools.Extension(
|
||||
# #name = libname + ".core",
|
||||
# name = libname,
|
||||
# sources = [
|
||||
# "cnorxz/core/core.cpp",
|
||||
# "cnorxz/core/lib/array_wrapper.cpp"
|
||||
# ],
|
||||
# define_macros=[('HAVE_CEREAL',None)],
|
||||
# **default_extension_args
|
||||
# )
|
||||
#)
|
||||
# append further extensions (cereal, hdf5, mpi ...) here
|
||||
|
||||
setup(
|
||||
name = libname,
|
||||
packages = setuptools.find_packages(),
|
||||
|
@ -81,10 +76,8 @@ if __name__ == "__main__":
|
|||
include_dirs = inc_dirs,
|
||||
ext_modules = [Extension(
|
||||
'cnorxz', ['cnorxz/core/core.cpp','cnorxz/core/lib/array_wrapper.cpp','cnorxz/core/lib/range_wrapper.cpp'],
|
||||
define_macros=[('HAVE_CEREAL',None)],
|
||||
**default_extension_args
|
||||
)],
|
||||
#ext_modules = Cython.Build.cythonize(extensions),
|
||||
author = author,
|
||||
author_email = author_email,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue