1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
from distutils.core import setup, Extension
from distutils.command.build import build
import sys
import re
import os
compile_bindings = os.getenv("COMPILE_BINDINGS")
if sys.platform == "darwin":
libraries = []
elif sys.platform == "linux":
libraries = ['m2k', 'iio']
else:
libraries = ['${PROJECT_NAME}', 'libiio']
if compile_bindings:
long_description=""
with open("README.md", "r") as fh:
long_description = fh.read()
class CustomBuild(build):
sub_commands = [
('build_ext', build.has_ext_modules),
('build_py', build.has_pure_modules),
('build_clib', build.has_c_libraries),
('build_scripts', build.has_scripts),
]
setup(cmdclass={'build': CustomBuild},
name = '${PROJECT_NAME}',
version = '${PROJECT_VERSION}',
maintainer = "Analog Devices, Inc",
maintainer_email = "Alexandra.Trifan@analog.com",
description = """Python bindings for the C/C++ libm2k""",
long_description = long_description,
long_description_content_type="text/markdown",
url='https://github.com/analogdevicesinc/libm2k',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
],
ext_modules=[Extension('_${PROJECT_NAME}', ['${PROJECT_NAME}.i'],
swig_opts=['-c++', '-I${CMAKE_SOURCE_DIR}/include', '-outdir', '${CMAKE_BINARY_DIR}', '-module', '${PROJECT_NAME}', '${CMAKE_SWIG_FLAGS}'],
include_dirs=['${CMAKE_SOURCE_DIR}/include', '${CMAKE_SOURCE_DIR}/include/bindings/python', '${CMAKE_BINARY_DIR}/include',
'${IIO_INCLUDE_DIRS}'],
define_macros=[('HAS_CONSTEXPR', '1'),
('_EXCEPTIONS', '1'),
('_libm2k_EXPORTS', None)],
extra_compile_args=[${EXTRA_COMPILE_FLAGS}],
extra_link_args=[${EXTRA_LINK_FLAGS}],
library_dirs=['${CMAKE_BINARY_DIR}', '${IIO_LIBRARY_DIR}'],
libraries=libraries)],
py_modules = ["libm2k"],
)
else:
setup (name = '${PROJECT_NAME}',
version = '${PROJECT_VERSION}',
maintainer = "Analog Devices, Inc",
maintainer_email = "Alexandra.Trifan@analog.com",
description = """Python bindings for the C/C++ libm2k""",
url='https://github.com/analogdevicesinc/libm2k',
py_modules = ["${PROJECT_NAME}"],
packages=[''],
package_data={'': ['_${PROJECT_NAME}.so', '_${PROJECT_NAME}.pyd']},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
],
)
|