Debian Codegraph @

biosig4c++/python/setup.py.in

raw
1 # encoding: utf-8
2 #
3 # Copyright (C) 2016-2024 Alois Schlögl <[email protected]>
4 #
5 # This file is part of the BioSig repository
6 # at https://biosig.sourceforge.io/
7 #
8 # BioSig is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 3
11 # of the License, or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #
21
22 #----> DO NOT EDIT setup.py <-----#
23 # setup.py is autogenerated from setup.py.in
24
25 # TODO:
26 # windows, how to add libbiosig.dll.a and alike
27 # https://docs.python.org/3/install/index.html#gnu-c-cygwin-mingw
28 # https://stackoverflow.com/questions/4597228/how-to-statically-link-a-library-when-compiling-a-python-module-extension
29 # https://stackoverflow.com/questions/67953800/linking-a-mingw-library-to-a-msvc-app-with-a-c-interface
30 # https://stackoverflow.com/questions/2529770/how-to-use-libraries-compiled-with-mingw-in-msvc
31 # Problem: 'extern "C" {...}' not supported by MSVC
32 # https://learn.microsoft.com/en-us/cpp/cpp/extern-cpp?view=msvc-170
33 # https://learn.microsoft.com/en-us/cpp/build/reference/zc-externc?view=msvc-170
34 # https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170
35
36 # The /Zc:externC compiler option tells the compiler to conform to the C++ standard and enforce consistent parameter declarations for functions declared as extern "C".
37
38 # The /Zc:externC option is available starting in Visual Studio 2019 version 16.3. It's off when the /permissive- option isn't set. In earlier versions of Visual Studio, and by default or if /Zc:externC- is specified, Visual Studio is permissive about matching declarations of extern "C" functions. The /permissive- option enables /Zc:externC, so it's on by default in projects that use /std:c++20 or /std:c++latest. The /Zc:externC option must come after a /permissive- option on the command line.
39
40 # /permissive- /Zc:externC
41
42 # not sure how to enforce this options through setup.py, cpp_args, extra_compiler_args do not work
43
44 # https://pl.python.org/docs/inst/tweak-flags.html
45 # python setup.py build --compiler=..
46 # https://wiki.python.org/moin/WindowsCompilers#Which_Microsoft_Visual_C.2B-.2B-_compiler_to_use_with_a_specific_Python_version_.3F
47
48 # https://sqlite.org/forum/forumpost/01b9b69211
49 # gcc -s -O3 -m64 -I/source/bld csv.c -o csv.dll
50 # -m64 -mdll -mthreads -Wl,-Bstatic,--nxcompat,--dynamicbase,--high-entropy-va,--image-base,0x180000000 -static-libgcc
51
52 from setuptools import setup, Extension
53
54 import os
55 import numpy
56
57 if os.name == 'nt':
58 # Windows
59 LIBS = ['biosig']
60 LIBDIRS = ['./lib', 'D:\\lib']
61 extra_compiler_args = ["/permissive-","/Zc:externC"] # does not work as expected
62 cpp_args = ["/permissive-","/Zc:externC"] # does not work as expected
63 os.environ['DISTUTILS_USE_SDK'] = '1'
64 os.environ['MSSdk'] = '1'
65
66 else:
67 # *nix
68 LIBS = ['biosig']
69 LIBDIRS = ['../', '../lib', './lib']
70
71 module_biosig = Extension('biosig',
72 define_macros = [('MAJOR_VERSION', '@PACKAGE_VERSION@'[:1] ), ('MINOR_VERSION', '@PACKAGE_VERSION@'[2:3])],
73 include_dirs = [numpy.get_include()],
74 sources = ['biosigmodule.c'],
75 libraries = LIBS,
76 library_dirs = LIBDIRS,
77 )
78
79 def read(fname):
80 return open(os.path.join(os.path.dirname(__file__), fname)).read()
81
82 setup (name = 'Biosig',
83 version = '@PACKAGE_VERSION@',
84 description = 'BioSig - tools for biomedical signal processing',
85 author = 'Alois Schlögl',
86 author_email = '[email protected]',
87 url = 'https://biosig.sourceforge.io',
88 long_description=read('README.md'),
89 long_description_content_type="text/markdown",
90 include_package_data = True,
91 keywords = 'EEG ECG EKG EMG EOG Polysomnography ECoG biomedical signals SCP EDF GDF HEKA CFS ABF',
92 classifiers=[
93 'Programming Language :: Python',
94 'Operating System :: OS Independent'
95 ],
96 ext_modules = [module_biosig]
97 )