From 73769db059669d7d7c8e64e3ba4f1904ae45fc86 Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Mon, 9 Nov 2026 12:32:49 -0800 Subject: [PATCH 1/9] fix(build): default MSVC Ninja builds to Release and publish an sdist A single-configuration generator now builds Release when no build type is given. The default is set before project(), where MSVC would otherwise preset the cache entry to Debug. The Windows CI checks it with a Ninja configure. publish_pypi.yml builds a source distribution, installs it in the manylinux image and uploads it after the wheels. install_prereq_win.bat no longer downloads Boost. The URL returned 404 and the 0.12.0 Windows wheels were built without it, with OME-Zarr, Arrow and DICOM present. --- .github/workflows/build_and_test_windows.yml | 7 +++ .github/workflows/publish_pypi.yml | 64 ++++++++++++++++++++ CLAUDE.md | 8 +-- CMakeLists.txt | 12 ++-- CONTRIBUTING.md | 6 +- ci-utils/install_prereq_win.bat | 18 +----- docs/source/installation.rst | 22 +++---- docs/source/supported_formats.rst | 2 +- docs/source/troubleshooting.rst | 4 +- 9 files changed, 98 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build_and_test_windows.yml b/.github/workflows/build_and_test_windows.yml index efd71f344..f6e0f784c 100644 --- a/.github/workflows/build_and_test_windows.yml +++ b/.github/workflows/build_and_test_windows.yml @@ -40,6 +40,13 @@ jobs: conda install mamba mamba install --file ${{github.workspace}}/ci-utils/envs/conda_cpp.txt + - name: Check that a Ninja configure defaults to Release + shell: bash -l {0} + run: | + set -e + cmake -S . -B build-default-type -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/Library + grep '^CMAKE_BUILD_TYPE:STRING=Release$' build-default-type/CMakeCache.txt + - name: Configure CMake run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_CLI=ON -DRUN_GTEST=ON -DALLEXTRAS=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index aef30e4d9..ba1b1a9a6 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -149,6 +149,70 @@ jobs: # Wheel build + publish jobs — each starts as soon as its prereq finishes # ============================================================ + sdist: + name: Build & publish the source distribution + runs-on: ubuntu-22.04 + # Uploaded after the wheels: pip prefers a new version's sdist over an older wheel. + needs: [prereqs_ubuntu, wheels_ubuntu, wheels_ubuntu_arm, wheels_windows, wheels_macos_intel, wheels_macos_arm64] + if: ${{ !cancelled() }} + steps: + - uses: actions/checkout@v3 + name: Check out + with: + fetch-depth: 0 + fetch-tags: true + - name: Fetch git tags + run: git fetch --force --tags + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: '3.11' + - name: Verify version detection + run: | + python -m pip install setuptools-scm + if [[ "$GITHUB_REF_NAME" == v* ]]; then + echo "Release build on tag $GITHUB_REF_NAME" + else + python ci-utils/sync_version.py + fi + python -m setuptools_scm + shell: bash + - name: Build the source distribution + run: | + python -m pip install --upgrade pip build + python -m build --sdist --outdir dist + - name: Download prereqs + uses: actions/download-artifact@v4 + with: + name: prereqs-ubuntu-22.04 + path: . + - name: Extract prereqs + run: tar -xzf prereqs.tar.gz + - name: Install from the source distribution + run: | + docker run --rm \ + -v "${{ github.workspace }}:/work" \ + -w /work \ + -e NYXUS_DEP_DIR=/work/local_install \ + -e LD_LIBRARY_PATH=/work/local_install/lib:/work/local_install/lib64 \ + quay.io/pypa/manylinux_2_28_x86_64:latest \ + bash -c " + set -e + dnf -y install llvm libevent-devel openssl-devel + python3.11 -m pip install dist/*.tar.gz + cd /tmp + python3.11 -c 'import nyxus; print(nyxus.__version__)' + " + - name: Install Dependencies + run: python -m pip install --upgrade twine requests + - name: Publish to PyPi + run: python -m twine upload dist/*.tar.gz + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} + TWINE_REPOSITORY: pypi + + wheels_ubuntu: name: Build & publish wheels (ubuntu-22.04 / ${{ matrix.cibw_build }}) runs-on: ubuntu-22.04 diff --git a/CLAUDE.md b/CLAUDE.md index e49542b1d..41a43a290 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -149,17 +149,17 @@ build cannot link them. Full-feature + CUDA build (paths below are placeholders: 2. Configure with the **Ninja** generator so `nvcc` can use `cl` as its host compiler (no CUDA MSBuild integration needed): run the Visual Studio `vcvars64.bat` first, then `cmake -S . -B build-cli -G Ninja - -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -DBUILD_CLI=ON + -DCMAKE_CXX_COMPILER=cl -DBUILD_CLI=ON -DALLEXTRAS=ON -DUSEGPU=ON -DCMAKE_PREFIX_PATH=$ENV\Library` then - `cmake --build build-cli`. With MSVC, CMake presets `Debug` for Ninja and - `--config` has no effect there, so `-DCMAKE_BUILD_TYPE=Release` is required. + `cmake --build build-cli`. Ninja builds `Release` by default; `--config` has + no effect there, so another type needs `-DCMAKE_BUILD_TYPE` at configure time. (`NYXUS_DEP_DIR` is read only as an environment variable, not as a `-D` cache variable.) 3. To run, put `$ENV\Library\bin` (dependency DLLs) and the CUDA toolkit `bin` on PATH. **Fast Python-extension build** for running the test suite (tiff-only CPU): -same as above (keep `-DCMAKE_BUILD_TYPE=Release`, which +same as above (the default `Release` type is what `CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE` below relies on) but `-DBUILD_LIB=ON -DALLEXTRAS=OFF -DUSEGPU=OFF -DPYTHON_EXECUTABLE=$ENV\python.exe -Dpybind11_DIR=$ENV\Lib\site-packages\pybind11\share\cmake\pybind11` and `--target backend`, with `-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE` pointed at diff --git a/CMakeLists.txt b/CMakeLists.txt index b5db0a27c..6d5c6f1ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.20) + +# A single-configuration generator builds Release unless told otherwise. This precedes project() +# because project() presets the cache entry to Debug under MSVC. +get_property(NYXUS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT NYXUS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE AND "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) +endif() + project(AxleNyxus) include(GNUInstallDirs) include(CheckLanguage) @@ -114,10 +122,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /EHsc /bigobj /Zc:__cplusplus") endif() -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif() - set(CMAKE_CXX_FLAGS_RELEASE "-O2") #== GTest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 581caabf5..d8839ef0b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,13 +105,13 @@ cannot link them. Run the Visual Studio `vcvars64.bat` first and configure with which also lets `nvcc` use `cl` as its host compiler for a CUDA build: ```bat -cmake -S . -B build-cli -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release ^ +cmake -S . -B build-cli -G Ninja -DCMAKE_CXX_COMPILER=cl ^ -DBUILD_CLI=ON -DALLEXTRAS=ON -DCMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library cmake --build build-cli ``` -Pass `-DCMAKE_BUILD_TYPE=Release`: with MSVC, CMake presets `Debug` for Ninja, and `--config` has -no effect on a single-configuration generator. +Ninja builds `Release` by default. To build another type, pass `-DCMAKE_BUILD_TYPE` when configuring: +`--config` has no effect on a single-configuration generator. If CMake still misses a dependency, set the environment variable `NYXUS_DEP_DIR` to the same prefix before configuring; `CMakeLists.txt` reads it from the environment, not as a `-D` option. diff --git a/ci-utils/install_prereq_win.bat b/ci-utils/install_prereq_win.bat index f7d634698..5ae1fddfc 100644 --- a/ci-utils/install_prereq_win.bat +++ b/ci-utils/install_prereq_win.bat @@ -59,21 +59,6 @@ popd popd if "%BUILD_Z5_DEP%" == "1" ( - for /l %%x in (1, 1, 5) do ( - curl -L https://archives.boost.io/release/1.79.0/source/boost_1_88_0.zip -o boost_1_88_0.zip - if exist boost_1_88_0.zip ( - goto :continue_boost - ) - ) - :continue_boost - tar -xf boost_1_88_0.zip - pushd boost_1_88_0 - call bootstrap.bat - .\b2 headers --prefix=../local_install - .\b2 -j %NUMBER_OF_PROCESSORS% variant=release link=shared runtime-link=shared threading=multi install --prefix=../local_install - xcopy /E /I /y boost ..\local_install\include\boost - popd - curl -L https://github.com/Blosc/c-blosc/archive/refs/tags/v1.21.6.zip -o v1.21.6.zip tar -xf v1.21.6.zip pushd c-blosc-1.21.6 @@ -106,7 +91,6 @@ if "%BUILD_Z5_DEP%" == "1" ( ) -set _ROOTDIR=%ROOTDIR:\=/% if "%BUILD_ARROW%" == "1" ( curl -L https://github.com/apache/arrow/archive/refs/tags/apache-arrow-20.0.0.zip -o arrow-apache-arrow-20.0.0.zip @@ -115,7 +99,7 @@ if "%BUILD_ARROW%" == "1" ( pushd cpp mkdir build pushd build - cmake .. -A x64 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX=../../../local_install/ -DCMAKE_PREFIX_PATH=%ABS_INSTALL% -DARROW_PARQUET=ON -DARROW_WITH_SNAPPY=ON -DARROW_BUILD_TESTS=OFF -DBOOST_ROOT=%_ROOTDIR%/boost_1_88_0 + cmake .. -A x64 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX=../../../local_install/ -DCMAKE_PREFIX_PATH=%ABS_INSTALL% -DARROW_PARQUET=ON -DARROW_WITH_SNAPPY=ON -DARROW_BUILD_TESTS=OFF cmake --build . --config Release --target install --parallel 4 popd popd diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 735b73491..fa4c146ed 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -36,12 +36,11 @@ The PyPI wheels are built for CPython 3.10, 3.11, 3.12 and 3.13 on these platfor * Windows x86_64; * macOS x86_64 (10.15 or newer) and arm64 (11.0 or newer). -PyPI has no source distribution, so where no wheel fits, ``pip`` falls back to an older release -without a warning, or stops with ``No matching distribution found for nyxus``: +Later releases also publish a source distribution; where no wheel fits, ``pip`` builds it, which +needs CMake, a C++20 compiler and the libraries listed in `Building from source`_. Releases up to +0.12.0 have none, so where no wheel fits, ``pip`` falls back to an older release without a warning, +or stops with ``No matching distribution found for nyxus``: -* Release 0.11.0 has no wheel for CPython 3.13 on Linux x86_64, so ``pip install nyxus`` installs - 0.10.0 there. Use Python 3.10 to 3.12, conda-forge or a source build to get 0.11.0. This is a known - issue (`#525 `__). * On Linux with a glibc older than 2.28 (for example CentOS 7 or Ubuntu 18.04), ``pip`` installs 0.8.3, the last release built for ``manylinux2014``, on x86_64 with Python 3.8 to 3.12, and an even older release with Python 3.6 or 3.7. With Python 3.13 or on aarch64 it stops with ``No @@ -82,7 +81,7 @@ output, in addition to TIFF, OME-TIFF and NIfTI. They also read OME-Zarr and com * The Windows wheels on PyPI (``nyxus`` 0.9.3 and 0.11.0, and ``nyxus-cuda12x`` 0.9.3) were built without OME-Zarr support, and so without ``.nii.gz``: they refuse OME-Zarr and fail on - ``.nii.gz`` files. This is a known issue (`#527 `__). + ``.nii.gz`` files. The ``nyxus`` 0.12.0 Windows wheels read both. * The first conda-forge Windows builds of 0.11.0 (build number 0, a build string ending in ``_0`` in ``conda list nyxus``) read none of OME-Zarr, ``.nii.gz`` and DICOM; conda installs one of them into an environment that holds ``libarrow`` 19 or 20. @@ -337,10 +336,6 @@ Getting the dependencies uses for ``.zip`` files. The script does not stop when a step fails, so check its output for errors before building. - The script's Boost download, in its OME-Zarr part, currently fails: the URL returns HTTP - 404. The Windows release wheels built with the script since 0.9.3 have no OME-Zarr support. - This is a known issue (`#527 `__). - The dependency DLLs in ``local_install\bin`` must be on ``PATH`` when you run the command-line program. Python does not search ``PATH`` for an extension module's DLLs, so in Python call ``os.add_dll_directory(r"\local_install\bin")`` before @@ -435,10 +430,9 @@ CMake options - ``OFF`` - Builds the ``bench_convex_hull`` micro-benchmark (see ``benchmarks/README.md``). * - ``CMAKE_BUILD_TYPE`` - - ``Release`` (``Debug`` with MSVC) - - Single-configuration generators build ``Release`` unless told otherwise. With MSVC, CMake - itself presets ``Debug``, so pass ``-DCMAKE_BUILD_TYPE=Release`` when you use Ninja or - NMake. This is a known defect (`#524 `__). + - ``Release`` + - Single-configuration generators, such as Ninja and NMake, build ``Release`` unless told + otherwise. The C++ standard is C++20 and is required (``CMAKE_CXX_STANDARD 20``). On MSVC the build adds ``/permissive- /EHsc /bigobj /Zc:__cplusplus``. diff --git a/docs/source/supported_formats.rst b/docs/source/supported_formats.rst index 90708f666..e890b7a7c 100644 --- a/docs/source/supported_formats.rst +++ b/docs/source/supported_formats.rst @@ -37,7 +37,7 @@ run with that error. OME-Zarr and DICOM support are optional parts of a source build (see the CMake options in :doc:`installation`). The PyPI and conda packages include both, except that the Windows wheels -on PyPI have no OME-Zarr support since 0.9.3, and the first conda-forge Windows builds of +on PyPI of 0.9.3 and 0.11.0 have no OME-Zarr support, and the first conda-forge Windows builds of 0.11.0 (build number 0) have neither. Reading ``.nii.gz`` needs zlib, which a build includes together with OME-Zarr support, so those packages do not read ``.nii.gz`` either. diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index f1591509c..7cf4bc228 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -150,8 +150,8 @@ A build without an optional part refuses its files or outputs: available. Please install Nyxus with Arrow enabled to use this functionality.`` and the call raises ``RuntimeError``. -The PyPI and conda packages include all of them, except that the Windows wheels on PyPI have no -OME-Zarr support since 0.9.3 (see :doc:`installation`). The first conda-forge Windows builds of +The PyPI and conda packages include all of them, except that the Windows wheels on PyPI of 0.9.3 +and 0.11.0 have no OME-Zarr support (see :doc:`installation`). The first conda-forge Windows builds of 0.11.0 (build number 0) also lack OME-Zarr, ``.nii.gz`` and DICOM; conda installs one of them into an environment that holds ``libarrow`` 19 or 20. :ref:`installation-check` shows how to check a build. From 717e111c8f826bba0d538c325b738439fbc41645 Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Mon, 9 Nov 2026 12:58:00 -0800 Subject: [PATCH 2/9] fix(ci): publish the sdist only beside a full wheel grid The wheel jobs are continue-on-error, so the sdist job ran and uploaded whatever they produced. Since pip prefers a new version's sdist over an older wheel, a missing wheel would have turned into a source build. ci-utils/check_wheel_grid.py now compares PyPI's files with the 20-wheel grid and stops the upload when a cell is absent. The release and PR wheel builds pass the new REQUIRE_ALLEXTRAS option, which fails the configure when OME-Zarr, Arrow or DICOM support would be dropped. The Release default also applies on CMake 3.20 and 3.21 when CMAKE_BUILD_TYPE is set in the environment, since those versions ignore that variable. The Windows CI checks this and the REQUIRE_ALLEXTRAS refusal with real configures. --- .github/workflows/build_and_test_windows.yml | 19 +++ .github/workflows/build_wheels.yml | 8 +- .github/workflows/publish_pypi.yml | 16 ++- CMakeLists.txt | 20 ++- ci-utils/check_wheel_grid.py | 83 +++++++++++ docs/source/installation.rst | 5 + .../test_release_wheel_grid_mechanics.py | 129 ++++++++++++++++++ tests/vetting/check_test_names.py | 1 + 8 files changed, 270 insertions(+), 11 deletions(-) create mode 100644 ci-utils/check_wheel_grid.py create mode 100644 tests/python/test_release_wheel_grid_mechanics.py diff --git a/.github/workflows/build_and_test_windows.yml b/.github/workflows/build_and_test_windows.yml index f6e0f784c..ad49dbb9d 100644 --- a/.github/workflows/build_and_test_windows.yml +++ b/.github/workflows/build_and_test_windows.yml @@ -47,6 +47,25 @@ jobs: cmake -S . -B build-default-type -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/Library grep '^CMAKE_BUILD_TYPE:STRING=Release$' build-default-type/CMakeCache.txt + - name: Check that CMake older than 3.22 ignores a build type in the environment + shell: bash -l {0} + run: | + set -e + python -m pip install --target "$RUNNER_TEMP/cmake-3.21" cmake==3.21.4 + CMAKE_BUILD_TYPE=RelWithDebInfo "$RUNNER_TEMP/cmake-3.21/cmake/data/bin/cmake" -S . -B build-old-cmake -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/Library + grep '^CMAKE_BUILD_TYPE:STRING=Release$' build-old-cmake/CMakeCache.txt + + - name: Check that REQUIRE_ALLEXTRAS refuses a dropped part + shell: bash -l {0} + run: | + set -e + if cmake -S . -B build-required-extras -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/Library -DALLEXTRAS=ON -DREQUIRE_ALLEXTRAS=ON -DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON > required-extras.log 2>&1; then + cat required-extras.log + exit 1 + fi + cat required-extras.log + grep 'these parts are off: USE_ARROW' required-extras.log + - name: Configure CMake run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_CLI=ON -DRUN_GTEST=ON -DALLEXTRAS=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 031579256..7f2a2e08f 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -385,6 +385,7 @@ jobs: CIBW_ENVIRONMENT_LINUX: > LD_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64:$LD_LIBRARY_PATH" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" + CMAKE_ARGS="-DREQUIRE_ALLEXTRAS=ON" CIBW_ARCHS: auto64 CIBW_TEST_REQUIRES: numpy pandas pyarrow pytest bfio imagecodecs CIBW_TEST_COMMAND: pytest -vv {project}/tests/python @@ -448,6 +449,7 @@ jobs: CIBW_ENVIRONMENT_LINUX: > LD_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64:$LD_LIBRARY_PATH" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" + CMAKE_ARGS="-DREQUIRE_ALLEXTRAS=ON" CIBW_ARCHS: auto64 CIBW_TEST_REQUIRES: numpy pandas pyarrow pytest bfio imagecodecs CIBW_TEST_COMMAND: pytest -vv {project}/tests/python @@ -506,7 +508,7 @@ jobs: CIBW_BUILD: ${{ matrix.cibw_build }}-* CIBW_BUILD_VERBOSITY: 3 CIBW_BEFORE_ALL_WINDOWS: xcopy /E /I /y local_install C:\TEMP\nyxus_bld\local_install - CIBW_ENVIRONMENT_WINDOWS: PATH="C:\\TEMP\\nyxus_bld\\local_install\\bin;$PATH" NYXUS_DEP_DIR="C:\\TEMP\\nyxus_bld\\local_install" + CIBW_ENVIRONMENT_WINDOWS: PATH="C:\\TEMP\\nyxus_bld\\local_install\\bin;$PATH" NYXUS_DEP_DIR="C:\\TEMP\\nyxus_bld\\local_install" CMAKE_ARGS="-DREQUIRE_ALLEXTRAS=ON" CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" CIBW_ARCHS: auto64 CIBW_TEST_REQUIRES: numpy pandas pyarrow pytest bfio imagecodecs @@ -579,7 +581,7 @@ jobs: LDFLAGS="-isysroot $SDKROOT -lc++ -lc++abi -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" PIP_ONLY_BINARY="imagecodecs" ARROW_HAVE_LIBATOMIC=OFF - CMAKE_ARGS="-DUSE_STATIC_ARROW=ON" + CMAKE_ARGS="-DUSE_STATIC_ARROW=ON -DREQUIRE_ALLEXTRAS=ON" REPAIR_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" CIBW_REPAIR_WHEEL_COMMAND_MACOS: | @@ -655,7 +657,7 @@ jobs: CMAKE_C_COMPILER="$CC" CMAKE_CXX_COMPILER="$CXX" CXXFLAGS="-isysroot $SDKROOT -stdlib=libc++" LDFLAGS="-isysroot $SDKROOT -lc++ -lc++abi" - CMAKE_ARGS="-DUSE_STATIC_ARROW=ON" + CMAKE_ARGS="-DUSE_STATIC_ARROW=ON -DREQUIRE_ALLEXTRAS=ON" REPAIR_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" CIBW_REPAIR_WHEEL_COMMAND_MACOS: | diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index ba1b1a9a6..744fcc573 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -152,7 +152,8 @@ jobs: sdist: name: Build & publish the source distribution runs-on: ubuntu-22.04 - # Uploaded after the wheels: pip prefers a new version's sdist over an older wheel. + # Uploaded after the wheels, and only beside all of them: pip prefers a new version's sdist + # over an older wheel. needs: [prereqs_ubuntu, wheels_ubuntu, wheels_ubuntu_arm, wheels_windows, wheels_macos_intel, wheels_macos_arm64] if: ${{ !cancelled() }} steps: @@ -195,6 +196,7 @@ jobs: -w /work \ -e NYXUS_DEP_DIR=/work/local_install \ -e LD_LIBRARY_PATH=/work/local_install/lib:/work/local_install/lib64 \ + -e CMAKE_ARGS=-DREQUIRE_ALLEXTRAS=ON \ quay.io/pypa/manylinux_2_28_x86_64:latest \ bash -c " set -e @@ -203,6 +205,8 @@ jobs: cd /tmp python3.11 -c 'import nyxus; print(nyxus.__version__)' " + - name: Check that PyPI holds every wheel of this release + run: python ci-utils/check_wheel_grid.py dist/*.tar.gz - name: Install Dependencies run: python -m pip install --upgrade twine requests - name: Publish to PyPi @@ -267,7 +271,7 @@ jobs: CIBW_BEFORE_ALL_LINUX: dnf -y install llvm libevent-devel openssl-devel && mkdir -p /tmp/nyxus_bld && cp -a local_install /tmp/nyxus_bld - CIBW_ENVIRONMENT_LINUX: LD_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64:$LD_LIBRARY_PATH" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" + CIBW_ENVIRONMENT_LINUX: LD_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64:$LD_LIBRARY_PATH" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" CMAKE_ARGS="-DREQUIRE_ALLEXTRAS=ON" CIBW_ARCHS: ${{ matrix.cibw_archs }} CIBW_TEST_REQUIRES: numpy pandas pyarrow pytest bfio imagecodecs CIBW_TEST_COMMAND: pytest {project}/tests/python @@ -335,7 +339,7 @@ jobs: CIBW_BEFORE_ALL_LINUX: dnf -y install llvm libevent-devel openssl-devel && mkdir -p /tmp/nyxus_bld && cp -a local_install /tmp/nyxus_bld - CIBW_ENVIRONMENT_LINUX: LD_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64:$LD_LIBRARY_PATH" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" + CIBW_ENVIRONMENT_LINUX: LD_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64:$LD_LIBRARY_PATH" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" CMAKE_ARGS="-DREQUIRE_ALLEXTRAS=ON" CIBW_ARCHS: ${{ matrix.cibw_archs }} CIBW_TEST_REQUIRES: numpy pandas pyarrow pytest bfio imagecodecs CIBW_TEST_COMMAND: pytest {project}/tests/python @@ -399,7 +403,7 @@ jobs: CIBW_BUILD: ${{ matrix.cibw_build }} CIBW_BUILD_VERBOSITY: 3 CIBW_BEFORE_ALL_WINDOWS: xcopy /E /I /y local_install C:\TEMP\nyxus_bld\local_install - CIBW_ENVIRONMENT_WINDOWS: PATH="C:\\TEMP\\nyxus_bld\\local_install\\bin;$PATH" NYXUS_DEP_DIR="C:\\TEMP\\nyxus_bld\\local_install" + CIBW_ENVIRONMENT_WINDOWS: PATH="C:\\TEMP\\nyxus_bld\\local_install\\bin;$PATH" NYXUS_DEP_DIR="C:\\TEMP\\nyxus_bld\\local_install" CMAKE_ARGS="-DREQUIRE_ALLEXTRAS=ON" CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" CIBW_ARCHS: ${{ matrix.cibw_archs }} CIBW_TEST_REQUIRES: numpy pandas pyarrow pytest bfio imagecodecs @@ -480,7 +484,7 @@ jobs: LDFLAGS="-isysroot $SDKROOT -lc++ -lc++abi -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" PIP_ONLY_BINARY="imagecodecs" ARROW_HAVE_LIBATOMIC=OFF - CMAKE_ARGS="-DUSE_STATIC_ARROW=ON" + CMAKE_ARGS="-DUSE_STATIC_ARROW=ON -DREQUIRE_ALLEXTRAS=ON" REPAIR_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" CIBW_REPAIR_WHEEL_COMMAND_MACOS: | @@ -567,7 +571,7 @@ jobs: CXXFLAGS="-isysroot $SDKROOT -stdlib=libc++ -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" LDFLAGS="-isysroot $SDKROOT -lc++ -lc++abi -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" ARROW_HAVE_LIBATOMIC=OFF - CMAKE_ARGS="-DUSE_STATIC_ARROW=ON" + CMAKE_ARGS="-DUSE_STATIC_ARROW=ON -DREQUIRE_ALLEXTRAS=ON" REPAIR_LIBRARY_PATH="/tmp/nyxus_bld/local_install/lib:/tmp/nyxus_bld/local_install/lib64" NYXUS_DEP_DIR="/tmp/nyxus_bld/local_install" CIBW_REPAIR_WHEEL_COMMAND_MACOS: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d5c6f1ed..3f041f05b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_minimum_required(VERSION 3.20) # A single-configuration generator builds Release unless told otherwise. This precedes project() -# because project() presets the cache entry to Debug under MSVC. +# because project() presets the cache entry to Debug under MSVC. CMake 3.22 and newer take a type +# from the CMAKE_BUILD_TYPE environment variable; older versions ignore that variable. get_property(NYXUS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(NOT NYXUS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE AND "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "") +if(NOT NYXUS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE AND ("$ENV{CMAKE_BUILD_TYPE}" STREQUAL "" OR CMAKE_VERSION VERSION_LESS 3.22)) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) endif() @@ -26,6 +27,7 @@ option(USE_ARROW "Use Arrow" OFF) option(USE_STATIC_ARROW "Link Arrow/Parquet statically and keep their symbols private (macOS)" OFF) option(ALLEXTRAS "Building with all I/O support" OFF) option(NOEXTRAS "Building with Only Tiff and Pybind11(For Python package)" ON) +option(REQUIRE_ALLEXTRAS "Fail the configure when an ALLEXTRAS part is unavailable" OFF) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules") @@ -506,6 +508,20 @@ message(STATUS "Z5 | ${Z5_REQUESTED} | ${USE_Z5}") message(STATUS "Arrow | ${ARROW_REQUESTED} | ${USE_ARROW}") message(STATUS "Dicom | ${DCMTK_REQUESTED} | ${USE_DCMTK}") message(STATUS "CUDA | ${CUDA_REQUESTED} | ${USEGPU}") + +# Release wheels set this, so that none of them can ship without a file format. +if(REQUIRE_ALLEXTRAS) + set(NYXUS_PARTS_OFF "") + foreach(part USE_Z5 USE_ARROW USE_DCMTK) + if(NOT ${part}) + list(APPEND NYXUS_PARTS_OFF ${part}) + endif() + endforeach() + if(NYXUS_PARTS_OFF) + message(FATAL_ERROR "REQUIRE_ALLEXTRAS is set and these parts are off: ${NYXUS_PARTS_OFF}") + endif() +endif() + ## Running Tests if (RUN_GTEST) # Download and unpack googletest at configure time diff --git a/ci-utils/check_wheel_grid.py b/ci-utils/check_wheel_grid.py new file mode 100644 index 000000000..18ee8ef25 --- /dev/null +++ b/ci-utils/check_wheel_grid.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +"""Check that PyPI holds every wheel of a release. + +pip prefers a new version's source distribution over an older wheel, so publish_pypi.yml uploads +the source distribution only when this check passes. Usage: check_wheel_grid.py +""" +import argparse +import fnmatch +import json +import re +import sys +import time +import urllib.error +import urllib.request +from pathlib import Path + +PYTHONS = ("cp310", "cp311", "cp312", "cp313") +PLATFORMS = { + "Linux x86_64": "manylinux_*_x86_64", + "Linux aarch64": "manylinux_*_aarch64", + "Windows x86_64": "win_amd64", + "macOS x86_64": "macosx_*_x86_64", + "macOS arm64": "macosx_*_arm64", +} + + +def missing_wheels(filenames, version): + """Name the Python and platform cells of the grid that no file of this version covers.""" + present = set() + for filename in filenames: + if not filename.endswith(".whl"): + continue + parts = filename[: -len(".whl")].split("-") + if len(parts) != 5 or parts[1] != version: + continue + for tag in parts[4].split("."): + for label, pattern in PLATFORMS.items(): + if fnmatch.fnmatchcase(tag, pattern): + present.add((parts[2], label)) + return [python + " " + label for python in PYTHONS for label in PLATFORMS if (python, label) not in present] + + +def version_of_sdist(path): + match = re.fullmatch(r"nyxus-(.+)\.tar\.gz", Path(path).name) + if match is None: + raise SystemExit(f"'{path}' is not a nyxus source distribution.") + return match.group(1) + + +def fetch_filenames(version): + """List the files PyPI holds for this version; a version PyPI does not know has none.""" + try: + with urllib.request.urlopen(f"https://pypi.org/pypi/nyxus/{version}/json", timeout=60) as response: + return [entry["filename"] for entry in json.load(response)["urls"]] + except urllib.error.HTTPError as exc: + if exc.code == 404: + return [] + raise + + +def main(argv=None): + parser = argparse.ArgumentParser(description="Check that PyPI holds every wheel of a release.") + parser.add_argument("sdist", help="Path of the source distribution about to be uploaded.") + # PyPI's JSON API can trail an upload by a few minutes. + parser.add_argument("--attempts", type=int, default=6) + parser.add_argument("--delay", type=float, default=30.0, help="Seconds between attempts.") + args = parser.parse_args(argv) + + version = version_of_sdist(args.sdist) + for attempt in range(1, args.attempts + 1): + missing = missing_wheels(fetch_filenames(version), version) + if not missing: + print(f"PyPI holds all {len(PYTHONS) * len(PLATFORMS)} wheels of nyxus {version}.") + return 0 + print(f"Attempt {attempt}/{args.attempts}: nyxus {version} lacks {len(missing)} wheels.") + if attempt < args.attempts: + time.sleep(args.delay) + print(f"nyxus {version} is missing these wheels on PyPI: " + ", ".join(missing), file=sys.stderr) + return 1 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index fa4c146ed..3ce4f0fde 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -398,6 +398,11 @@ CMake options - ``OFF`` - Turns ``USE_Z5``, ``USE_DCMTK`` and ``USE_ARROW`` on. It takes precedence over ``NOEXTRAS``. ``setup.py`` always passes it. + * - ``REQUIRE_ALLEXTRAS`` + - ``OFF`` + - Stops the configure with an error when ``USE_Z5``, ``USE_DCMTK`` or ``USE_ARROW`` is off. + Without it, a part whose libraries are missing is dropped with a warning. The PyPI wheels + are built with it. * - ``USE_Z5`` - ``OFF`` - OME-Zarr input. Also enables compressed NIfTI (``.nii.gz``), which needs the zlib that this diff --git a/tests/python/test_release_wheel_grid_mechanics.py b/tests/python/test_release_wheel_grid_mechanics.py new file mode 100644 index 000000000..60bb6fef7 --- /dev/null +++ b/tests/python/test_release_wheel_grid_mechanics.py @@ -0,0 +1,129 @@ +"""A release's source distribution reaches PyPI only beside its full wheel grid. + +pip prefers a new version's source distribution over an older wheel, so a platform whose wheel +is missing would attempt a source build. ci-utils/check_wheel_grid.py compares PyPI's file list +with the grid publish_pypi.yml builds, and the release wheels are configured so that a dropped +ALLEXTRAS part fails the build. +""" +import importlib.util +import pathlib +import re + +import pytest + +REPO = pathlib.Path(__file__).resolve().parent.parent.parent +VERSION = "1.2.3" +PLATFORM_TAGS = ( + "manylinux_2_28_x86_64", + "manylinux_2_28_aarch64", + "win_amd64", + "macosx_10_15_x86_64", + "macosx_11_0_arm64", +) +PYTHONS = ("cp310", "cp311", "cp312", "cp313") + + +def _grid(): + spec = importlib.util.spec_from_file_location("check_wheel_grid", REPO / "ci-utils" / "check_wheel_grid.py") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def _wheel(python, tag, version=VERSION): + return "nyxus-" + version + "-" + python + "-" + python + "-" + tag + ".whl" + + +def _complete(version=VERSION): + return [_wheel(python, tag, version) for python in PYTHONS for tag in PLATFORM_TAGS] + + +def _jobs(workflow): + """Split a workflow into its jobs, keyed by job id.""" + text = (REPO / ".github" / "workflows" / workflow).read_text(encoding="utf-8") + body = text[text.index("\njobs:\n"):] + parts = re.split(r"^ ([A-Za-z0-9_-]+):\n", body, flags=re.M) + return dict(zip(parts[1::2], parts[2::2])) + + +def _wheel_jobs(workflow): + return {name: job for name, job in _jobs(workflow).items() if "cibuildwheel --output-dir" in job} + + +def test_complete_grid_has_nothing_missing_mechanics(): + assert len(_complete()) == 20 + assert _grid().missing_wheels(_complete(), VERSION) == [] + + +def test_release_without_macos_arm64_is_reported_mechanics(): + # the file set of nyxus 0.12.0: every cell but macOS arm64 + files = [name for name in _complete("0.12.0") if "arm64" not in name] + assert len(files) == 16 + assert _grid().missing_wheels(files, "0.12.0") == [python + " macOS arm64" for python in PYTHONS] + + +def test_single_missing_cell_is_named_mechanics(): + # the file set of nyxus 0.11.0: 19 wheels, one Linux x86_64 cell absent + files = [name for name in _complete() if name != _wheel("cp313", "manylinux_2_28_x86_64")] + assert _grid().missing_wheels(files, VERSION) == ["cp313 Linux x86_64"] + + +def test_compound_platform_tag_covers_its_cell_mechanics(): + files = [name for name in _complete() if name != _wheel("cp312", "manylinux_2_28_x86_64")] + files.append(_wheel("cp312", "manylinux2014_x86_64.manylinux_2_28_x86_64")) + assert _grid().missing_wheels(files, VERSION) == [] + + +def test_other_versions_and_sdists_cover_no_cell_mechanics(): + files = _complete("1.2.2") + ["nyxus-" + VERSION + ".tar.gz"] + assert len(_grid().missing_wheels(files, VERSION)) == 20 + + +def test_sdist_name_gives_the_version_mechanics(): + assert _grid().version_of_sdist("dist/nyxus-0.13.0.post2.dev5.tar.gz") == "0.13.0.post2.dev5" + + +def test_foreign_sdist_name_refused_mechanics(): + with pytest.raises(SystemExit): + _grid().version_of_sdist("dist/other-1.2.3.tar.gz") + + +def test_incomplete_grid_exits_nonzero_and_names_the_cells_mechanics(monkeypatch, capsys): + grid = _grid() + files = [name for name in _complete() if "arm64" not in name] + monkeypatch.setattr(grid, "fetch_filenames", lambda version: files) + assert grid.main(["dist/nyxus-" + VERSION + ".tar.gz", "--attempts", "2", "--delay", "0"]) == 1 + assert "cp310 macOS arm64" in capsys.readouterr().err + + +def test_grid_appearing_between_attempts_passes_mechanics(monkeypatch): + grid = _grid() + answers = iter([[], _complete()]) + monkeypatch.setattr(grid, "fetch_filenames", lambda version: next(answers)) + assert grid.main(["dist/nyxus-" + VERSION + ".tar.gz", "--attempts", "2", "--delay", "0"]) == 0 + + +def test_grid_check_precedes_the_sdist_upload_mechanics(): + job = _jobs("publish_pypi.yml")["sdist"] + check = job.index("ci-utils/check_wheel_grid.py dist/*.tar.gz") + assert check < job.index("twine upload dist/*.tar.gz") + + +def test_sdist_job_waits_for_every_wheel_job_mechanics(): + needs = re.search(r"^ needs: \[(.*)\]$", _jobs("publish_pypi.yml")["sdist"], re.M).group(1) + needed = {name.strip() for name in needs.split(",")} + assert set(_wheel_jobs("publish_pypi.yml")) <= needed + + +def test_grid_matches_the_wheel_jobs_pythons_mechanics(): + for name, job in _wheel_jobs("publish_pypi.yml").items(): + built = tuple(re.findall(r'"(cp3\d+)-\*"', job)) + assert built == _grid().PYTHONS, name + + +@pytest.mark.parametrize("workflow", ["publish_pypi.yml", "build_wheels.yml"]) +def test_wheel_builds_refuse_a_dropped_extra_mechanics(workflow): + jobs = _wheel_jobs(workflow) + assert len(jobs) == 5 + for name, job in jobs.items(): + assert "-DREQUIRE_ALLEXTRAS=ON" in job, workflow + ": " + name diff --git a/tests/vetting/check_test_names.py b/tests/vetting/check_test_names.py index 2e2de659c..1e71b5b35 100644 --- a/tests/vetting/check_test_names.py +++ b/tests/vetting/check_test_names.py @@ -106,6 +106,7 @@ "test_docs_cli_reference_mechanics.py": "the CLI reference generator's checks; no image is read", "test_docs_conf_mechanics.py": "the Sphinx configuration's release and title; no image is read", "test_release_tag_mechanics.py": "the release tag's name and the release tooling that reads it; no image is read", + "test_release_wheel_grid_mechanics.py": "the release's wheel grid and the workflows that build it; no image is read", "test_docs_feature_reference_mechanics.py": "the feature reference generator's checks; no image is read", "test_ooc_mechanics.py": "out-of-core streaming machinery, asserted for both dims at once", "test_physical_calibration_regression.py": "physical voxel spacing read from OME metadata, not from an image of either dimension", From 0c98cf671fbcd012dc717d2639fa755f17cbb8f2 Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Tue, 10 Nov 2026 08:40:48 -0800 Subject: [PATCH 3/9] docs: say which releases carry an sdist and which wheels require all extras A release publishes its source distribution only once all its wheels are on PyPI, so a release with a missing wheel has none. REQUIRE_ALLEXTRAS is passed by the nyxus wheel builds, not by the nyxus-cuda11x and nyxus-cuda12x ones. --- docs/source/installation.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 3ce4f0fde..d5afe5223 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -36,10 +36,10 @@ The PyPI wheels are built for CPython 3.10, 3.11, 3.12 and 3.13 on these platfor * Windows x86_64; * macOS x86_64 (10.15 or newer) and arm64 (11.0 or newer). -Later releases also publish a source distribution; where no wheel fits, ``pip`` builds it, which -needs CMake, a C++20 compiler and the libraries listed in `Building from source`_. Releases up to -0.12.0 have none, so where no wheel fits, ``pip`` falls back to an older release without a warning, -or stops with ``No matching distribution found for nyxus``: +Later releases also publish a source distribution once all their wheels are on PyPI; where no +wheel fits, ``pip`` builds it, which needs CMake, a C++20 compiler and the libraries listed in +`Building from source`_. Releases up to 0.12.0, and a release with a wheel missing, have none, so +where no wheel fits, ``pip`` falls back to an older release without a warning, or stops with ``No matching distribution found for nyxus``: * On Linux with a glibc older than 2.28 (for example CentOS 7 or Ubuntu 18.04), ``pip`` installs 0.8.3, the last release built for ``manylinux2014``, on x86_64 with Python 3.8 to 3.12, and an @@ -401,8 +401,8 @@ CMake options * - ``REQUIRE_ALLEXTRAS`` - ``OFF`` - Stops the configure with an error when ``USE_Z5``, ``USE_DCMTK`` or ``USE_ARROW`` is off. - Without it, a part whose libraries are missing is dropped with a warning. The PyPI wheels - are built with it. + Without it, a part whose libraries are missing is dropped with a warning. The ``nyxus`` + wheels on PyPI are built with it; the ``nyxus-cuda11x`` and ``nyxus-cuda12x`` wheels are not. * - ``USE_Z5`` - ``OFF`` - OME-Zarr input. Also enables compressed NIfTI (``.nii.gz``), which needs the zlib that this From 078f2940292cb5f418d94c1b6597c39e11f996f1 Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Tue, 10 Nov 2026 08:46:40 -0800 Subject: [PATCH 4/9] docs: state the Windows package facts of 0.12.0 and 0.12.1 The PyPI Windows wheels read OME-Zarr and .nii.gz since 0.12.0, the conda-forge Windows packages of 0.12.0 are Debug builds like those of 0.11.0, and 0.12.1 was published without a source distribution. --- README.md | 5 +++-- docs/source/installation.rst | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a01f8dd2e..6cbf57219 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,9 @@ conda install nyxus -c conda-forge ``` The conda-forge package has no build for Apple Silicon Macs or Linux aarch64; use `pip` there. -On Windows, the PyPI wheels do not read OME-Zarr or compressed NIfTI (`.nii.gz`), and the -conda-forge packages of 0.11.0 need Visual Studio installed (they were built in Debug mode). +On Windows, the PyPI wheels older than 0.12.0 do not read OME-Zarr or compressed NIfTI +(`.nii.gz`), and the conda-forge packages of 0.11.0 and 0.12.0 need Visual Studio installed (they +were built in Debug mode). GPU wheels, the Docker image and building from source are described in [Installation](https://nyxus.readthedocs.io/en/latest/installation.html). diff --git a/docs/source/installation.rst b/docs/source/installation.rst index d5afe5223..0cd53d146 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -38,7 +38,7 @@ The PyPI wheels are built for CPython 3.10, 3.11, 3.12 and 3.13 on these platfor Later releases also publish a source distribution once all their wheels are on PyPI; where no wheel fits, ``pip`` builds it, which needs CMake, a C++20 compiler and the libraries listed in -`Building from source`_. Releases up to 0.12.0, and a release with a wheel missing, have none, so +`Building from source`_. Releases up to 0.12.1, and a release with a wheel missing, have none, so where no wheel fits, ``pip`` falls back to an older release without a warning, or stops with ``No matching distribution found for nyxus``: * On Linux with a glibc older than 2.28 (for example CentOS 7 or Ubuntu 18.04), ``pip`` installs @@ -81,7 +81,7 @@ output, in addition to TIFF, OME-TIFF and NIfTI. They also read OME-Zarr and com * The Windows wheels on PyPI (``nyxus`` 0.9.3 and 0.11.0, and ``nyxus-cuda12x`` 0.9.3) were built without OME-Zarr support, and so without ``.nii.gz``: they refuse OME-Zarr and fail on - ``.nii.gz`` files. The ``nyxus`` 0.12.0 Windows wheels read both. + ``.nii.gz`` files. The ``nyxus`` Windows wheels of 0.12.0 and later read both. * The first conda-forge Windows builds of 0.11.0 (build number 0, a build string ending in ``_0`` in ``conda list nyxus``) read none of OME-Zarr, ``.nii.gz`` and DICOM; conda installs one of them into an environment that holds ``libarrow`` 19 or 20. @@ -91,8 +91,8 @@ libraries it finds (see `Building from source`_). .. warning:: - The conda-forge Windows packages of 0.11.0 were built in Debug mode: their extension module - imports the Visual Studio debug runtime (``MSVCP140D.dll``, ``VCRUNTIME140D.dll``, + The conda-forge Windows packages of 0.11.0 and 0.12.0 were built in Debug mode: their extension + module imports the Visual Studio debug runtime (``MSVCP140D.dll``, ``VCRUNTIME140D.dll``, ``ucrtbased.dll``), which only an installation of Visual Studio provides, not the Visual C++ redistributable. Without Visual Studio, ``import nyxus`` fails. This is a known issue (`#528 `__). From 627768e3f029ea9a607f768aaba33f8f183f8e86 Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Tue, 10 Nov 2026 08:46:41 -0800 Subject: [PATCH 5/9] docs: state on the index page which Nyxus version the pages describe A Read the Docs build of a release tag says it describes that release. Every other build says it describes the development version on main, newer than the latest release that CITATION.cff records. --- docs/source/conf.py | 7 ++++++- docs/source/devguide.rst | 7 +++++-- docs/source/index.rst | 11 +++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 1cc88f85f..5776a420c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,6 +23,11 @@ for line in _f if line.startswith('version:')) version = '.'.join(release.split('.')[:2]) +# Read the Docs builds a tag from the release it names and every other version from a branch, +# which runs ahead of the latest release. The index page states which of the two it describes. +if os.environ.get('READTHEDOCS_VERSION_TYPE') == 'tag': + tags.add('release_docs') + # -- General configuration --------------------------------------------------- @@ -61,7 +66,7 @@ # -- Options for HTML output ------------------------------------------------- html_theme = 'pydata_sphinx_theme' -# The pages describe the development head, not a release, so the title carries no version number. +# The index page states the version the pages describe, so the title carries no version number. html_title = 'Nyxus' html_theme_options = { 'github_url': 'https://github.com/PolusAI/nyxus', diff --git a/docs/source/devguide.rst b/docs/source/devguide.rst index 9b740ba75..6e42e8ae4 100644 --- a/docs/source/devguide.rst +++ b/docs/source/devguide.rst @@ -1214,8 +1214,11 @@ Documentation ------------- The documentation is a Sphinx site in ``docs/source``. It does not need the compiled module: -``conf.py`` mocks ``nyxus.backend``. The pages describe the development head, so their title -carries no version number. +``conf.py`` mocks ``nyxus.backend``. The title carries no version number; the index page states +the version instead. ``conf.py`` reads the latest release from ``CITATION.cff`` into ``|release|``. +A Read the Docs build of a tag (``READTHEDOCS_VERSION_TYPE=tag``) says it describes that release, +and every other build, a local one included, says it describes the development version newer than +it. Building ^^^^^^^^ diff --git a/docs/source/index.rst b/docs/source/index.rst index 0ea88ac25..94e8d52fa 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -7,6 +7,17 @@ volumes and 6 image quality features. It runs from the command line or from Pyth TIFF, OME-TIFF, OME-Zarr, NIfTI and DICOM files (OME-TIFF and OME-Zarr with up to five dimensions), and assembles ROIs that span several image tiles. +.. only:: release_docs + + This documentation describes Nyxus |release|. + +.. only:: not release_docs + + This documentation describes the development version of Nyxus on the ``main`` branch, which + is newer than the latest release, |release|. Features and options added since |release| are + not in the packages on PyPI and conda-forge until the next release; :doc:`release_notes` lists + what each release contains. + ROIs larger than the memory budget are processed out of core when they come from files; which features then keep their in-memory values is listed under :ref:`large-images`. From c9d085ec62cf8824171c47a2f4fcecea6cccfada Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Thu, 12 Nov 2026 09:15:45 -0800 Subject: [PATCH 6/9] docs: name 0.12.1 among the Debug-built conda-forge Windows packages The conda-forge win-64 packages of 0.12.1, CPU and CUDA, import the Visual Studio debug runtime (MSVCP140D.dll, VCRUNTIME140D.dll, VCRUNTIME140_1D.dll, ucrtbased.dll), as those of 0.11.0 and 0.12.0 do. --- README.md | 4 ++-- docs/source/installation.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6cbf57219..188d3fc73 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ conda install nyxus -c conda-forge The conda-forge package has no build for Apple Silicon Macs or Linux aarch64; use `pip` there. On Windows, the PyPI wheels older than 0.12.0 do not read OME-Zarr or compressed NIfTI -(`.nii.gz`), and the conda-forge packages of 0.11.0 and 0.12.0 need Visual Studio installed (they -were built in Debug mode). +(`.nii.gz`), and the conda-forge packages of 0.11.0, 0.12.0 and 0.12.1 need Visual Studio installed +(they were built in Debug mode). GPU wheels, the Docker image and building from source are described in [Installation](https://nyxus.readthedocs.io/en/latest/installation.html). diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 0cd53d146..f18fce304 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -91,8 +91,8 @@ libraries it finds (see `Building from source`_). .. warning:: - The conda-forge Windows packages of 0.11.0 and 0.12.0 were built in Debug mode: their extension - module imports the Visual Studio debug runtime (``MSVCP140D.dll``, ``VCRUNTIME140D.dll``, + The conda-forge Windows packages of 0.11.0, 0.12.0 and 0.12.1 were built in Debug mode: their + extension module imports the Visual Studio debug runtime (``MSVCP140D.dll``, ``VCRUNTIME140D.dll``, ``ucrtbased.dll``), which only an installation of Visual Studio provides, not the Visual C++ redistributable. Without Visual Studio, ``import nyxus`` fails. This is a known issue (`#528 `__). From a3b1cdba7045d5ecdbb575feacda931b9a0761dc Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Mon, 16 Nov 2026 09:52:46 -0800 Subject: [PATCH 7/9] fix(ci): report missing release wheels instead of publishing an sdist The release no longer builds or uploads a source distribution. The wheel-grid check stays as its own wheel_grid job in publish_pypi.yml: it runs after every wheel job, checks the version the wheels were built as, and turns the run red with the missing wheels named. It publishes nothing. check_wheel_grid.py takes the version as its argument and refuses an empty one. The installation page states again that PyPI has no source distribution. --- .github/workflows/publish_pypi.yml | 48 +++--------------- ci-utils/check_wheel_grid.py | 20 +++----- docs/source/installation.rst | 6 +-- .../test_release_wheel_grid_mechanics.py | 50 ++++++++++++------- 4 files changed, 49 insertions(+), 75 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 744fcc573..36305b8d0 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -149,12 +149,12 @@ jobs: # Wheel build + publish jobs — each starts as soon as its prereq finishes # ============================================================ - sdist: - name: Build & publish the source distribution + wheel_grid: + name: Check that PyPI holds every wheel of this release runs-on: ubuntu-22.04 - # Uploaded after the wheels, and only beside all of them: pip prefers a new version's sdist - # over an older wheel. - needs: [prereqs_ubuntu, wheels_ubuntu, wheels_ubuntu_arm, wheels_windows, wheels_macos_intel, wheels_macos_arm64] + # The wheel jobs continue on error, so a release can lack wheels with the run still green. + # This job turns the run red and names the missing wheels; it publishes nothing. + needs: [wheels_ubuntu, wheels_ubuntu_arm, wheels_windows, wheels_macos_intel, wheels_macos_arm64] if: ${{ !cancelled() }} steps: - uses: actions/checkout@v3 @@ -178,43 +178,9 @@ jobs: fi python -m setuptools_scm shell: bash - - name: Build the source distribution - run: | - python -m pip install --upgrade pip build - python -m build --sdist --outdir dist - - name: Download prereqs - uses: actions/download-artifact@v4 - with: - name: prereqs-ubuntu-22.04 - path: . - - name: Extract prereqs - run: tar -xzf prereqs.tar.gz - - name: Install from the source distribution - run: | - docker run --rm \ - -v "${{ github.workspace }}:/work" \ - -w /work \ - -e NYXUS_DEP_DIR=/work/local_install \ - -e LD_LIBRARY_PATH=/work/local_install/lib:/work/local_install/lib64 \ - -e CMAKE_ARGS=-DREQUIRE_ALLEXTRAS=ON \ - quay.io/pypa/manylinux_2_28_x86_64:latest \ - bash -c " - set -e - dnf -y install llvm libevent-devel openssl-devel - python3.11 -m pip install dist/*.tar.gz - cd /tmp - python3.11 -c 'import nyxus; print(nyxus.__version__)' - " - name: Check that PyPI holds every wheel of this release - run: python ci-utils/check_wheel_grid.py dist/*.tar.gz - - name: Install Dependencies - run: python -m pip install --upgrade twine requests - - name: Publish to PyPi - run: python -m twine upload dist/*.tar.gz - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} - TWINE_REPOSITORY: pypi + run: python ci-utils/check_wheel_grid.py "$(python -m setuptools_scm)" + shell: bash wheels_ubuntu: diff --git a/ci-utils/check_wheel_grid.py b/ci-utils/check_wheel_grid.py index 18ee8ef25..6cab60029 100644 --- a/ci-utils/check_wheel_grid.py +++ b/ci-utils/check_wheel_grid.py @@ -1,18 +1,17 @@ #!/usr/bin/env python3 """Check that PyPI holds every wheel of a release. -pip prefers a new version's source distribution over an older wheel, so publish_pypi.yml uploads -the source distribution only when this check passes. Usage: check_wheel_grid.py +The wheel jobs of publish_pypi.yml continue on error, so a release can lack wheels while its run +stays green, and pip then installs an older release on the platforms concerned. publish_pypi.yml +runs this check after the wheel jobs. Usage: check_wheel_grid.py """ import argparse import fnmatch import json -import re import sys import time import urllib.error import urllib.request -from pathlib import Path PYTHONS = ("cp310", "cp311", "cp312", "cp313") PLATFORMS = { @@ -40,13 +39,6 @@ def missing_wheels(filenames, version): return [python + " " + label for python in PYTHONS for label in PLATFORMS if (python, label) not in present] -def version_of_sdist(path): - match = re.fullmatch(r"nyxus-(.+)\.tar\.gz", Path(path).name) - if match is None: - raise SystemExit(f"'{path}' is not a nyxus source distribution.") - return match.group(1) - - def fetch_filenames(version): """List the files PyPI holds for this version; a version PyPI does not know has none.""" try: @@ -60,13 +52,15 @@ def fetch_filenames(version): def main(argv=None): parser = argparse.ArgumentParser(description="Check that PyPI holds every wheel of a release.") - parser.add_argument("sdist", help="Path of the source distribution about to be uploaded.") + parser.add_argument("version", help="The release's version, as setuptools-scm gives it.") # PyPI's JSON API can trail an upload by a few minutes. parser.add_argument("--attempts", type=int, default=6) parser.add_argument("--delay", type=float, default=30.0, help="Seconds between attempts.") args = parser.parse_args(argv) - version = version_of_sdist(args.sdist) + version = args.version + if not version or any(char.isspace() for char in version): + raise SystemExit(f"'{version}' is not a version.") for attempt in range(1, args.attempts + 1): missing = missing_wheels(fetch_filenames(version), version) if not missing: diff --git a/docs/source/installation.rst b/docs/source/installation.rst index f18fce304..0781be4f7 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -36,10 +36,8 @@ The PyPI wheels are built for CPython 3.10, 3.11, 3.12 and 3.13 on these platfor * Windows x86_64; * macOS x86_64 (10.15 or newer) and arm64 (11.0 or newer). -Later releases also publish a source distribution once all their wheels are on PyPI; where no -wheel fits, ``pip`` builds it, which needs CMake, a C++20 compiler and the libraries listed in -`Building from source`_. Releases up to 0.12.1, and a release with a wheel missing, have none, so -where no wheel fits, ``pip`` falls back to an older release without a warning, or stops with ``No matching distribution found for nyxus``: +PyPI has no source distribution, so where no wheel fits, ``pip`` falls back to an older release +without a warning, or stops with ``No matching distribution found for nyxus``: * On Linux with a glibc older than 2.28 (for example CentOS 7 or Ubuntu 18.04), ``pip`` installs 0.8.3, the last release built for ``manylinux2014``, on x86_64 with Python 3.8 to 3.12, and an diff --git a/tests/python/test_release_wheel_grid_mechanics.py b/tests/python/test_release_wheel_grid_mechanics.py index 60bb6fef7..fe68e0a4a 100644 --- a/tests/python/test_release_wheel_grid_mechanics.py +++ b/tests/python/test_release_wheel_grid_mechanics.py @@ -1,9 +1,9 @@ -"""A release's source distribution reaches PyPI only beside its full wheel grid. +"""A release run reports every wheel of the grid that PyPI lacks. -pip prefers a new version's source distribution over an older wheel, so a platform whose wheel -is missing would attempt a source build. ci-utils/check_wheel_grid.py compares PyPI's file list -with the grid publish_pypi.yml builds, and the release wheels are configured so that a dropped -ALLEXTRAS part fails the build. +The wheel jobs continue on error, so a release can lack wheels with its run green, and pip then +installs an older release on the platforms concerned. ci-utils/check_wheel_grid.py compares PyPI's +file list with the grid publish_pypi.yml builds, and the release wheels are configured so that a +dropped ALLEXTRAS part fails the build. """ import importlib.util import pathlib @@ -79,20 +79,28 @@ def test_other_versions_and_sdists_cover_no_cell_mechanics(): assert len(_grid().missing_wheels(files, VERSION)) == 20 -def test_sdist_name_gives_the_version_mechanics(): - assert _grid().version_of_sdist("dist/nyxus-0.13.0.post2.dev5.tar.gz") == "0.13.0.post2.dev5" +def test_version_argument_is_the_one_queried_mechanics(monkeypatch): + grid = _grid() + asked = [] + monkeypatch.setattr(grid, "fetch_filenames", lambda version: asked.append(version) or _complete(version)) + assert grid.main(["0.13.0.post2.dev5", "--attempts", "1"]) == 0 + assert asked == ["0.13.0.post2.dev5"] -def test_foreign_sdist_name_refused_mechanics(): +@pytest.mark.parametrize("version", ["", "0.13.0 0.13.1"]) +def test_empty_or_split_version_refused_mechanics(monkeypatch, version): + # an empty "$(python -m setuptools_scm)" would otherwise query the URL of no version + grid = _grid() + monkeypatch.setattr(grid, "fetch_filenames", lambda version: pytest.fail("PyPI queried")) with pytest.raises(SystemExit): - _grid().version_of_sdist("dist/other-1.2.3.tar.gz") + grid.main([version]) def test_incomplete_grid_exits_nonzero_and_names_the_cells_mechanics(monkeypatch, capsys): grid = _grid() files = [name for name in _complete() if "arm64" not in name] monkeypatch.setattr(grid, "fetch_filenames", lambda version: files) - assert grid.main(["dist/nyxus-" + VERSION + ".tar.gz", "--attempts", "2", "--delay", "0"]) == 1 + assert grid.main([VERSION, "--attempts", "2", "--delay", "0"]) == 1 assert "cp310 macOS arm64" in capsys.readouterr().err @@ -100,19 +108,27 @@ def test_grid_appearing_between_attempts_passes_mechanics(monkeypatch): grid = _grid() answers = iter([[], _complete()]) monkeypatch.setattr(grid, "fetch_filenames", lambda version: next(answers)) - assert grid.main(["dist/nyxus-" + VERSION + ".tar.gz", "--attempts", "2", "--delay", "0"]) == 0 + assert grid.main([VERSION, "--attempts", "2", "--delay", "0"]) == 0 -def test_grid_check_precedes_the_sdist_upload_mechanics(): - job = _jobs("publish_pypi.yml")["sdist"] - check = job.index("ci-utils/check_wheel_grid.py dist/*.tar.gz") - assert check < job.index("twine upload dist/*.tar.gz") +def test_grid_job_checks_the_built_version_mechanics(): + job = _jobs("publish_pypi.yml")["wheel_grid"] + assert 'ci-utils/check_wheel_grid.py "$(python -m setuptools_scm)"' in job + assert job.index("ci-utils/sync_version.py") < job.index("check_wheel_grid.py") -def test_sdist_job_waits_for_every_wheel_job_mechanics(): - needs = re.search(r"^ needs: \[(.*)\]$", _jobs("publish_pypi.yml")["sdist"], re.M).group(1) +def test_grid_job_waits_for_every_wheel_job_mechanics(): + job = _jobs("publish_pypi.yml")["wheel_grid"] + needs = re.search(r"^ needs: \[(.*)\]$", job, re.M).group(1) needed = {name.strip() for name in needs.split(",")} assert set(_wheel_jobs("publish_pypi.yml")) <= needed + assert "if: ${{ !cancelled() }}" in job + + +def test_release_publishes_no_source_distribution_mechanics(): + workflow = (REPO / ".github" / "workflows" / "publish_pypi.yml").read_text(encoding="utf-8") + assert "--sdist" not in workflow + assert "*.tar.gz" not in workflow def test_grid_matches_the_wheel_jobs_pythons_mechanics(): From 7809265783f7dd9a6cb7156f6de07506bd18d499 Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Mon, 16 Nov 2026 10:38:16 -0800 Subject: [PATCH 8/9] fix(ci): leave the build type as on main and drop the CI-code tests The wheels on Windows build with the Visual Studio generator, which the build-type default never touched; only explicit Ninja or NMake builds, such as the conda-forge feedstock, come out Debug, and the feedstock is fixed there. CMakeLists.txt keeps main's build-type fallback, and the Windows workflow no longer checks the Ninja default. CLAUDE.md, CONTRIBUTING.md and the CMake options table again say to pass -DCMAKE_BUILD_TYPE=Release with Ninja. test_release_wheel_grid_mechanics.py tested the release workflows rather than Nyxus, so it is removed with its check_test_names.py entry. --- .github/workflows/build_and_test_windows.yml | 15 -- CLAUDE.md | 8 +- CMakeLists.txt | 13 +- CONTRIBUTING.md | 6 +- docs/source/installation.rst | 7 +- .../test_release_wheel_grid_mechanics.py | 145 ------------------ tests/vetting/check_test_names.py | 1 - 7 files changed, 15 insertions(+), 180 deletions(-) delete mode 100644 tests/python/test_release_wheel_grid_mechanics.py diff --git a/.github/workflows/build_and_test_windows.yml b/.github/workflows/build_and_test_windows.yml index ad49dbb9d..6f9f03924 100644 --- a/.github/workflows/build_and_test_windows.yml +++ b/.github/workflows/build_and_test_windows.yml @@ -40,21 +40,6 @@ jobs: conda install mamba mamba install --file ${{github.workspace}}/ci-utils/envs/conda_cpp.txt - - name: Check that a Ninja configure defaults to Release - shell: bash -l {0} - run: | - set -e - cmake -S . -B build-default-type -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/Library - grep '^CMAKE_BUILD_TYPE:STRING=Release$' build-default-type/CMakeCache.txt - - - name: Check that CMake older than 3.22 ignores a build type in the environment - shell: bash -l {0} - run: | - set -e - python -m pip install --target "$RUNNER_TEMP/cmake-3.21" cmake==3.21.4 - CMAKE_BUILD_TYPE=RelWithDebInfo "$RUNNER_TEMP/cmake-3.21/cmake/data/bin/cmake" -S . -B build-old-cmake -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/Library - grep '^CMAKE_BUILD_TYPE:STRING=Release$' build-old-cmake/CMakeCache.txt - - name: Check that REQUIRE_ALLEXTRAS refuses a dropped part shell: bash -l {0} run: | diff --git a/CLAUDE.md b/CLAUDE.md index 41a43a290..e49542b1d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -149,17 +149,17 @@ build cannot link them. Full-feature + CUDA build (paths below are placeholders: 2. Configure with the **Ninja** generator so `nvcc` can use `cl` as its host compiler (no CUDA MSBuild integration needed): run the Visual Studio `vcvars64.bat` first, then `cmake -S . -B build-cli -G Ninja - -DCMAKE_CXX_COMPILER=cl -DBUILD_CLI=ON + -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -DBUILD_CLI=ON -DALLEXTRAS=ON -DUSEGPU=ON -DCMAKE_PREFIX_PATH=$ENV\Library` then - `cmake --build build-cli`. Ninja builds `Release` by default; `--config` has - no effect there, so another type needs `-DCMAKE_BUILD_TYPE` at configure time. + `cmake --build build-cli`. With MSVC, CMake presets `Debug` for Ninja and + `--config` has no effect there, so `-DCMAKE_BUILD_TYPE=Release` is required. (`NYXUS_DEP_DIR` is read only as an environment variable, not as a `-D` cache variable.) 3. To run, put `$ENV\Library\bin` (dependency DLLs) and the CUDA toolkit `bin` on PATH. **Fast Python-extension build** for running the test suite (tiff-only CPU): -same as above (the default `Release` type is what +same as above (keep `-DCMAKE_BUILD_TYPE=Release`, which `CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE` below relies on) but `-DBUILD_LIB=ON -DALLEXTRAS=OFF -DUSEGPU=OFF -DPYTHON_EXECUTABLE=$ENV\python.exe -Dpybind11_DIR=$ENV\Lib\site-packages\pybind11\share\cmake\pybind11` and `--target backend`, with `-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE` pointed at diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f041f05b..579ff77a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,4 @@ cmake_minimum_required(VERSION 3.20) - -# A single-configuration generator builds Release unless told otherwise. This precedes project() -# because project() presets the cache entry to Debug under MSVC. CMake 3.22 and newer take a type -# from the CMAKE_BUILD_TYPE environment variable; older versions ignore that variable. -get_property(NYXUS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(NOT NYXUS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE AND ("$ENV{CMAKE_BUILD_TYPE}" STREQUAL "" OR CMAKE_VERSION VERSION_LESS 3.22)) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) -endif() - project(AxleNyxus) include(GNUInstallDirs) include(CheckLanguage) @@ -124,6 +115,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /EHsc /bigobj /Zc:__cplusplus") endif() +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + set(CMAKE_CXX_FLAGS_RELEASE "-O2") #== GTest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8839ef0b..581caabf5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,13 +105,13 @@ cannot link them. Run the Visual Studio `vcvars64.bat` first and configure with which also lets `nvcc` use `cl` as its host compiler for a CUDA build: ```bat -cmake -S . -B build-cli -G Ninja -DCMAKE_CXX_COMPILER=cl ^ +cmake -S . -B build-cli -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release ^ -DBUILD_CLI=ON -DALLEXTRAS=ON -DCMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library cmake --build build-cli ``` -Ninja builds `Release` by default. To build another type, pass `-DCMAKE_BUILD_TYPE` when configuring: -`--config` has no effect on a single-configuration generator. +Pass `-DCMAKE_BUILD_TYPE=Release`: with MSVC, CMake presets `Debug` for Ninja, and `--config` has +no effect on a single-configuration generator. If CMake still misses a dependency, set the environment variable `NYXUS_DEP_DIR` to the same prefix before configuring; `CMakeLists.txt` reads it from the environment, not as a `-D` option. diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 0781be4f7..753853f81 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -433,9 +433,10 @@ CMake options - ``OFF`` - Builds the ``bench_convex_hull`` micro-benchmark (see ``benchmarks/README.md``). * - ``CMAKE_BUILD_TYPE`` - - ``Release`` - - Single-configuration generators, such as Ninja and NMake, build ``Release`` unless told - otherwise. + - ``Release`` (``Debug`` with MSVC) + - Single-configuration generators build ``Release`` unless told otherwise. With MSVC, CMake + itself presets ``Debug``, so pass ``-DCMAKE_BUILD_TYPE=Release`` when you use Ninja or + NMake. This is a known defect (`#524 `__). The C++ standard is C++20 and is required (``CMAKE_CXX_STANDARD 20``). On MSVC the build adds ``/permissive- /EHsc /bigobj /Zc:__cplusplus``. diff --git a/tests/python/test_release_wheel_grid_mechanics.py b/tests/python/test_release_wheel_grid_mechanics.py deleted file mode 100644 index fe68e0a4a..000000000 --- a/tests/python/test_release_wheel_grid_mechanics.py +++ /dev/null @@ -1,145 +0,0 @@ -"""A release run reports every wheel of the grid that PyPI lacks. - -The wheel jobs continue on error, so a release can lack wheels with its run green, and pip then -installs an older release on the platforms concerned. ci-utils/check_wheel_grid.py compares PyPI's -file list with the grid publish_pypi.yml builds, and the release wheels are configured so that a -dropped ALLEXTRAS part fails the build. -""" -import importlib.util -import pathlib -import re - -import pytest - -REPO = pathlib.Path(__file__).resolve().parent.parent.parent -VERSION = "1.2.3" -PLATFORM_TAGS = ( - "manylinux_2_28_x86_64", - "manylinux_2_28_aarch64", - "win_amd64", - "macosx_10_15_x86_64", - "macosx_11_0_arm64", -) -PYTHONS = ("cp310", "cp311", "cp312", "cp313") - - -def _grid(): - spec = importlib.util.spec_from_file_location("check_wheel_grid", REPO / "ci-utils" / "check_wheel_grid.py") - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - return module - - -def _wheel(python, tag, version=VERSION): - return "nyxus-" + version + "-" + python + "-" + python + "-" + tag + ".whl" - - -def _complete(version=VERSION): - return [_wheel(python, tag, version) for python in PYTHONS for tag in PLATFORM_TAGS] - - -def _jobs(workflow): - """Split a workflow into its jobs, keyed by job id.""" - text = (REPO / ".github" / "workflows" / workflow).read_text(encoding="utf-8") - body = text[text.index("\njobs:\n"):] - parts = re.split(r"^ ([A-Za-z0-9_-]+):\n", body, flags=re.M) - return dict(zip(parts[1::2], parts[2::2])) - - -def _wheel_jobs(workflow): - return {name: job for name, job in _jobs(workflow).items() if "cibuildwheel --output-dir" in job} - - -def test_complete_grid_has_nothing_missing_mechanics(): - assert len(_complete()) == 20 - assert _grid().missing_wheels(_complete(), VERSION) == [] - - -def test_release_without_macos_arm64_is_reported_mechanics(): - # the file set of nyxus 0.12.0: every cell but macOS arm64 - files = [name for name in _complete("0.12.0") if "arm64" not in name] - assert len(files) == 16 - assert _grid().missing_wheels(files, "0.12.0") == [python + " macOS arm64" for python in PYTHONS] - - -def test_single_missing_cell_is_named_mechanics(): - # the file set of nyxus 0.11.0: 19 wheels, one Linux x86_64 cell absent - files = [name for name in _complete() if name != _wheel("cp313", "manylinux_2_28_x86_64")] - assert _grid().missing_wheels(files, VERSION) == ["cp313 Linux x86_64"] - - -def test_compound_platform_tag_covers_its_cell_mechanics(): - files = [name for name in _complete() if name != _wheel("cp312", "manylinux_2_28_x86_64")] - files.append(_wheel("cp312", "manylinux2014_x86_64.manylinux_2_28_x86_64")) - assert _grid().missing_wheels(files, VERSION) == [] - - -def test_other_versions_and_sdists_cover_no_cell_mechanics(): - files = _complete("1.2.2") + ["nyxus-" + VERSION + ".tar.gz"] - assert len(_grid().missing_wheels(files, VERSION)) == 20 - - -def test_version_argument_is_the_one_queried_mechanics(monkeypatch): - grid = _grid() - asked = [] - monkeypatch.setattr(grid, "fetch_filenames", lambda version: asked.append(version) or _complete(version)) - assert grid.main(["0.13.0.post2.dev5", "--attempts", "1"]) == 0 - assert asked == ["0.13.0.post2.dev5"] - - -@pytest.mark.parametrize("version", ["", "0.13.0 0.13.1"]) -def test_empty_or_split_version_refused_mechanics(monkeypatch, version): - # an empty "$(python -m setuptools_scm)" would otherwise query the URL of no version - grid = _grid() - monkeypatch.setattr(grid, "fetch_filenames", lambda version: pytest.fail("PyPI queried")) - with pytest.raises(SystemExit): - grid.main([version]) - - -def test_incomplete_grid_exits_nonzero_and_names_the_cells_mechanics(monkeypatch, capsys): - grid = _grid() - files = [name for name in _complete() if "arm64" not in name] - monkeypatch.setattr(grid, "fetch_filenames", lambda version: files) - assert grid.main([VERSION, "--attempts", "2", "--delay", "0"]) == 1 - assert "cp310 macOS arm64" in capsys.readouterr().err - - -def test_grid_appearing_between_attempts_passes_mechanics(monkeypatch): - grid = _grid() - answers = iter([[], _complete()]) - monkeypatch.setattr(grid, "fetch_filenames", lambda version: next(answers)) - assert grid.main([VERSION, "--attempts", "2", "--delay", "0"]) == 0 - - -def test_grid_job_checks_the_built_version_mechanics(): - job = _jobs("publish_pypi.yml")["wheel_grid"] - assert 'ci-utils/check_wheel_grid.py "$(python -m setuptools_scm)"' in job - assert job.index("ci-utils/sync_version.py") < job.index("check_wheel_grid.py") - - -def test_grid_job_waits_for_every_wheel_job_mechanics(): - job = _jobs("publish_pypi.yml")["wheel_grid"] - needs = re.search(r"^ needs: \[(.*)\]$", job, re.M).group(1) - needed = {name.strip() for name in needs.split(",")} - assert set(_wheel_jobs("publish_pypi.yml")) <= needed - assert "if: ${{ !cancelled() }}" in job - - -def test_release_publishes_no_source_distribution_mechanics(): - workflow = (REPO / ".github" / "workflows" / "publish_pypi.yml").read_text(encoding="utf-8") - assert "--sdist" not in workflow - assert "*.tar.gz" not in workflow - - -def test_grid_matches_the_wheel_jobs_pythons_mechanics(): - for name, job in _wheel_jobs("publish_pypi.yml").items(): - built = tuple(re.findall(r'"(cp3\d+)-\*"', job)) - assert built == _grid().PYTHONS, name - - -@pytest.mark.parametrize("workflow", ["publish_pypi.yml", "build_wheels.yml"]) -def test_wheel_builds_refuse_a_dropped_extra_mechanics(workflow): - jobs = _wheel_jobs(workflow) - assert len(jobs) == 5 - for name, job in jobs.items(): - assert "-DREQUIRE_ALLEXTRAS=ON" in job, workflow + ": " + name diff --git a/tests/vetting/check_test_names.py b/tests/vetting/check_test_names.py index 1e71b5b35..2e2de659c 100644 --- a/tests/vetting/check_test_names.py +++ b/tests/vetting/check_test_names.py @@ -106,7 +106,6 @@ "test_docs_cli_reference_mechanics.py": "the CLI reference generator's checks; no image is read", "test_docs_conf_mechanics.py": "the Sphinx configuration's release and title; no image is read", "test_release_tag_mechanics.py": "the release tag's name and the release tooling that reads it; no image is read", - "test_release_wheel_grid_mechanics.py": "the release's wheel grid and the workflows that build it; no image is read", "test_docs_feature_reference_mechanics.py": "the feature reference generator's checks; no image is read", "test_ooc_mechanics.py": "out-of-core streaming machinery, asserted for both dims at once", "test_physical_calibration_regression.py": "physical voxel spacing read from OME metadata, not from an image of either dimension", From 9d639245ab3f85209e1d7eb982b60222694455a0 Mon Sep 17 00:00:00 2001 From: Demian Vladi Date: Mon, 16 Nov 2026 16:45:07 -0800 Subject: [PATCH 9/9] ci: drop the wheel-grid job and the REQUIRE_ALLEXTRAS workflow check The wheel_grid job of publish_pypi.yml and ci-utils/check_wheel_grid.py are removed. The Windows test workflow no longer configures a build with Arrow disabled to see REQUIRE_ALLEXTRAS refuse it; the release wheel jobs still pass -DREQUIRE_ALLEXTRAS=ON. --- .github/workflows/build_and_test_windows.yml | 11 --- .github/workflows/publish_pypi.yml | 34 --------- ci-utils/check_wheel_grid.py | 77 -------------------- 3 files changed, 122 deletions(-) delete mode 100644 ci-utils/check_wheel_grid.py diff --git a/.github/workflows/build_and_test_windows.yml b/.github/workflows/build_and_test_windows.yml index 6f9f03924..efd71f344 100644 --- a/.github/workflows/build_and_test_windows.yml +++ b/.github/workflows/build_and_test_windows.yml @@ -40,17 +40,6 @@ jobs: conda install mamba mamba install --file ${{github.workspace}}/ci-utils/envs/conda_cpp.txt - - name: Check that REQUIRE_ALLEXTRAS refuses a dropped part - shell: bash -l {0} - run: | - set -e - if cmake -S . -B build-required-extras -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_PREFIX_PATH=$CONDA_PREFIX/Library -DALLEXTRAS=ON -DREQUIRE_ALLEXTRAS=ON -DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON > required-extras.log 2>&1; then - cat required-extras.log - exit 1 - fi - cat required-extras.log - grep 'these parts are off: USE_ARROW' required-extras.log - - name: Configure CMake run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_CLI=ON -DRUN_GTEST=ON -DALLEXTRAS=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 36305b8d0..f90379537 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -149,40 +149,6 @@ jobs: # Wheel build + publish jobs — each starts as soon as its prereq finishes # ============================================================ - wheel_grid: - name: Check that PyPI holds every wheel of this release - runs-on: ubuntu-22.04 - # The wheel jobs continue on error, so a release can lack wheels with the run still green. - # This job turns the run red and names the missing wheels; it publishes nothing. - needs: [wheels_ubuntu, wheels_ubuntu_arm, wheels_windows, wheels_macos_intel, wheels_macos_arm64] - if: ${{ !cancelled() }} - steps: - - uses: actions/checkout@v3 - name: Check out - with: - fetch-depth: 0 - fetch-tags: true - - name: Fetch git tags - run: git fetch --force --tags - - uses: actions/setup-python@v4 - name: Install Python - with: - python-version: '3.11' - - name: Verify version detection - run: | - python -m pip install setuptools-scm - if [[ "$GITHUB_REF_NAME" == v* ]]; then - echo "Release build on tag $GITHUB_REF_NAME" - else - python ci-utils/sync_version.py - fi - python -m setuptools_scm - shell: bash - - name: Check that PyPI holds every wheel of this release - run: python ci-utils/check_wheel_grid.py "$(python -m setuptools_scm)" - shell: bash - - wheels_ubuntu: name: Build & publish wheels (ubuntu-22.04 / ${{ matrix.cibw_build }}) runs-on: ubuntu-22.04 diff --git a/ci-utils/check_wheel_grid.py b/ci-utils/check_wheel_grid.py deleted file mode 100644 index 6cab60029..000000000 --- a/ci-utils/check_wheel_grid.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python3 -"""Check that PyPI holds every wheel of a release. - -The wheel jobs of publish_pypi.yml continue on error, so a release can lack wheels while its run -stays green, and pip then installs an older release on the platforms concerned. publish_pypi.yml -runs this check after the wheel jobs. Usage: check_wheel_grid.py -""" -import argparse -import fnmatch -import json -import sys -import time -import urllib.error -import urllib.request - -PYTHONS = ("cp310", "cp311", "cp312", "cp313") -PLATFORMS = { - "Linux x86_64": "manylinux_*_x86_64", - "Linux aarch64": "manylinux_*_aarch64", - "Windows x86_64": "win_amd64", - "macOS x86_64": "macosx_*_x86_64", - "macOS arm64": "macosx_*_arm64", -} - - -def missing_wheels(filenames, version): - """Name the Python and platform cells of the grid that no file of this version covers.""" - present = set() - for filename in filenames: - if not filename.endswith(".whl"): - continue - parts = filename[: -len(".whl")].split("-") - if len(parts) != 5 or parts[1] != version: - continue - for tag in parts[4].split("."): - for label, pattern in PLATFORMS.items(): - if fnmatch.fnmatchcase(tag, pattern): - present.add((parts[2], label)) - return [python + " " + label for python in PYTHONS for label in PLATFORMS if (python, label) not in present] - - -def fetch_filenames(version): - """List the files PyPI holds for this version; a version PyPI does not know has none.""" - try: - with urllib.request.urlopen(f"https://pypi.org/pypi/nyxus/{version}/json", timeout=60) as response: - return [entry["filename"] for entry in json.load(response)["urls"]] - except urllib.error.HTTPError as exc: - if exc.code == 404: - return [] - raise - - -def main(argv=None): - parser = argparse.ArgumentParser(description="Check that PyPI holds every wheel of a release.") - parser.add_argument("version", help="The release's version, as setuptools-scm gives it.") - # PyPI's JSON API can trail an upload by a few minutes. - parser.add_argument("--attempts", type=int, default=6) - parser.add_argument("--delay", type=float, default=30.0, help="Seconds between attempts.") - args = parser.parse_args(argv) - - version = args.version - if not version or any(char.isspace() for char in version): - raise SystemExit(f"'{version}' is not a version.") - for attempt in range(1, args.attempts + 1): - missing = missing_wheels(fetch_filenames(version), version) - if not missing: - print(f"PyPI holds all {len(PYTHONS) * len(PLATFORMS)} wheels of nyxus {version}.") - return 0 - print(f"Attempt {attempt}/{args.attempts}: nyxus {version} lacks {len(missing)} wheels.") - if attempt < args.attempts: - time.sleep(args.delay) - print(f"nyxus {version} is missing these wheels on PyPI: " + ", ".join(missing), file=sys.stderr) - return 1 - - -if __name__ == "__main__": - sys.exit(main())