agents/docs/development-setup.md
This guide covers setting up your local development environment for Salt development.
Salt development requires setting up two virtual environments:
This environment is used for testing on 3006.x and 3007.x branches.
# Create virtual environment
python3.10 -m venv venv310
# Activate
source venv310/bin/activate
# Upgrade pip
pip install --upgrade pip setuptools wheel
# Install platform-specific dependencies (choose your OS)
# Linux:
pip install -r requirements/static/pkg/py3.10/linux.txt
# macOS:
pip install -r requirements/static/pkg/py3.10/darwin.txt
# Windows:
pip install -r requirements/static/pkg/py3.10/windows.txt
# Install pytest requirements
pip install -r requirements/pytest.txt
# Install Salt in editable mode
pip install -e .
# Install tools dependencies (for using tools/ commands)
pip install -r requirements/static/ci/py3.10/tools.txt
# Install pre-commit and python-tools-scripts
pip install pre-commit python-tools-scripts
# Deactivate
deactivate
This environment is used for testing on master branch and running pre-commit hooks.
# Create virtual environment
python3.11 -m venv venv311
# Activate
source venv311/bin/activate
# Upgrade pip
pip install --upgrade pip setuptools wheel
# Install platform-specific dependencies (choose your OS)
# Linux:
pip install -r requirements/static/pkg/py3.11/linux.txt
# macOS:
pip install -r requirements/static/pkg/py3.11/darwin.txt
# Windows:
pip install -r requirements/static/pkg/py3.11/windows.txt
# Install pytest requirements
pip install -r requirements/pytest.txt
# Install Salt in editable mode
pip install -e .
# Install tools dependencies
pip install -r requirements/static/ci/py3.11/tools.txt
# Install pre-commit and python-tools-scripts
pip install pre-commit python-tools-scripts
# Install pre-commit hooks
pre-commit install
# Deactivate
deactivate
python -m tools)# Test Salt import
./venv310/bin/python -c "import salt.version; print(salt.version.__version__)"
# Run a simple test
./venv310/bin/pytest tests/pytests/unit/test_loader.py -v
# Test tools
./venv310/bin/python -m tools --help
When running tests or tools, always use the full path to the venv executable or activate the venv first. This ensures you're using the correct Python environment with all dependencies installed.
Good examples:
./venv310/bin/pytest tests/pytests/unit/test_foo.py -v
./venv311/bin/pre-commit run --files salt/loader/lazy.py
./venv310/bin/python -m tools ts pytest run tests/pytests/unit/
Alternatively, activate first:
source venv310/bin/activate
pytest tests/pytests/unit/test_foo.py -v
deactivate
If you see this error when running python -m tools, you need to install the tools dependencies:
./venv310/bin/pip install -r requirements/static/ci/py3.10/tools.txt
./venv310/bin/pip install python-tools-scripts
If you get "No such file or directory" for venv paths, make sure you've created the virtual environment and are running commands from the repository root directory.
On some systems you may need to use python3.10 and python3.11 explicitly instead of just python3.
Make sure you've run pre-commit install in the venv311 environment:
source venv311/bin/activate
pre-commit install
deactivate