Loading...
Loading...
Set up Python test environment in Claude Code for web where flox is unavailable. Use when you need to run backend tests and `uv sync` fails due to Python version mismatch.
npx skill4agent add posthog/posthog setup-web-testspyproject.tomlrequires-pythonuv python install <version>uv syncpyproject.toml# Auto-detect the required version from pyproject.toml
REQUIRED_VERSION=$(grep requires-python pyproject.toml | grep -oP '[\d.]+')
echo "Required Python: $REQUIRED_VERSION"
# Get the latest release tag from python-build-standalone
RELEASE_TAG=$(curl -sL "https://api.github.com/repos/astral-sh/python-build-standalone/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
# Find and download the matching build
DOWNLOAD_URL=$(curl -sL "https://api.github.com/repos/astral-sh/python-build-standalone/releases/latest" | \
grep "browser_download_url" | grep "$REQUIRED_VERSION" | grep "x86_64-unknown-linux-gnu-install_only.tar.gz" | head -1 | cut -d'"' -f4)
mkdir -p /tmp/python-install && cd /tmp/python-install
curl -L -o python.tar.gz "$DOWNLOAD_URL"
tar -xzf python.tar.gz
# Verify
/tmp/python-install/python/bin/python3 --versioncpython-<version>+<tag>-x86_64-unknown-linux-gnu-install_only.tar.gzcd /home/user/posthog
uv sync --python /tmp/python-install/python/bin/python3
source .venv/bin/activate
# Run a specific test
pytest path/to/test.py::TestClass::test_method -v
# Run all tests in a directory
pytest posthog/hogql/test/ -vdocker compose -f docker-compose.dev.yml up -ddocker-compose.dev.ymlecho "127.0.0.1 kafka clickhouse clickhouse-coordinator objectstorage" | sudo tee -a /etc/hosts.github/workflows/ci-backend.ymlenv:.env.example.envmkdir -p frontend/dist
touch frontend/dist/index.html
touch frontend/dist/layout.html
touch frontend/dist/exporter.htmlsudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-opensslpytest.inipythonpath = . commonDJANGO_SETTINGS_MODULE = posthog.settingsDEBUG=1TEST=1--ignore=posthog/user_scripts --ignore=services/llm-gateway --ignore=common/ingestion/acceptance_tests.github/workflows/ci-backend.yml