From b23c26c22dc1e40781d529bfad3c5c317dcf30ed Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Wed, 9 Oct 2024 23:05:17 +0200 Subject: [PATCH 1/6] Update scikit-build --- .github/workflows/check-sdist.yml | 2 +- .github/workflows/publish-sdist-wheels.yml | 16 ++-- 3rdparty/HighFive | 2 +- CMakeLists.txt | 6 +- binds/python/pybind11 | 2 +- pyproject.toml | 60 ++++++------ setup.py | 101 --------------------- tests/test_0_API.py | 2 +- 8 files changed, 46 insertions(+), 145 deletions(-) delete mode 100644 setup.py diff --git a/.github/workflows/check-sdist.yml b/.github/workflows/check-sdist.yml index 5a0b79605..08da0e2ac 100644 --- a/.github/workflows/check-sdist.yml +++ b/.github/workflows/check-sdist.yml @@ -24,7 +24,7 @@ jobs: - name: Build a source tarball run: - python setup.py sdist + python -m build --sdist - name: Test tarball run: | diff --git a/.github/workflows/publish-sdist-wheels.yml b/.github/workflows/publish-sdist-wheels.yml index 3e4ad5a24..324ae6e8c 100644 --- a/.github/workflows/publish-sdist-wheels.yml +++ b/.github/workflows/publish-sdist-wheels.yml @@ -28,10 +28,10 @@ jobs: with: submodules: 'true' - - name: Install Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 + name: Install Python 3.9 with: - python-version: '3.11' + python-version: '3.9' - name: Install cibuildwheel run: | @@ -164,14 +164,18 @@ jobs: with: submodules: 'true' - - name: Set up Python + - name: Set up Python 3.9 uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: 3.9 + + - name: Install Dependencies + run: + python -m pip install build - name: Build a source tarball run: - python setup.py sdist + python -m build --sdist - name: Test tarball run: | diff --git a/3rdparty/HighFive b/3rdparty/HighFive index 4a326f350..be68bd0ef 160000 --- a/3rdparty/HighFive +++ b/3rdparty/HighFive @@ -1 +1 @@ -Subproject commit 4a326f350d93d5847368105f840a1bd7e4094969 +Subproject commit be68bd0efcef338a016fba448d6444089fd196d5 diff --git a/CMakeLists.txt b/CMakeLists.txt index d8c99eab4..31ef60817 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) #allow using of HDF5_ROOT for building with a custom HDF5 version cmake_policy(SET CMP0074 NEW) + project(MorphIO VERSION 2.0.0) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) @@ -42,6 +43,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) if (EXTERNAL_HIGHFIVE) find_package(HighFive REQUIRED) endif() + +set(PYBIND11_NEWPYTHON ON) + if (EXTERNAL_PYBIND11) find_package(pybind11 REQUIRED CONFIG) endif() diff --git a/binds/python/pybind11 b/binds/python/pybind11 index 3e9dfa286..a2e59f0e7 160000 --- a/binds/python/pybind11 +++ b/binds/python/pybind11 @@ -1 +1 @@ -Subproject commit 3e9dfa2866941655c56877882565e7577de6fc7b +Subproject commit a2e59f0e7065404b44dfe92a28aca47ba1378dc4 diff --git a/pyproject.toml b/pyproject.toml index 7495f82e6..21e5b9d20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,8 @@ [build-system] requires = [ - "scikit-build-core", - "setuptools_scm>=8", - "cmake>=3.14", - "ninja", - "pybind11", + "scikit-build-core>=0.10,<1", + # use h5py's hdf5 install on Windows so we don't have to redistribute hdf5 + 'h5py; platform_system == "Windows"' ] build-backend = "scikit_build_core.build" @@ -25,50 +23,46 @@ classifiers = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering :: Bio-Informatics", "License :: OSI Approved :: Apache Software License v2.0", ] +keywords = [ + "computational neuroscience", + "morphology", + "neuron", + "neurolucida", + "neuromorphology", +] 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", -#) +[project.optional-dependencies] +docs = ["sphinx-bluebrain-theme"] + +[project.urls] +Homepage = "https://github.com/BlueBrain/MorphIO" +Repository = "https://github.com/BlueBrain/MorphIO.git" +Documentation = "https://morphio.readthedocs.io/" +Tracker = "https://github.com/BlueBrain/MorphIO/issues" [tool.scikit-build] -cmake.targets = ["_morphio"] +build.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', + "-DMORPHIO_TESTS=OFF", + "-DMorphIO_CXX_WARNINGS=OFF", + "-GNinja", ] #sdist.include = ["src/some_generated_file.txt"] #sdist.exclude = [".github"] +[tool.setuptools_scm] +local_scheme = "no-local-version" + [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 deleted file mode 100644 index 055f08749..000000000 --- a/setup.py +++ /dev/null @@ -1,101 +0,0 @@ -'''morphio setup.py''' -import os -import platform -import subprocess -import sys - -from setuptools import Extension, setup -from setuptools.command.build_ext import build_ext - - -class CMakeBuild(build_ext): - user_options = build_ext.user_options + [ - ("cmake-defs=", None, "Additional CMake definitions, comma split") - ] - - def initialize_options(self): - build_ext.initialize_options(self) - self.cmake_defs = None - - def run(self): - for ext in self.extensions: - self.build_extension(ext) - - def build_extension(self, ext): - extdir = os.path.abspath( - os.path.dirname(self.get_ext_fullpath(ext.name))) - cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, - '-DMORPHIO_VERSION_STRING=' + self.distribution.get_version(), - '-DMORPHIO_TESTS=OFF', - '-DPYTHON_EXECUTABLE=' + sys.executable, - '-DHIGHFIVE_EXAMPLES=OFF', - '-DHIGHFIVE_UNIT_TESTS=OFF', - ] - - if self.cmake_defs: - cmake_args += ["-D" + opt for opt in self.cmake_defs.split(",")] - - cfg = 'Debug' if self.debug else 'Release' - - build_args = ['--config', cfg] - - if "STATIC_HDF5" in os.environ: - cmake_args += ["-DHDF5_USE_STATIC_LIBRARIES=True", ] - - cmake_args += ['-DCMAKE_BUILD_TYPE={}'.format(cfg), - '-DMorphIO_CXX_WARNINGS=OFF', - '-GNinja', - ] - - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - - subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp) - subprocess.check_call(['cmake', '--build', '.', '--target', '_morphio'] + build_args, cwd=self.build_temp) - -install_requires = ['numpy>=1.14.1', - ] - -with open('README.rst', 'r', encoding='utf-8') as f: - long_description = f.read() - -if platform.system() == 'Windows': - install_requires += ['h5py>=3,<4', # use h5py's hdf5 install so we don't have to redistribute hdf5 - ] - -setup( - name='morphio', - author='Blue Brain Project, EPFL', - description='A neuron morphology IO library', - long_description=long_description, - long_description_content_type="text/x-rst", - 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=['morphio', 'morphio.mut', 'morphio.vasculature'], - license="Apache License 2.0", - keywords=['computational neuroscience', - 'morphology', - 'neuron', - 'neurolucida', - 'neuromorphology', - ], - zip_safe=False, - classifiers=[ - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "Programming Language :: Python", - "Topic :: Scientific/Engineering :: Bio-Informatics", - ], - use_scm_version=True, - setup_requires=[ - 'setuptools_scm', - ], - python_requires=">=3.8", -) diff --git a/tests/test_0_API.py b/tests/test_0_API.py index 4d12301c6..c712012bd 100644 --- a/tests/test_0_API.py +++ b/tests/test_0_API.py @@ -19,7 +19,7 @@ def test_doc_exists(): morphio.mut.Soma, ] for cls in classes: - public_methods = (method for method in dir(cls) if not method[:2] == '__') + public_methods = (method for method in dir(cls) if not method.startswith("_")) for method in public_methods: assert getattr(cls, method).__doc__, \ 'Public method {} of class {} is not documented !'.format(method, cls) From f440e916b54a3a1a40e8ad0bdde3dbda39cf97f6 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Thu, 10 Oct 2024 11:53:35 +0200 Subject: [PATCH 2/6] Fix bad rebase --- .github/workflows/publish-sdist-wheels.yml | 8 ++++---- CMakeLists.txt | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-sdist-wheels.yml b/.github/workflows/publish-sdist-wheels.yml index 324ae6e8c..33c56a5b5 100644 --- a/.github/workflows/publish-sdist-wheels.yml +++ b/.github/workflows/publish-sdist-wheels.yml @@ -29,9 +29,9 @@ jobs: submodules: 'true' - uses: actions/setup-python@v5 - name: Install Python 3.9 + name: Install Python 3.11 with: - python-version: '3.9' + python-version: '3.11' - name: Install cibuildwheel run: | @@ -164,10 +164,10 @@ jobs: with: submodules: 'true' - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: '3.10' - name: Install Dependencies run: diff --git a/CMakeLists.txt b/CMakeLists.txt index 31ef60817..40483a1f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.15) #allow using of HDF5_ROOT for building with a custom HDF5 version cmake_policy(SET CMP0074 NEW) - project(MorphIO VERSION 2.0.0) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) From 129ab2d6f332d03cacb727ba90159c454c09dc6a Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Thu, 10 Oct 2024 11:54:37 +0200 Subject: [PATCH 3/6] Swap --- .github/workflows/publish-sdist-wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-sdist-wheels.yml b/.github/workflows/publish-sdist-wheels.yml index 33c56a5b5..c8a9a455b 100644 --- a/.github/workflows/publish-sdist-wheels.yml +++ b/.github/workflows/publish-sdist-wheels.yml @@ -28,8 +28,8 @@ jobs: with: submodules: 'true' - - uses: actions/setup-python@v5 - name: Install Python 3.11 + - name: Install Python 3.11 + uses: actions/setup-python@v5 with: python-version: '3.11' From a5c5d4826d9acec6a789ce06146daa8dc61bf4bd Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Thu, 10 Oct 2024 11:55:23 +0200 Subject: [PATCH 4/6] Fix --- .github/workflows/publish-sdist-wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-sdist-wheels.yml b/.github/workflows/publish-sdist-wheels.yml index c8a9a455b..c5f6aaef4 100644 --- a/.github/workflows/publish-sdist-wheels.yml +++ b/.github/workflows/publish-sdist-wheels.yml @@ -28,7 +28,7 @@ jobs: with: submodules: 'true' - - name: Install Python 3.11 + - name: Install Python uses: actions/setup-python@v5 with: python-version: '3.11' @@ -164,7 +164,7 @@ jobs: with: submodules: 'true' - - name: Set up Python 3.10 + - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.10' From a5f8956114004c700ce580e07ef677e911d01853 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Thu, 10 Oct 2024 12:01:26 +0200 Subject: [PATCH 5/6] Fix --- .github/workflows/check-sdist.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/check-sdist.yml b/.github/workflows/check-sdist.yml index 08da0e2ac..0b4484090 100644 --- a/.github/workflows/check-sdist.yml +++ b/.github/workflows/check-sdist.yml @@ -22,6 +22,10 @@ jobs: with: python-version: '3.10' + - name: Install requirements + run: + python -m pip install build + - name: Build a source tarball run: python -m build --sdist From 5eec3643b1b28e63a64d93859d6a17284a7a377a Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Fri, 11 Oct 2024 10:12:18 +0200 Subject: [PATCH 6/6] List ignored methods explicitly --- tests/test_0_API.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_0_API.py b/tests/test_0_API.py index c712012bd..f1d8ae93d 100644 --- a/tests/test_0_API.py +++ b/tests/test_0_API.py @@ -18,8 +18,14 @@ def test_doc_exists(): morphio.mut.Section, morphio.mut.Soma, ] + ignored_methods = { + "_pybind11_conduit_v1_" + } for cls in classes: - public_methods = (method for method in dir(cls) if not method.startswith("_")) + public_methods = ( + method for method in dir(cls) + if not (method.startswith("__") or method in ignored_methods) + ) for method in public_methods: assert getattr(cls, method).__doc__, \ 'Public method {} of class {} is not documented !'.format(method, cls)