Switch to pyproject build structure

This commit is contained in:
Anne de Jong 2023-07-14 16:40:57 +02:00
parent 2727bb5582
commit 790eb41a26
99 changed files with 97 additions and 99 deletions

View File

@ -121,7 +121,7 @@ include(portaudio)
include(uldaq)
#
add_definitions(-Dgsl_CONFIG_DEFAULTS_VERSION=1)
add_subdirectory(src/lasp)
add_subdirectory(cpp_src)
if(LASP_BUILD_CPP_TESTS)
add_subdirectory(test)
endif()

53
cpp_src/CMakeLists.txt Normal file
View File

@ -0,0 +1,53 @@
# src/lasp/CMakeLists.txt
# Armadillo, don't build the wrapper lib, but instead directly link to
# openblas.
add_definitions(-DARMA_DONT_USE_WRAPPER)
configure_file(lasp_config.h.in lasp_config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(SYSTEM
${PROJECT_SOURCE_DIR}/third_party/armadillo-code/include)
include_directories(${PROJECT_SOURCE_DIR}/third_party/DebugTrace-cpp/include)
include_directories(${PROJECT_SOURCE_DIR}/third_party/gsl-lite/include)
include_directories(${PROJECT_SOURCE_DIR}/third_party/tomlplusplus/include)
include_directories(${PROJECT_SOURCE_DIR}/third_party/thread-pool)
if(LASP_HAS_RTAUDIO)
include_directories(${PROJECT_SOURCE_DIR}/third_party/rtaudio)
endif()
if(LASP_HAS_ULDAQ)
include_directories(${PROJECT_SOURCE_DIR}/third_party/uldaq/src)
endif()
add_subdirectory(device)
add_subdirectory(dsp)
pybind11_add_module(lasp_cpp MODULE lasp_cpp.cpp
pybind11/lasp_deviceinfo.cpp
pybind11/lasp_daqconfig.cpp
pybind11//lasp_dsp_pybind.cpp
pybind11/lasp_streammgr.cpp
pybind11/lasp_daq.cpp
pybind11/lasp_deviceinfo.cpp
pybind11/lasp_pyindatahandler.cpp
pybind11/lasp_siggen.cpp
)
target_link_libraries(lasp_cpp PRIVATE lasp_device_lib lasp_dsp_lib
${OpenMP_CXX_LIBRARIES} ${LASP_FFT_LIBS} ${TARGET_OS_LINKLIBS})
# Install the Python module
install(TARGETS lasp_cpp
EXCLUDE_FROM_ALL
COMPONENT python_modules
DESTINATION ${PY_BUILD_CMAKE_MODULE_NAME})
# Install the debug file for the Python module (Windows only)
if (WIN32)
install(FILES $<TARGET_PDB_FILE:_add_module>
EXCLUDE_FROM_ALL
COMPONENT python_modules
DESTINATION ${PY_BUILD_CMAKE_MODULE_NAME}
OPTIONAL)
endif()

43
pyproject.toml Normal file
View File

@ -0,0 +1,43 @@
[project]
name = "lasp"
readme = "README.md"
requires-python = ">=3.10"
description = "Library for Acoustic Signal Processing"
license = { "file" = "LICENSE" }
authors = [{ "name" = "J.A. de Jong", "email" = "j.a.dejong@ascee.nl" }]
dynamic = ["version"]
keywords = ["DSP", "DAQ", "Signal processing"]
classifiers = [
"Development Status :: 3 - Alpha",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Topic :: Scientific/Engineering",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
]
urls = { "Documentation" = "https://lasp.ascee.nl" }
dependencies = ["scipy", "numpy", "matplotlib", "appdirs", "dataclasses_json",
"h5py", "pybind11"]
[build-system] # How pip and other frontends should build this project
requires = ["py-build-cmake~=0.1.8", "setuptools-scm"]
build-backend = "py_build_cmake.build"
[tool.py-build-cmake.module] # Where to find the Python module to package
directory = "python_src"
[tool.py-build-cmake.sdist] # What to include in source distributions
include = ["CMakeLists.txt", "cmake", "cpp_src", "python_src", "img", "scripts",
"third_party"]
[tool.py-build-cmake.cmake] # How to build the CMake project
build_type = "Release"
source_path = "."
build_args = ["-j"]
install_components = ["python_modules", "python_stubs"]

View File

@ -1,58 +0,0 @@
import glob, os
import platform
from setuptools import setup
pf = platform.platform()
if 'Linux' in pf:
ext_name_glob = 'lasp_cpp.cpython*'
# Split of path from file.
extensions = list(glob.glob('src/lasp/' + ext_name_glob))
elif 'Windows' in pf:
ext_name_glob = 'lasp_cpp*.cp*.pyd'
# Split of path from file.
extensions = list(glob.glob('src\\lasp/' + ext_name_glob))
else:
raise RuntimeError('Not yet Windows-proof')
print(extensions)
ext_names = [os.path.split(a)[1] for a in extensions]
if len(extensions) == 0:
raise RuntimeError('Please first run CMake to build extension')
elif len(extensions) > 1:
raise RuntimeError('Too many extension files found')
pkgdata = ext_names
classifiers = [
"Topic :: Scientific/Engineering",
"Programming Language :: Python :: 3.8",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
]
keywords = ["DSP", "DAQ", "Signal processing"]
setup(
name="lasp",
version="1.0",
description="LASP: Library for Acoustic Signal Processing",
author='J.A. de Jong (ASCEE / Redu-Sone)',
author_email='info@ascee.nl',
url='https://www.ascee.nl/lasp',
classifiers=classifiers,
keywords=keywords,
license="MIT",
dependencies=["numpy", "scipy", "appdirs", "h5py", "appdirs",
"dataclasses_json"],
package_dir={"": "src"},
packages=['lasp', 'lasp.filter', 'lasp.tools'],
include_package_data=True,
package_data={'lasp': pkgdata},
python_requires='>=3.8',
)

View File

@ -1,40 +0,0 @@
# src/lasp/CMakeLists.txt
# Armadillo
add_definitions(-DARMA_DONT_USE_WRAPPER)
configure_file(lasp_config.h.in lasp_config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(SYSTEM
${PROJECT_SOURCE_DIR}/third_party/armadillo-code/include)
include_directories(../../third_party/DebugTrace-cpp/include)
include_directories(../../third_party/gsl-lite/include)
include_directories(../../third_party/tomlplusplus/include)
include_directories(../../third_party/thread-pool)
if(LASP_HAS_RTAUDIO)
include_directories(../../third_party/rtaudio)
endif()
if(LASP_HAS_ULDAQ)
include_directories(../../third_party/uldaq/src)
endif()
add_subdirectory(device)
add_subdirectory(dsp)
pybind11_add_module(lasp_cpp MODULE lasp_cpp.cpp
pybind11/lasp_deviceinfo.cpp
pybind11/lasp_daqconfig.cpp
pybind11//lasp_dsp_pybind.cpp
pybind11/lasp_streammgr.cpp
pybind11/lasp_daq.cpp
pybind11/lasp_deviceinfo.cpp
pybind11/lasp_pyindatahandler.cpp
pybind11/lasp_siggen.cpp
)
target_link_libraries(lasp_cpp PRIVATE lasp_device_lib lasp_dsp_lib
${OpenMP_CXX_LIBRARIES} ${LASP_FFT_LIBS} ${TARGET_OS_LINKLIBS})
install(TARGETS lasp_cpp DESTINATION .)