From 5f5e6eff88fb92b809246fba3215bb656eca5693 Mon Sep 17 00:00:00 2001 From: Alex Allmont Date: Thu, 15 Jan 2026 13:43:58 +0000 Subject: [PATCH] build: experimental roughpy jax wheel build - First draft attempting to build roughpy-jax wheel directly from the roughpy_jax/ sub directory. - Local build only, run test_build.sh in roughpy_jax/ dir. You cannot directly run `python -m build` because it cannot access files in parent folder, instead the shell script copies them to a `_deps` subdir. - Note that although this builds locally testing on Linux, when pip installing and running `import roughpy_jax` in python, it fails with `ImportError: dynamic module does not define module export function (PyInit__rpy_jax_internals)` --- roughpy_jax/CHANGELOG | 2 ++ roughpy_jax/CMakeLists.txt | 27 ++++++++++++++ roughpy_jax/README.md | 3 ++ roughpy_jax/pyproject.toml | 73 ++++++++++++++++++++++++++++++++++++++ roughpy_jax/test_build.sh | 21 +++++++++++ 5 files changed, 126 insertions(+) create mode 100644 roughpy_jax/CHANGELOG create mode 100644 roughpy_jax/README.md create mode 100644 roughpy_jax/pyproject.toml create mode 100755 roughpy_jax/test_build.sh diff --git a/roughpy_jax/CHANGELOG b/roughpy_jax/CHANGELOG new file mode 100644 index 000000000..41314ed9f --- /dev/null +++ b/roughpy_jax/CHANGELOG @@ -0,0 +1,2 @@ +Unreleased + - roughpy_jax diff --git a/roughpy_jax/CMakeLists.txt b/roughpy_jax/CMakeLists.txt index 5000d7e11..a820c0c91 100644 --- a/roughpy_jax/CMakeLists.txt +++ b/roughpy_jax/CMakeLists.txt @@ -1,3 +1,20 @@ +if(ROUGHPY_TEST_BUILD) + # FIXME experimental wheel building work see test_build for notes + + # If running python build, this is the CMakeLists.txt root, so need cmake version + cmake_minimum_required(VERSION 3.28) + + if (NOT EXISTS "_deps/find_python.cmake") + message(FATAL_ERROR "Cannot find find_python.cmake. Please run via test_build.sh") + endif() + + if (NOT EXISTS "_deps/roughpy_compute") + message(FATAL_ERROR "Cannot find roughpy_compute. Please run via test_build.sh") + endif() + + include(_deps/find_python.cmake) +endif() + project(RoughPy_JaxModule LANGUAGES CXX) # Optionally enable CUDA build @@ -27,6 +44,9 @@ execute_process( "-c" "from jax import ffi; print(ffi.include_dir())" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE XLA_DIR ) +if ("${XLA_DIR}" STREQUAL "") + message(FATAL_ERROR "Could not find XLA include directory") +endif() message(STATUS "XLA include directory: ${XLA_DIR}") python_add_library(RoughPy_JaxModule MODULE @@ -62,6 +82,13 @@ target_include_directories(RoughPy_JaxModule PRIVATE ${CMAKE_CURRENT_LIST_DIR}/.. ) +if (ROUGHPY_TEST_BUILD) + # FIXME experimental work as above with _deps + target_include_directories(RoughPy_JaxModule PRIVATE + _deps + ) +endif () + # Use same naming convention as rpy_compute (except without cpython versioning) set_target_properties(RoughPy_JaxModule PROPERTIES PREFIX "") set_target_properties(RoughPy_JaxModule PROPERTIES diff --git a/roughpy_jax/README.md b/roughpy_jax/README.md new file mode 100644 index 000000000..1d1b4906f --- /dev/null +++ b/roughpy_jax/README.md @@ -0,0 +1,3 @@ +# roughpy-jax + +roughpy-jax wraps RoughPy in the JAX framework for working with streaming data as rough paths, and working with algebraic objects such as free tensors, shuffle tensors, and elements of the free Lie algebra. diff --git a/roughpy_jax/pyproject.toml b/roughpy_jax/pyproject.toml new file mode 100644 index 000000000..9d2a90047 --- /dev/null +++ b/roughpy_jax/pyproject.toml @@ -0,0 +1,73 @@ +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "scikit-build-core>=0.11", + "setuptools>=61", + "wheel", + "jax" +] + +[project] +name = "roughpy-jax" +version = "0.0.1" +dynamic = ["readme"] +description = "" +authors = [ + { name = "The RoughPy Authors", email = "info@datasig.ac.uk" } +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Topic :: Scientific/Engineering :: Mathematics", + "License :: OSI Approved :: BSD License", + "Programming Language :: C++", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS" +] +dependencies = [ + "jax", +] + +[tool.scikit-build] +cmake.args = [ + "-DROUGHPY_TEST_BUILD=ON", + "-DROUGHPY_BUILD_PYLIB=ON" +] +build.verbose = true +cmake.build-type = "Release" +experimental=true +metadata.readme.provider = "scikit_build_core.metadata.fancy_pypi_readme" + +[tool.hatch.metadata.hooks.fancy-pypi-readme] +content-type = "text/markdown" + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]] +path = "README.md" + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]] +text = "# Changelog\n\n" + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]] +path = "CHANGELOG" + +[tool.cibuildwheel] +skip = [ + "*win32", + "*-musl*", + "pp*", + "*linux_i686", + "*universal2", + "cp3{6,7,8}-*", + "cp3{9}-macos*" +] +build-verbosity=1 diff --git a/roughpy_jax/test_build.sh b/roughpy_jax/test_build.sh new file mode 100755 index 000000000..1184f7328 --- /dev/null +++ b/roughpy_jax/test_build.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# FIXME experimental test build of roughpy-jax wheel +# +# Python build cannot access files in the parent folder so cmake/ and roughpy_compute/ +# directories are copied in here into _deps folder used in CMakeLists.txt. +# +# Possible workarounds: +# - Move roughpy_jax into a separate repo and bring in RoughPy as a submodule or CMake find +# - Remove roughpy_jax/pyproject.toml and instead build roughpy-jax from root project + +echo "Copying python build deps..." +rm -rf _deps +mkdir _deps +cp ../cmake/find_python.cmake _deps +cp -r ../roughpy_compute _deps + +echo "Building wheel..." +python -m build --wheel + +echo "Done!"