Back to Mem0

Development

cli/python/development.md

2.0.12.2 KB
Original Source

Development

Prerequisites

  • Python 3.10+
  • make (optional — you can use plain Python commands instead)

All commands below should be run from the python/ directory:

bash
cd python

Setup

All make targets automatically create a virtual environment (.venv/) and install the required dependencies — no manual setup needed.

bash
# Install the CLI in editable mode
make install

# Install with dev tools (tests + linting)
make dev

Using Python directly

bash
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip

# Install in editable mode
pip install -e .

# With dev tools
pip install -e ".[dev]"

Make targets

TargetDescription
make installCreate venv and install the CLI (editable mode)
make devCreate venv and install CLI + dev dependencies
make testRun all tests (installs dev deps if needed)
make lintRun linter and format check
make formatAuto-fix lint issues and format code
make buildBuild distribution packages
make cleanRemove dist/
make publishBuild and publish to PyPI
make publish-testBuild and publish to Test PyPI
make shellOpen a new shell with the venv activated

Run tests

bash
# Using Make
make test

# Using Python directly
pytest

# Run a specific test file
pytest tests/test_cli_integration.py

# Run a single test
pytest -k test_help

Run the CLI

bash
# Using Make — drop into an activated shell
make shell
mem0 --help

# Using Python directly (with venv activated)
source .venv/bin/activate
mem0 --help
mem0 version

# Or run without activating
.venv/bin/mem0 --help

Lint

bash
# Using Make
make lint      # check only
make format    # auto-fix

# Using Python directly (with venv activated)
ruff check .
ruff format .

Optional extras

OSS integration

bash
pip install -e ".[oss]"