Skip to content

Commit

Permalink
Migrate build system to scikit-build-core (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins authored Oct 5, 2023
1 parent 51db1d5 commit 7fe0101
Show file tree
Hide file tree
Showing 24 changed files with 108 additions and 94 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ set(CMAKE_JOB_POOL_COMPILE "compile")
set(CMAKE_JOB_POOL_LINK "link")
set(CMAKE_JOB_POOLS "compile=${ncores};link=2")

set(ARCAE_LIB_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/arcae/lib)

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
Expand All @@ -22,13 +21,13 @@ endif(CCACHE_FOUND)

include(FindPyArrow)
include(SetupVCPKG)
project(main CXX C)
project(arcae CXX)

include_directories(cpp)
add_subdirectory(cpp)

if(SKBUILD)
add_subdirectory(arcae)
add_subdirectory(src/arcae)
else()
message(WARNING "scikit-build not available, Cython extensions not built")
endif()
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ History

X.Y.Z (YYYY-MM-DD)
------------------
* Migrate build system to scikit-build-core (:pr:`61`)
* Upgrade to Cython 3 and pyarrow 13.0.0 (:pr:`60`)
* Introduce a more canonical C++ project structure (:pr:`57`. :pr:`59`)
* Consistently use CamelCase throughout the C++ layer (:pr:`56`)
Expand Down
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In the user or, even better, a virtual environment:
.. code-block:: python
$ pip install -U pip cibuildwheel
$ bash scripts/run_cbuildwheel.sh -p 3.8
$ bash scripts/run_cbuildwheel.sh -p 3.10
.. warning::
Only linux wheels are currently supported.
Expand All @@ -35,9 +35,8 @@ In the directory containing the source, setup your development environment as fo
.. code-block:: python
$ pip install -U pip virtualenv
$ virtualenv -p python3.8 /venv/arcaedev
$ virtualenv -p python3.10 /venv/arcaedev
$ . /venv/arcaedev/bin/activate
# Edit pyproject.toml with instructions in https://github.com/ratt-ru/arcae/issues/52
(arcaedev) export VCPKG_TARGET_TRIPLET=x64-linux-dynamic-cxx17-abi1-dbg
(arcaedev) pip install -e .[test]
(arcaedev) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/vcpkg/installed/$VCPKG_TARGET_TRIPLET/lib
Expand Down
28 changes: 0 additions & 28 deletions arcae/CMakeLists.txt

This file was deleted.

3 changes: 3 additions & 0 deletions cmake_modules/FindPyArrow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ if(NOT DEFINED NUMPY_INCLUDE)
message(FATAL_ERROR "Unable to find numpy include directory. Set NUMPY_INCLUDE")
endif()


if(NOT DEFINED PYARROW_INCLUDE AND DEFINED ENV{PYARROW_INCLUDE})
set(PYARROW_INCLUDE ENV{PYARROW_INCLUDE})
endif()

execute_process(COMMAND ${Python_EXECUTABLE} -c "import pyarrow; pyarrow.create_library_symlinks()")

if(NOT DEFINED PYARROW_INCLUDE AND Python_Interpreter_FOUND)
execute_process(COMMAND ${Python_EXECUTABLE} -c "import pyarrow; print(pyarrow.get_include())"
OUTPUT_VARIABLE PYARROW_INCLUDE
Expand Down
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ target_compile_options(arcae PUBLIC "-D_GLIBCXX_USE_CXX11_ABI=1")
set_target_properties(arcae PROPERTIES
POSITION_INDEPENDENT_CODE 1)

install(TARGETS arcae LIBRARY DESTINATION ${ARCAE_LIB_INSTALL_PATH})
install(TARGETS arcae LIBRARY DESTINATION arcae/lib)
55 changes: 48 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
[project]
name = "arcae"
version = "0.1.0"
authors = [
{name = "Simon Perkins", email = "[email protected]"}
]
description = "Arrow bindings for casacore"
readme = {file = "README.rst", content-type = "test/rst"}
requires_python = ">= 3.8"
license = {file = "LICENSE"}
classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3"
]
dependencies = [
"appdirs",
"click",
"rich",
"pyarrow == 13.0.0"
]

[project.optional-dependencies]
dev = [
"black == 22.1.0",
"flake8 == 4.0.1",
"tbump"
]
test = [
"duckdb",
"pytest >= 7.0.0",
"python-casacore >= 3.5.0",
"requests"
]

[project.scripts]
arcae = "arcae.applications.entrypoint:main"

[project.urls]
Repository = "https://github.com/ratt-ru/arcae"

[build-system]
requires = [
"setuptools",
"cmake>=3.18",
"cython>=3.0.2",
"ninja; platform_system!='Windows'",
"numpy>=1.24.1,<2.0.0",
"requires",
"scikit-build>=0.16.7",
"scikit-build-core",
"pyarrow == 13.0.0"]
build-backend = "setuptools.build_meta"
build-backend = "scikit_build_core.build"

[tools.setuptools.packages]
find = {}

[tool.scikit-build]
# build-dir = "/tmp/arcae"
1 change: 1 addition & 0 deletions scripts/run_cibuildwheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export MANYLINUX_PLATFORM=manylinux_x86_64
export CIBW_BUILD=$CPYTHON_VERSION-$MANYLINUX_PLATFORM
export CIBW_BUILD_FRONTEND=build
export CIBW_BEFORE_ALL_LINUX="yum install -y zip flex bison gcc-gfortran"
export CIBW_MANYLINUX_X86_64_IMAGE="quay.io/pypa/manylinux_2_28_x86_64"
export VCPKG_TARGET_TRIPLET=x64-linux-dynamic-cxx17-abi1-rel
export CIBW_ENVIRONMENT_LINUX="\
VCPKG_DEFAULT_BINARY_CACHE=/host$VCPKG_HOST_BINARY_CACHE \
Expand Down
39 changes: 0 additions & 39 deletions setup.cfg

This file was deleted.

13 changes: 0 additions & 13 deletions setup.py

This file was deleted.

46 changes: 46 additions & 0 deletions src/arcae/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_package(PkgConfig REQUIRED)
find_program(CYTHON_FOUND "cython" REQUIRED)

pkg_check_modules(casacore REQUIRED IMPORTED_TARGET casacore)

add_custom_command(
OUTPUT arrow_tables.cc
VERBATIM
COMMAND cython ${CMAKE_CURRENT_SOURCE_DIR}/arrow_tables.pyx
--output-file ${CMAKE_CURRENT_BINARY_DIR}/arrow_tables.cc
--cplus -vvv)

# Check and correct Python_SOABI if it has an .so suffix
if(${Python_SOABI} MATCHES "\\.so$")
string(REGEX REPLACE "\\.so$" "" Python_SOABI_FIXED "${Python_SOABI}")
message(STATUS "Removing extra .so from ${Python_SOABI}")
else()
set(Python_SOABI_FIXED ${Python_SOABI})
endif()

message(STATUS "Python_SOABI_FIXED: ${Python_SOABI_FIXED}")

python_add_library(arrow_tables MODULE arrow_tables.cc)
set_target_properties(arrow_tables PROPERTIES OUTPUT_NAME "arrow_tables.${Python_SOABI_FIXED}")

target_link_libraries(arrow_tables PUBLIC arcae PkgConfig::casacore)
target_link_directories(arrow_tables PUBLIC ${PYARROW_LIBDIRS})
target_include_directories(arrow_tables PUBLIC
PkgConfig::casacore
${PYARROW_INCLUDE}
${NUMPY_INCLUDE}
${CMAKE_SOURCE_DIR}/cpp)
target_compile_options(arrow_tables PUBLIC "-D_GLIBCXX_USE_CXX11_ABI=1")

string(REPLACE " " ";" _PYARROW_LIBS ${PYARROW_LIBS})

foreach(PYARROW_LIB ${_PYARROW_LIBS})
message("Linking arrow_tables against ${PYARROW_LIB}")
target_link_libraries(arrow_tables PUBLIC ${PYARROW_LIB})
endforeach()

set_target_properties(arrow_tables PROPERTIES
POSITION_INDEPENDENT_CODE 1)

install(TARGETS arrow_tables LIBRARY DESTINATION arcae/lib)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions tbump.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ tag_template = "{new_version}"
[[file]]
src = "arcae/__init__.py"
search = "__version__ = \"{current_version}\""

[[file]]
src = "pyproject.toml"
search = "version = \"{current_version}\""

0 comments on commit 7fe0101

Please sign in to comment.