Skip to content

Commit

Permalink
Note down useful testing script for local Python API integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Sep 29, 2024
1 parent 035f7a7 commit 51118da
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions wrappers/python/src/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Script to run tests from the repo root on an M* macOS:

```py
bin="$PWD/target/release/pagefind"
ext="$PWD/target/release/pagefind_extended"

cd wrappers/python

# set up the python virtual environment
poetry install --no-root # for dev dependencies
export VIRTUAL_ENV="${PWD}/.venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"

# build and install the binary-only wheels

python3 -m scripts.build.binary_only_wheel \
--llvm-triple="aarch64-apple-darwin" \
--bin-path=$bin \
--version=1.1.0

python3 -m scripts.build.binary_only_wheel \
--llvm-triple="aarch64-apple-darwin" \
--bin-path=$ext \
--version=1.1.0

python3 -m scripts.build.api_package

poetry build # build the source-only distribution for the python API
# install all the wheels
pip install ./dist/*.whl --force-reinstall
pip show --verbose pagefind
pip show --verbose pagefind_bin
pip show --verbose pagefind_bin_extended
python3 --version

LOG_LEVEL="DEBUG" python3 ./src/tests/integration.py 2>&1 | tee /tmp/integration_test.log
```

1 comment on commit 51118da

@SKalt
Copy link
Contributor

@SKalt SKalt commented on 51118da Sep 29, 2024

Choose a reason for hiding this comment

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

This is tangential, but have you considered using direnv(1) to handle setting project-specific environment variables? I find it's fairly helpful; here's what I've got in my top-level .envrc:

#!/usr/bin/env bash
use flake # pushes copies of a rust toolchain, python, node, hugo, etc. to the front of my $PATH
if [ -d "$PWD/wrappers/python/.venv" ]; then
  export VIRTUAL_ENV="$PWD/wrappers/python/.venv"
  export PATH="$VIRTUAL_ENV/bin:$PATH"
fi

Please sign in to comment.