mirror of
https://github.com/esphome/esphome.git
synced 2026-08-18 03:59:08 +08:00
45 lines
1.2 KiB
Bash
Executable File
45 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Set up ESPHome dev environment
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "$0")/.."
|
|
if [ -n "$VIRTUAL_ENV" ]; then
|
|
# A virtual environment is already active (e.g. the devcontainer's pre-provisioned
|
|
# esphome-venv). Install into it rather than creating a ./venv in the workspace.
|
|
created_venv=false
|
|
else
|
|
created_venv=true
|
|
if [ -x "$(command -v uv)" ]; then
|
|
uv venv --seed venv
|
|
else
|
|
python3 -m venv venv
|
|
fi
|
|
source venv/bin/activate
|
|
fi
|
|
|
|
if ! [ -x "$(command -v uv)" ]; then
|
|
python3 -m pip install uv
|
|
fi
|
|
|
|
uv pip install setuptools wheel
|
|
uv pip install -e ".[dev,test]" --config-settings editable_mode=compat
|
|
|
|
# --overwrite replaces any hook already in place. Without it, prek finds a
|
|
# previously installed pre-commit hook, moves it aside to
|
|
# .git/hooks/pre-commit.legacy and keeps calling it, so every commit would
|
|
# run both tools.
|
|
prek install --overwrite
|
|
|
|
mkdir -p .temp
|
|
|
|
echo
|
|
echo
|
|
if [ "$created_venv" = true ]; then
|
|
echo "Virtual environment created at ./venv. Run 'source venv/bin/activate' to use it."
|
|
else
|
|
echo "Dependencies installed into the active virtual environment:"
|
|
echo " $VIRTUAL_ENV"
|
|
echo "It is already active in this shell, so no 'source venv/bin/activate' is needed."
|
|
fi
|