Skip to content

[build] Consume an external CppInterOp via find_package - #79

Merged
aaronj0 merged 1 commit into
compiler-research:mainfrom
aaronj0:find-package-cppinterop
Sep 4, 2026
Merged

[build] Consume an external CppInterOp via find_package#79
aaronj0 merged 1 commit into
compiler-research:mainfrom
aaronj0:find-package-cppinterop

Conversation

@aaronj0

@aaronj0 aaronj0 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #48, makes the build system robust for purely developement builds:

Development build (CMake)

The build tree runs in place; nothing is installed. CppInterOp builds
and stages inside it, and the python package assembles under
<build>/python:

cmake -S cppjit -B build -DLLVM_DIR=$LLVM_DIR
cmake --build build -j
export PYTHONPATH=$PWD/build/python

A prebuilt CppInterOp, either an install prefix or a build directory,
is consumed in place through CppInterOp_DIR instead of being rebuilt:

cmake -S cppjit -B build -DLLVM_DIR=$LLVM_DIR \
    -DCppInterOp_DIR=$PWD/CppInterOp/build/lib/cmake/CppInterOp

Development build (pip editable)

Editable install with a persistent build directory; a one-file change
rebuilds incrementally:

pip install --no-build-isolation -ve . \
    --config-settings=build-dir=build \
    --config-settings=cmake.define.LLVM_DIR=$LLVM_DIR

To co-develop CppInterOp alongside cppjit, point the build at a local
checkout; it overrides the pinned tag:

git clone https://github.com/compiler-research/CppInterOp.git ../CppInterOp
pip install --no-build-isolation -ve . \
    --config-settings=build-dir=build-local \
    --config-settings=cmake.define.LLVM_DIR=$LLVM_DIR \
    --config-settings=cmake.define.CPPINTEROP_SOURCE_DIR=$PWD/../CppInterOp

Keep the checkout API-compatible with the pinned CPPINTEROP_GIT_TAG in
CMakeLists.txt.

Verify the install

Run from a directory outside the checkout; the in-tree python/cppjit
shadows the installed extension:

cd /tmp && python -c "import cppjit
cppjit.cppdef('int f(int x) { return x + 1; }')
print(cppjit.gbl.f(41))"   # 42

Tests

pip install -r requirements.txt
sudo apt-get install -y libboost-dev libeigen3-dev  # optional; those tests skip without them
cd test
make -j4                          # builds the *Dict.so dictionaries the tests load
python -m pytest -ra --tb=short

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! That works for me too!

@aaronj0
aaronj0 requested a review from vgvassilev September 4, 2026 11:50
@aaronj0
aaronj0 merged commit f665c8a into compiler-research:main Sep 4, 2026
41 of 44 checks passed
@aaronj0
aaronj0 deleted the find-package-cppinterop branch September 4, 2026 14:27
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

CppJIT CI has detected a new failure on workflow CI running on main while building f665c8a at job "macos-26-intel/llvm22/py3.12/c++20 / Build & Test", "macos-26-intel/llvm21/py3.14/c++20 / Build & Test".

Full details are available at: https://github.com/compiler-research/cppjit/actions/runs/33883861337
Here is the relevant piece of the build log for the reference

Step "Build and test" failure:
  Python3_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.12.10/x64
  LLVM_DIR: /Users/runner/work/cppjit/cppjit/install/lib/cmake/llvm
  Clang_DIR: /Users/runner/work/cppjit/cppjit/install/lib/cmake/clang
##[endgroup]
(node:20503) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
With the provided path, there will be 1 file uploaded
Artifact name is valid!
Root directory input is valid!
Beginning upload of artifact content to blob storage
(node:20503) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
Uploaded bytes 229
Finished uploading artifact content to blob storage!
SHA256 digest of uploaded artifact zip is b5ac67fdb671f18da4ebf25d8f1150ad43c7c713f7a2232546028d57af1f8d91
Finalizing artifact upload
Artifact result-macos-26-intel-llvm22-py3.12-cxx20.zip successfully finalized. Artifact ID 9941791401
Artifact result-macos-26-intel-llvm22-py3.12-cxx20 has been successfully uploaded! Final size is 229 bytes. Artifact ID is 9941791401
Artifact download URL: https://github.com/compiler-research/cppjit/actions/runs/33883861337/artifacts/9941791401
Post job cleanup.
Node 20 is being deprecated. This workflow is running with Node 24 by default. If you need to temporarily use Node 20, you can set the ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true environment variable. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
Post job cleanup.
[command]/usr/local/bin/git version
git version 2.55.0
Copying '/Users/runner/.gitconfig' to '/Users/runner/work/_temp/8225f954-16f4-43cf-8e39-84c6abb26478/.gitconfig'
Temporarily overriding HOME='/Users/runner/work/_temp/8225f954-16f4-43cf-8e39-84c6abb26478' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]/usr/local/bin/git config --global --add safe.directory /Users/runner/work/cppjit/cppjit
[command]/usr/local/bin/git config --local --name-only --get-regexp core\.sshCommand
[command]/usr/local/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
[command]/usr/local/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
http.https://github.com/.extraheader
[command]/usr/local/bin/git config --local --unset-all http.https://github.com/.extraheader
[command]/usr/local/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
[command]/usr/local/bin/git config --local --name-only --get-regexp ^includeIf\.gitdir:
[command]/usr/local/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
Evaluate and set job outputs
Set output 'summary'
Cleaning up orphan processes
##[warning]Node.js 20 is deprecated. The following actions target Node.js 20 but are being forced to run on Node.js 24: actions/checkout@v4, actions/setup-python@v5, actions/upload-artifact@v4. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants