# encoding: utf-8 # # Copyright (C) 2016-2024 Alois Schlögl # # This file is part of the BioSig repository # at https://biosig.sourceforge.io/ # # BioSig is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 3 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # #----> DO NOT EDIT setup.py <-----# # setup.py is autogenerated from setup.py.in # TODO: # windows, how to add libbiosig.dll.a and alike # https://docs.python.org/3/install/index.html#gnu-c-cygwin-mingw # https://stackoverflow.com/questions/4597228/how-to-statically-link-a-library-when-compiling-a-python-module-extension # https://stackoverflow.com/questions/67953800/linking-a-mingw-library-to-a-msvc-app-with-a-c-interface # https://stackoverflow.com/questions/2529770/how-to-use-libraries-compiled-with-mingw-in-msvc # Problem: 'extern "C" {...}' not supported by MSVC # https://learn.microsoft.com/en-us/cpp/cpp/extern-cpp?view=msvc-170 # https://learn.microsoft.com/en-us/cpp/build/reference/zc-externc?view=msvc-170 # https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170 # 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". # 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. # /permissive- /Zc:externC # not sure how to enforce this options through setup.py, cpp_args, extra_compiler_args do not work # https://pl.python.org/docs/inst/tweak-flags.html # python setup.py build --compiler=.. # https://wiki.python.org/moin/WindowsCompilers#Which_Microsoft_Visual_C.2B-.2B-_compiler_to_use_with_a_specific_Python_version_.3F # https://sqlite.org/forum/forumpost/01b9b69211 # gcc -s -O3 -m64 -I/source/bld csv.c -o csv.dll # -m64 -mdll -mthreads -Wl,-Bstatic,--nxcompat,--dynamicbase,--high-entropy-va,--image-base,0x180000000 -static-libgcc from setuptools import setup, Extension import os import numpy if os.name == 'nt': # Windows LIBS = ['biosig'] LIBDIRS = ['./lib', 'D:\\lib'] extra_compiler_args = ["/permissive-","/Zc:externC"] # does not work as expected cpp_args = ["/permissive-","/Zc:externC"] # does not work as expected os.environ['DISTUTILS_USE_SDK'] = '1' os.environ['MSSdk'] = '1' else: # *nix LIBS = ['biosig'] LIBDIRS = ['../', '../lib', './lib'] module_biosig = Extension('biosig', define_macros = [('MAJOR_VERSION', '@PACKAGE_VERSION@'[:1] ), ('MINOR_VERSION', '@PACKAGE_VERSION@'[2:3])], include_dirs = [numpy.get_include()], sources = ['biosigmodule.c'], libraries = LIBS, library_dirs = LIBDIRS, ) def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup (name = 'Biosig', version = '@PACKAGE_VERSION@', description = 'BioSig - tools for biomedical signal processing', author = 'Alois Schlögl', author_email = 'alois.schloegl@gmail.com', url = 'https://biosig.sourceforge.io', long_description=read('README.md'), long_description_content_type="text/markdown", include_package_data = True, keywords = 'EEG ECG EKG EMG EOG Polysomnography ECoG biomedical signals SCP EDF GDF HEKA CFS ABF', classifiers=[ 'Programming Language :: Python', 'Operating System :: OS Independent' ], ext_modules = [module_biosig] )