From cbf941a7ddcbfca1f8363c37884a295e3930b6f2 Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Thu, 21 Dec 2023 09:57:00 +0100 Subject: [PATCH] try scikit-build-core --- CMakeLists.txt | 10 +++--- binds/python/CMakeLists.txt | 5 +-- pyproject.toml | 71 ++++++++++++++++++++++++++++++++++++- setup.py | 6 ---- src/CMakeLists.txt | 14 ++++---- 5 files changed, 85 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d6cfb043..eaedd0314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,11 +59,11 @@ install( DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install( - EXPORT MorphIOTargets - NAMESPACE MorphIO:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MorphIO - ) +#install( +# EXPORT MorphIOTargets +# NAMESPACE MorphIO:: +# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MorphIO +# ) install( FILES ${CMAKE_CURRENT_LIST_DIR}/CMake/MorphIOConfig.cmake diff --git a/binds/python/CMakeLists.txt b/binds/python/CMakeLists.txt index a9e17007f..ceca20f94 100644 --- a/binds/python/CMakeLists.txt +++ b/binds/python/CMakeLists.txt @@ -2,9 +2,8 @@ if (NOT EXTERNAL_PYBIND11) add_subdirectory(pybind11 EXCLUDE_FROM_ALL) endif() -pybind11_add_module(_morphio SYSTEM +pybind11_add_module(_morphio morphio.cpp - bind_enums.cpp bind_immutable.cpp bind_misc.cpp @@ -17,3 +16,5 @@ target_link_libraries(_morphio PRIVATE morphio_static PRIVATE pybind11::module ) + +install(TARGETS _morphio DESTINATION morphio) diff --git a/pyproject.toml b/pyproject.toml index 921cc9a81..7495f82e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,74 @@ [build-system] -requires = ["setuptools>=24.2.0", "wheel", "cmake", "ninja"] +requires = [ + "scikit-build-core", + "setuptools_scm>=8", + "cmake>=3.14", + "ninja", + "pybind11", +] +build-backend = "scikit_build_core.build" + +[project] +name = "MorphIO" +description = "A neuron morphology IO library" +readme = "README.rst" +requires-python = ">=3.8" +license = { file = "LICENSE.txt" } +authors = [ + { name = "Blue Brain Project, EPFL" }, +] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "License :: OSI Approved :: Apache Software License v2.0", +] +dynamic = ["version"] +#dependencies = [ +# "blueetl-core>=0.1.0", +#] + +[tool.setuptools_scm] +# +# install_requires=install_requires, +# extras_require={ +# 'docs': ['sphinx-bluebrain-theme'], +# }, +# url='https://github.com/BlueBrain/MorphIO/', +# ext_modules=[CMakeExtension('morphio._morphio'), +# ], +# cmdclass={'build_ext': CMakeBuild, +# }, +# packages=[], +# license="LGPLv3", +# zip_safe=False, +# use_scm_version=True, +# setup_requires=[ +# 'setuptools_scm', +# ], +# python_requires=">=3.8", +#) + +[tool.scikit-build] +cmake.targets = ["_morphio"] +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" +wheel.packages = [ 'morphio', 'morphio.mut', 'morphio.vasculature' ] +cmake.args = [ + "-DHIGHFIVE_EXAMPLES=OFF", + "-DHIGHFIVE_UNIT_TESTS=OFF", + '-DMORPHIO_TESTS=OFF', + ] +#sdist.include = ["src/some_generated_file.txt"] +#sdist.exclude = [".github"] [tool.pytest.ini_options] testpaths = ["tests"] + +#'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, +#'-DMORPHIO_VERSION_STRING=' + self.distribution.get_version(), +#'-DPYTHON_EXECUTABLE=' + sys.executable, diff --git a/setup.py b/setup.py index a1b73a165..89ec36899 100644 --- a/setup.py +++ b/setup.py @@ -8,12 +8,6 @@ from setuptools.command.build_ext import build_ext -class CMakeExtension(Extension): - def __init__(self, name, sourcedir=''): - Extension.__init__(self, name, sources=[]) - self.sourcedir = os.path.abspath(sourcedir) - - class CMakeBuild(build_ext): user_options = build_ext.user_options + [ ("cmake-defs=", None, "Additional CMake definitions, comma split") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d321d3c4f..e2a9efdf7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,10 +114,10 @@ foreach(TARGET morphio_shared morphio_static) target_link_libraries(${TARGET} PUBLIC gsl-lite PRIVATE HighFive lexertl) endforeach(TARGET) -install( - # DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - TARGETS morphio_shared - EXPORT MorphIOTargets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION include -) +#install( +# # DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +# TARGETS morphio_shared +# EXPORT MorphIOTargets +# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +# PUBLIC_HEADER DESTINATION include +#)