Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[c++/python/r] Migrate to C++20 #3331

Merged
merged 11 commits into from
Nov 19, 2024
2 changes: 1 addition & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
backport:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
name: Backport
steps:
- name: Backport
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
# This is GitHub Actions magic -- there are no secrets we as package owners need to set up or manage
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/python-ci-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
fail-fast: false
matrix:
# TODO: decide on Windows CI coverage
os: [ubuntu-latest, macos-latest]
# os: [ubuntu-latest, macos-latest, windows-2019]
os: [ubuntu-24.04, macos-latest]
# os: [ubuntu-24.04, macos-latest, windows-2019]
# TODO: add 3.12
# https://github.com/single-cell-data/TileDB-SOMA/issues/1849
python-version: ['3.9', '3.10', '3.11', '3.12']
include:
- runs-on: ubuntu-latest
cc: gcc-11
cxx: g++-11
- runs-on: ubuntu-24.04
cc: gcc-13
cxx: g++-13
- runs-on: macos-latest
cc: clang
cxx: clang++
Expand All @@ -39,6 +39,6 @@ jobs:
python_version: ${{ matrix.python-version }}
cc: ${{ matrix.cc }}
cxx: ${{ matrix.cxx }}
report_codecov: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
run_lint: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
report_codecov: ${{ matrix.os == 'ubuntu-24.04' && matrix.python-version == '3.11' }}
run_lint: ${{ matrix.os == 'ubuntu-24.04' && matrix.python-version == '3.11' }}
secrets: inherit
8 changes: 4 additions & 4 deletions .github/workflows/python-ci-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
fail-fast: true

matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-24.04, macos-latest]
python-version: ['3.9', '3.12']
include:
- os: ubuntu-latest
cc: gcc-11
cxx: g++-11
- os: ubuntu-24.04
cc: gcc-13
cxx: g++-13
- os: macos-latest
cc: clang
cxx: clang++
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/python-ci-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
# Confirm shared object copying when building the Python package
# https://github.com/single-cell-data/TileDB-SOMA/pull/1937
docker:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
name: "SO copying (docker) TILEDB_EXISTS: ${{ matrix.TILEDB_EXISTS }} TILEDBSOMA_EXISTS: ${{ matrix.TILEDBSOMA_EXISTS }}"
strategy:
fail-fast: false
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
# https://github.com/single-cell-data/TileDB-SOMA/pull/1937
# Same as job above, but running on macOS instead of in a Docker container
macos:
runs-on: macos-13
runs-on: macos-latest
name: "SO copying (macos) TILEDB_EXISTS: ${{ matrix.TILEDB_EXISTS }} TILEDBSOMA_EXISTS: ${{ matrix.TILEDBSOMA_EXISTS }}"
strategy:
fail-fast: false
Expand All @@ -168,6 +168,10 @@ jobs:
fetch-depth: 0 # for setuptools-scm
- name: Check if System Integrity Protection (SIP) is enabled
run: csrutil status
- name: Select XCode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Install pre-built libtiledb
if: ${{ matrix.TILEDB_EXISTS == 'yes' }}
run: |
Expand Down Expand Up @@ -259,7 +263,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
os: ["ubuntu-24.04", "macos-latest"]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -364,7 +368,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
os: ["ubuntu-24.04", "macos-latest"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-ci-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
run: echo "inputs.os:" ${{ inputs.os }}

- name: Linux CPU info
if: ${{ inputs.os == 'ubuntu-latest' }}
if: ${{ inputs.os == 'ubuntu-24.04' }}
run: cat /proc/cpuinfo

- name: MacOS CPU info
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/python-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
jobs:
sdist:
name: Build source distribution
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout TileDB-SOMA
uses: actions/checkout@v4
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
cibw_build: [ manylinux_x86_64, macosx_x86_64, macosx_arm64 ]
include:
- cibw_build: manylinux_x86_64
os: ubuntu-latest
os: ubuntu-24.04
wheel-name: manylinux2014
- cibw_build: macosx_x86_64
os: macos-latest
Expand Down Expand Up @@ -84,6 +84,11 @@ jobs:
pip install setuptools
python -c 'from distutils import util; print("distutil.util.get_platform:", util.get_platform())'
python -c 'import platform; print("platform.platform()", platform.platform())'
- name: Select XCode version
if: startsWith(matrix.os, 'macos')
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Build wheels
uses: pypa/[email protected]
with:
Expand Down Expand Up @@ -127,12 +132,12 @@ jobs:
- macos-arm64
include:
- wheel-name: manylinux2014
os: ubuntu-latest
os: ubuntu-24.04
arch: x86_64
cc: gcc-11
cxx: g++-11
cc: gcc-13
cxx: g++-13
- wheel-name: macos-x86_64
os: macos-13
os: macos-latest
arch: x86_64
cc: clang
cxx: clang++
Expand Down Expand Up @@ -166,7 +171,7 @@ jobs:
run: python -c 'import tiledbsoma; print(tiledbsoma.pytiledbsoma.__file__); tiledbsoma.show_package_versions()'
# TODO: more thorough local smoke test
- name: Smoke test in docker
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-24.04' }}
run: |
docker run -v $(pwd):/mnt python:${{ matrix.python.dotted-version }} bash -ec "
apt-get -qq update && apt-get install -y python3-pip python3-wheel
Expand All @@ -178,7 +183,7 @@ jobs:
publish-to-test-pypi:
name: Publish package to TestPyPI
needs: smoke-test
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
if: github.event_name == 'workflow_dispatch'
steps:
- name: Download artifacts
Expand All @@ -202,7 +207,7 @@ jobs:
publish-to-pypi:
name: Publish package to PyPI
needs: smoke-test
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
if: github.event_name == 'release'
steps:
- name: Download artifacts
Expand All @@ -223,7 +228,7 @@ jobs:
# File a bug report if anything fails, but don't file tickets for manual runs
# -- only for scheduled ones.
create_issue_on_fail:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [smoke-test, publish-to-test-pypi, publish-to-pypi]
if: (failure() || cancelled()) && github.event_name != 'workflow_dispatch'
steps:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/r-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
matrix:
include:
- name: linux
os: ubuntu-latest
os: ubuntu-24.04
covr: 'no'
- name: macos
os: macOS-latest
covr: 'no'
- name: coverage
os: ubuntu-latest
os: ubuntu-24.04
covr: 'yes'

runs-on: ${{ matrix.os }}
Expand All @@ -50,7 +50,7 @@ jobs:
run: echo "matrix.os:" ${{ matrix.os }}

- name: Linux CPU info
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-24.04' }}
run: cat /proc/cpuinfo

- name: MacOS CPU info
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
# run: sudo scripts/bld --prefix=/usr/local

#- name: Call ldconfig
# if: ${{ matrix.os == 'ubuntu-latest' }}
# if: ${{ matrix.os == 'ubuntu-24.04' }}
# run: sudo ldconfig
#
# - name: Update Packages
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
run: cd apis/r/tests && Rscript testthat.R

- name: Coverage
if: ${{ matrix.os == 'ubuntu-latest' && matrix.covr == 'yes' && github.event_name == 'workflow_dispatch' }}
if: ${{ matrix.os == 'ubuntu-24.04' && matrix.covr == 'yes' && github.event_name == 'workflow_dispatch' }}
run: apis/r/tools/r-ci.sh coverage

- name: View Logs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/r-python-interop-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
include:
- { os: ubuntu-latest }
- { os: ubuntu-24.04 }

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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/r-valgrind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
r-valgrind:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
container:
image: rocker/r2u:latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion apis/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def run(self):
library_dirs=LIB_DIRS,
libraries=["tiledbsoma"] + (["tiledb"] if os.name == "nt" else []),
extra_link_args=CXX_FLAGS,
extra_compile_args=["-std=c++17" if os.name != "nt" else "/std:c++17"]
extra_compile_args=["-std=c++20" if os.name != "nt" else "/std:c++20"]
+ CXX_FLAGS,
language="c++",
)
Expand Down
2 changes: 1 addition & 1 deletion apis/r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Imports:
nanoarrow
LinkingTo:
Rcpp,
RcppSpdlog,
RcppSpdlog (>= 0.0.19),
RcppInt64,
nanoarrow
Additional_repositories: https://ghrr.github.io/drat
Expand Down
8 changes: 4 additions & 4 deletions apis/r/configure
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ if [ $? -eq 0 ]; then
pkgcflags=`pkg-config --cflags tiledb tiledbsoma`
pkglibs=`pkg-config --libs tiledb tiledbsoma`

## substitute them in (leaving @tiledb_rpath@ and @cxx17_macos@ alone for now)
## substitute them in (leaving @tiledb_rpath@ and @cxx20_macos@ alone for now)
sed -e "s|@tiledb_include@|$pkgcflags |" \
-e "s|@tiledb_libs@|$pkglibs|" \
-e "s|@tiledb_rpath@||" \
-e "s|@cxx17_macos@||" \
-e "s|@cxx20_macos@||" \
src/Makevars.in > src/Makevars

echo "** updated src/Makevars for system library via pkg-config"
Expand Down Expand Up @@ -54,10 +54,10 @@ tools/build_libtiledbsoma.sh
pkgincl="-I../inst/tiledb/include -I../inst/tiledbsoma/include -I../inst/tiledbsoma/include/tiledbsoma"
pkglibs="-ltiledb -L../inst/tiledb/lib -ltiledbsoma -L../inst/tiledbsoma/lib"
rpath="-Wl,-rpath,'\$\$ORIGIN/../tiledb/lib' -Wl,-rpath,'\$\$ORIGIN/../tiledbsoma/lib'"
macosver=`${R_HOME}/bin/Rscript -e 'if (Sys.info()["sysname"] == "Darwin") cat("-mmacosx-version-min=11.0") else cat("")'`
macosver=`${R_HOME}/bin/Rscript -e 'if (Sys.info()["sysname"] == "Darwin") cat("-mmacosx-version-min=13.3") else cat("")'`

sed -e "s|@tiledb_include@|$pkgincl |" \
-e "s|@tiledb_libs@|$pkglibs|" \
-e "s|@tiledb_rpath@|$rpath|" \
-e "s|@cxx17_macos@|$macosver|" \
-e "s|@cxx20_macos@|$macosver|" \
src/Makevars.in > src/Makevars
6 changes: 3 additions & 3 deletions apis/r/src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CXX_STD = CXX17
CXX_STD = CXX20

## We need the TileDB Headers, and for macOS aka Darwin need to set minimum version 10.14 for macOS
PKG_CPPFLAGS = -I. -I../inst/include/ @tiledb_include@ @cxx17_macos@
PKG_CPPFLAGS = -I. -I../inst/include/ @tiledb_include@ @cxx20_macos@ -D SPDLOG_USE_STD_FORMAT

## We also need the TileDB library
PKG_LIBS = @cxx17_macos@ @tiledb_libs@ @tiledb_rpath@
PKG_LIBS = @cxx20_macos@ @tiledb_libs@ @tiledb_rpath@

all: $(SHLIB)
# On macOS aka Darwin we call install_name_tool
Expand Down
4 changes: 2 additions & 2 deletions libtiledbsoma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()

# Set C++17 as required standard for all C++ targets (C++17 minimum is required to use the TileDB C++ API).
set(CMAKE_CXX_STANDARD 17)
# Set C++20 as required standard for all C++ targets (C++17 minimum is required to use the TileDB C++ API).
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # Don't use GNU extensions

Expand Down
11 changes: 6 additions & 5 deletions libtiledbsoma/src/cli/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* This file is currently a sandbox for C++ API experiments
*/

#include <format>
#include "soma/enums.h"
#include "soma/soma_array.h"
#include "utils/arrow_adapter.h"
Expand Down Expand Up @@ -77,8 +78,8 @@ void test_sdf(const std::string& uri) {
total_num_rows += (*batch)->num_rows();
}

LOG_INFO(fmt::format("X/data rows = {}", total_num_rows));
LOG_INFO(fmt::format(" batches = {}", batches));
LOG_INFO(std::format("X/data rows = {}", total_num_rows));
LOG_INFO(std::format(" batches = {}", batches));
}

namespace tdbs = tiledbsoma;
Expand All @@ -89,10 +90,10 @@ void test_arrow(const std::string& uri) {
// Getting next batch: std::optional<std::shared_ptr<ArrayBuffers>>
auto obs_data = obs->read_next();
if (!obs->results_complete()) {
tdbs::LOG_WARN(fmt::format("Read of '{}' incomplete", uri));
tdbs::LOG_WARN(std::format("Read of '{}' incomplete", uri));
exit(-1);
}
tdbs::LOG_INFO(fmt::format(
tdbs::LOG_INFO(std::format(
"Read complete with {} obs and {} cols",
obs_data->get()->num_rows(),
obs_data->get()->names().size()));
Expand All @@ -101,7 +102,7 @@ void test_arrow(const std::string& uri) {
auto buf = obs_data->get()->at(nm);
auto pp = tdbs::ArrowAdapter::to_arrow(buf);
ArrowSchema* schema = pp.second.get();
tdbs::LOG_INFO(fmt::format(
tdbs::LOG_INFO(std::format(
"Accessing '{}', retrieved '{}', n_children {}",
nm,
schema->name,
Expand Down
Loading
Loading