Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ dist

sandbox.py
sandbox.ipynb

# scratch dir for tools/refresh-from-master.sh (cloned MEOS-API + provisioned MEOS)
.meos-chain/
22 changes: 18 additions & 4 deletions builder/build_pymeos.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,28 @@
ffibuilder.cdef(content)


def get_library_dirs():
paths = ["/usr/local/lib", "/opt/homebrew/lib"]
# A MEOS install prefix may be supplied out of band so the extension can be built
# against a MEOS that is not on the default system paths (e.g. a scratch prefix used
# by tools/refresh-from-master.sh). MEOS_PREFIX adds <prefix>/lib and <prefix>/include;
# MEOS_LIB_DIR / MEOS_INCLUDE_DIR override a single dir. Unset => unchanged behaviour.
def _search_dirs(single_env, subdir, defaults):
paths = []
explicit = os.environ.get(single_env)
if explicit:
paths.append(explicit)
prefix = os.environ.get("MEOS_PREFIX")
if prefix:
paths.append(os.path.join(prefix, subdir))
paths.extend(defaults)
return [path for path in paths if os.path.exists(path)]


def get_library_dirs():
return _search_dirs("MEOS_LIB_DIR", "lib", ["/usr/local/lib", "/opt/homebrew/lib"])


def get_include_dirs():
paths = ["/usr/local/include", "/opt/homebrew/include"]
return [path for path in paths if os.path.exists(path)]
return _search_dirs("MEOS_INCLUDE_DIR", "include", ["/usr/local/include", "/opt/homebrew/include"])


ffibuilder.set_source(
Expand Down
35 changes: 35 additions & 0 deletions tools/refresh-from-master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# refresh-from-master.sh — refresh this binding's generated surface against the latest MEOS API,
# end to end, with one command:
#
# tools/refresh-from-master.sh
#
# It runs the shared MobilityDB/MEOS-API refresh-binding.sh over this repo — deriving the catalog
# and libmeos from the latest MobilityDB master and regenerating this binding's surface. The
# per-binding last leg is in tools/refresh.conf.
#
# All of refresh-binding.sh's options pass through, e.g.:
# tools/refresh-from-master.sh --mdb ~/src/MobilityDB # refresh against a local MobilityDB branch
# tools/refresh-from-master.sh --skip-tests # regenerate + build, skip the tests
#
# MEOSAPI=<path> uses an existing MEOS-API checkout (any branch); otherwise MEOS-API master is
# cloned into the work dir. WORK_DIR overrides the scratch location (default <repo>/.meos-chain).
set -euo pipefail

HERE="$(cd "$(dirname "$0")/.." && pwd)"
WORK="${WORK_DIR:-$HERE/.meos-chain}"
MEOSAPI="${MEOSAPI:-}"

if [ -z "$MEOSAPI" ]; then
MEOSAPI="$WORK/MEOS-API"
mkdir -p "$WORK"
if [ -d "$MEOSAPI/.git" ]; then
git -C "$MEOSAPI" fetch --quiet https://github.com/MobilityDB/MEOS-API master
git -C "$MEOSAPI" checkout --quiet FETCH_HEAD
else
git clone --quiet https://github.com/MobilityDB/MEOS-API "$MEOSAPI"
fi
fi

exec "$MEOSAPI/tools/refresh-binding.sh" \
--binding "$HERE" --meos-api "$MEOSAPI" --work-dir "$WORK" "$@"
25 changes: 25 additions & 0 deletions tools/refresh.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# refresh.conf — PyMEOS-CFFI's last leg for tools/refresh-binding.sh (in MEOS-API).
# PyMEOS-CFFI pins a RELEASED MEOS line: its package __version__ (X.Y) maps to the
# MobilityDB stable-X.Y branch (see .github/workflows/pr_build.yml), NOT master —
# deriving from master would bind unreleased surface. Keep MDB_REF in step with
# pymeos_cffi/__init__.py __version__ (currently 1.3.0a1 => stable-1.3). The 1.3
# line exposes npoint among the optional families (not cbuffer/pose), so FAMILIES
# lists -DNPOINT=ON.
#
# The chain (MobilityDB -> catalog + libmeos) is shared. refresh-binding.sh stages
# the catalog at CATALOG_DEST (builder/meos-idl.json, where build_pymeos_functions.py
# reads it) and installs libmeos at $PREFIX. BUILD_CMD then regenerates the cdef
# header (build_header.py, from $PREFIX/include) and the wrappers (build_pymeos_functions.py,
# from the catalog), and compiles the CFFI extension against $PREFIX — build_pymeos.py
# honours MEOS_PREFIX — mirroring pr_build.yml's build + smoke.
ENGINE=cffi
BUILD_DIR=.
BUILD_LIBMEOS=true
MDB_REF=stable-1.3
FAMILIES=-DNPOINT=ON
CATALOG_DEST=builder/meos-idl.json
BUILD_CMD='python3 builder/build_header.py "$PREFIX/include" "$PREFIX/lib/libmeos.so"
python3 builder/build_pymeos_functions.py
export MEOS_PREFIX="$PREFIX" LD_LIBRARY_PATH="$PREFIX/lib"
python3 -m pip install . -q
[ -n "${SKIP_TESTS:-}" ] || python3 -c "import pymeos_cffi; assert callable(pymeos_cffi.tstzspan_make)"'
Loading