Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
aliddell committed Oct 23, 2024
2 parents 9a282e7 + 7d6dd61 commit b205594
Show file tree
Hide file tree
Showing 14 changed files with 1,114 additions and 30 deletions.
57 changes: 54 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- "main"
pull_request: # TODO (aliddell): remove this
branches:
- "main"

jobs:
windows-and-linux-build:
Expand Down Expand Up @@ -93,12 +96,12 @@ jobs:

- name: Build for x64
run: |
cmake --preset=default -DVCPKG_TARGET_TRIPLET=x64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-x64 -B ${{github.workspace}}/build-x64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_OSX_ARCHITECTURES="x86_64" -DNOTEST=1
cmake --preset=default -DVCPKG_TARGET_TRIPLET=x64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-x64 -B ${{github.workspace}}/build-x64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_OSX_ARCHITECTURES="x86_64" -DBUILD_TESTING=OFF
cmake --build ${{github.workspace}}/build-x64 --config ${{matrix.build_type}}
- name: Build for arm64
run: |
cmake --preset=default -DVCPKG_TARGET_TRIPLET=arm64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-arm64 -B ${{github.workspace}}/build-arm64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_OSX_ARCHITECTURES="arm64" -DNOTEST=1
cmake --preset=default -DVCPKG_TARGET_TRIPLET=arm64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-arm64 -B ${{github.workspace}}/build-arm64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_OSX_ARCHITECTURES="arm64" -DBUILD_TESTING=OFF
cmake --build ${{github.workspace}}/build-arm64 --config ${{matrix.build_type}}
- name: Create a universal binary
Expand All @@ -114,4 +117,52 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: macos-latest ${{matrix.build_type}} binaries
path: ${{github.workspace}}/*.zip
path: ${{github.workspace}}/*.zip

build-wheel:
strategy:
matrix:
platform:
- "windows-latest"
- "ubuntu-latest"
- "macos-latest" # TODO (aliddell): universal binary?

runs-on: ${{ matrix.platform }}

permissions:
actions: write

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
with:
submodules: true

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg && ./bootstrap-vcpkg.sh
echo "VCPKG_ROOT=${{github.workspace}}/vcpkg" >> $GITHUB_ENV
echo "${{github.workspace}}/vcpkg" >> $GITHUB_PATH
./vcpkg integrate install
shell: bash

- name: Install dependencies
run: python -m pip install -U pip "pybind11[global]" cmake build

- name: Build
run: python -m build

- name: Upload wheel
uses: actions/upload-artifact@v3
with:
path: ${{github.workspace}}/dist/*.whl
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

- name: Package
run: |
cmake --preset=default -DVCPKG_TARGET_TRIPLET=${{matrix.vcpkg_triplet}} -B ${{github.workspace}}/pack -DCMAKE_BUILD_TYPE=Release -DNOTEST=1
cmake --preset=default -DVCPKG_TARGET_TRIPLET=${{matrix.vcpkg_triplet}} -B ${{github.workspace}}/pack -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
cmake --build ${{github.workspace}}/pack --config Release
cpack --config ${{github.workspace}}/pack/CPackConfig.cmake -C Release -G ZIP
Expand Down Expand Up @@ -93,12 +93,12 @@ jobs:

- name: Build for x64
run: |
cmake --preset=default -DVCPKG_TARGET_TRIPLET=x64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-x64 -B ${{github.workspace}}/build-x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64" -DNOTEST=1
cmake --preset=default -DVCPKG_TARGET_TRIPLET=x64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-x64 -B ${{github.workspace}}/build-x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64" -DBUILD_TESTING=OFF
cmake --build ${{github.workspace}}/build-x64 --config Release
- name: Build for arm64
run: |
cmake --preset=default -DVCPKG_TARGET_TRIPLET=arm64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-arm64 -B ${{github.workspace}}/build-arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64"
cmake --preset=default -DVCPKG_TARGET_TRIPLET=arm64-osx -DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg-arm64 -B ${{github.workspace}}/build-arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64" -DBUILD_TESTING=OFF
cmake --build ${{github.workspace}}/build-arm64 --config Release
- name: Test # don't release if tests are failing
Expand Down
54 changes: 48 additions & 6 deletions .github/workflows/test_pr.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ jobs:
submodules: true
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install minio and mcli
run: |
apt update && apt install -y tmux wget
Expand Down Expand Up @@ -137,4 +132,51 @@ jobs:
ZARR_S3_BUCKET_NAME: ${{ env.MINIO_BUCKET }}
ZARR_S3_ACCESS_KEY_ID: ${{ env.MINIO_ACCESS_KEY }}
ZARR_S3_SECRET_ACCESS_KEY: ${{ env.MINIO_SECRET_KEY }}
run: ctest -C ${{env.BUILD_TYPE}} -L s3 --output-on-failure
run: ctest -C ${{env.BUILD_TYPE}} -L s3 --output-on-failure

test_python:
name: Test on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
platform:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
with:
submodules: true
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg && ./bootstrap-vcpkg.sh
echo "VCPKG_ROOT=${{github.workspace}}/vcpkg" >> $GITHUB_ENV
echo "${{github.workspace}}/vcpkg" >> $GITHUB_PATH
./vcpkg integrate install
shell: bash

- name: Install dependencies
run: python -m pip install -U pip "pybind11[global]" cmake build numpy pytest

- name: Build and install Python bindings
run: python -m pip install .

- name: Run tests
run: python -m pytest -v

73 changes: 66 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,72 @@
.idea
build*/
install
.vscode
.cache
CMakeSettings.json
.vs
TestResults
cmake-build*
.DS_Store
*.zip
_CPack_Packages/
.PVS-Studio

# IDE
.idea
.vscode
.vs

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build*/
cmake-build*/
_CPack_Packages/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.23)
project(acquire-zarr)
cmake_policy(SET CMP0057 NEW) # allows IN_LIST operator (for pybind11)
cmake_policy(SET CMP0079 NEW) # allows use with targets in other directories
enable_testing()

Expand All @@ -19,9 +20,23 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(NOTEST "Disable all tests" OFF)
option(BUILD_PYTHON "Build Python bindings" OFF)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()

add_subdirectory(src)
add_subdirectory(tests)
if (BUILD_TESTING)
add_subdirectory(tests)
else ()
message(STATUS "Skipping test targets")
endif ()

if (${BUILD_PYTHON})
add_subdirectory(python)
else ()
message(STATUS "Skipping Python bindings")
endif ()

include(CPack)
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include CMakeLists.txt
include CMakePresets.json
include vcpkg.json
include vcpkg-configuration.json
include cmake/*.cmake
recursive-include src *
recursive-include include *
recursive-include python *
include LICENSE
include README.md
6 changes: 3 additions & 3 deletions include/acquire.zarr.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ extern "C"
* @return ZarrStatusCode_Success on success, or an error code on failure.
*/
ZarrStatusCode ZarrStream_append(ZarrStream* stream,
const void* data,
size_t bytes_in,
size_t* bytes_out);
const void* data,
size_t bytes_in,
size_t* bytes_out);

#ifdef __cplusplus
}
Expand Down
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"ninja",
"cmake>=3.12",
"pybind11[global]",
]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q --color=yes"
log_cli = true # when true, messages are printed immediately
testpaths = [
"python/tests",
]
26 changes: 26 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
project(acquire-zarr-py)

execute_process(COMMAND python3 -m pybind11 --cmakedir
RESULT_VARIABLE pybind11_NOT_FOUND
OUTPUT_VARIABLE pybind11_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (pybind11_NOT_FOUND)
message(FATAL_ERROR "pybind11 not found in the current environment. Please install pybind11 via pip.")
else ()
LIST(APPEND CMAKE_MODULE_PATH ${pybind11_DIR})
cmake_path(CONVERT CMAKE_MODULE_PATH TO_CMAKE_PATH_LIST CMAKE_MODULE_PATH)
endif ()

find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11 REQUIRED)

pybind11_add_module(acquire_zarr acquire-zarr-py.cpp)

target_include_directories(acquire_zarr PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(acquire_zarr PRIVATE acquire-zarr)

set_target_properties(acquire_zarr PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)
Loading

0 comments on commit b205594

Please sign in to comment.