xo-umbrella2/xo-pyexpression
Roland Conybeare 03a542b4dd
Some checks failed
cmake-docker / cmake-build (clang, clang++) (push) Failing after 13m12s
cmake-docker / cmake-build (gcc, g++) (push) Failing after 13m7s
CI / smoke-test (push) Has been cancelled
xo-cmake: generate python module #includes [HYGIENE]
2026-09-13 12:00:21 -04:00
..
cmake xo-pyexpression: + cmake bootstrap [PKG] 2026-06-06 22:34:37 -04:00
include git subrepo clone (merge) git@github.com:Rconybea/xo-pyexpression.git xo-pyexpression 2026-06-06 22:34:33 -04:00
src/pyexpression xo-cmake: generate python module #includes [HYGIENE] 2026-09-13 12:00:21 -04:00
.gitignore git subrepo clone (merge) git@github.com:Rconybea/xo-pyexpression.git xo-pyexpression 2026-06-06 22:34:33 -04:00
.gitrepo git subrepo push xo-pyexpression 2026-06-07 00:06:11 -04:00
CMakeLists.txt git subrepo clone (merge) git@github.com:Rconybea/xo-pyexpression.git xo-pyexpression 2026-06-06 22:34:33 -04:00
README.md move python extensions into xo namespace [REFACTOR] 2026-09-13 11:51:33 -04:00

python bindings for Egad abstract syntax tree library (xo-expression)

Getting Started

Build + install xo-cmake dependency

Installs a few cmake ingredients, along with a build assistant xo-build for XO projects such as this one.

Build + install other necessary XO dependencies

$ xo-build --clone --configure --build --install xo-indentlog
$ xo-build --clone --configure --build --install xo-refnct
$ xo-build --clone --configure --build --install xo-subsys
$ xo-build --clone --configure --build --install xo-reflect
$ xo-build --clone --configure --build --install xo-expression
$ xo-build --clone --configure --build --install xo-jit
$ xo-build --clone --configure --build --install xo-pyutil

copy xo-pyexpression repository locally

$ xo-build --clone xo-pyexpression`

or equivalently

$ git clone git@github.com:Rconybea/xo-pyexpression.git

build + install xo-pyexpression

$ xo-build --configure --build --install xo-pyexpression

or equivalently:

$ PREFIX=/usr/local         # or preferred install location
$ cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -S xo-pyexpression -B xo-pyyexpression/.build
$ cmake --build xo-pyexpression/.build -j
$ cmake --install xo-pyexpression/.build

(also see .github/workflows/main.yml)

Examples

Assumes xo-pyexpression installed to ~/local2/lib/python, i.e. built with PREFIX=~/local2.

PYTHONPATH=~/local2/lib/python:$PYTHONPATH python
>>> import xo.expression
>>> dir(xo.expression)
['Expression', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'exprtype']

Development

use from build tree

Requires that supporting libraries (e.g. xo.reflect) appear in PYTHONPATH

$ cd xo-pyexpression/.build/src/pyexpression
$ python
>>> import xo.expression

build for unit test coverage

$ cd xo-pyexpression
$ cmake -DCMAKE_BUILD_TYPE=coverage -DENABLE_TESTING=on -S . -B .build-ccov
$ cmake --build .build-ccov -j

LSP (language server) support

LSP looks for compile commands in the root of the source tree; while Cmake creates them in the root of its build directory.

$ cd xo-pyexpression
$ ln -s .build/compile_commands.json  # supply compile commands to LSP

display cmake variables

  • -L list variables
  • -A include 'advanced' variables
  • -H include help text
$ cd xo-pyexpression/.build
$ cmake -LAH