Use uv instead of pip in development env (#113517)
This commit is contained in:
parent
d44f949b19
commit
5e3483ac3c
9 changed files with 49 additions and 28 deletions
|
@ -5,7 +5,6 @@
|
||||||
"postCreateCommand": "script/setup",
|
"postCreateCommand": "script/setup",
|
||||||
"postStartCommand": "script/bootstrap",
|
"postStartCommand": "script/bootstrap",
|
||||||
"containerEnv": {
|
"containerEnv": {
|
||||||
"DEVCONTAINER": "1",
|
|
||||||
"PYTHONASYNCIODEBUG": "1"
|
"PYTHONASYNCIODEBUG": "1"
|
||||||
},
|
},
|
||||||
"features": {
|
"features": {
|
||||||
|
@ -29,7 +28,9 @@
|
||||||
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
|
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
|
||||||
"settings": {
|
"settings": {
|
||||||
"python.experiments.optOutFrom": ["pythonTestAdapter"],
|
"python.experiments.optOutFrom": ["pythonTestAdapter"],
|
||||||
"python.pythonPath": "/usr/local/bin/python",
|
"python.defaultInterpreterPath": "/home/vscode/.local/ha-venv/bin/python",
|
||||||
|
"python.pythonPath": "/home/vscode/.local/ha-venv/bin/python",
|
||||||
|
"python.terminal.activateEnvInCurrentTerminal": true,
|
||||||
"python.testing.pytestArgs": ["--no-cov"],
|
"python.testing.pytestArgs": ["--no-cov"],
|
||||||
"editor.formatOnPaste": false,
|
"editor.formatOnPaste": false,
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
|
|
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
|
@ -103,7 +103,7 @@
|
||||||
{
|
{
|
||||||
"label": "Install all Requirements",
|
"label": "Install all Requirements",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "pip3 install -r requirements_all.txt",
|
"command": "uv pip install -r requirements_all.txt",
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"isDefault": true
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
{
|
{
|
||||||
"label": "Install all Test Requirements",
|
"label": "Install all Test Requirements",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "pip3 install -r requirements_test_all.txt",
|
"command": "uv pip install -r requirements_test_all.txt",
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"isDefault": true
|
||||||
|
|
|
@ -35,21 +35,30 @@ RUN \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install uv
|
||||||
|
RUN pip3 install uv
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
|
|
||||||
# Setup hass-release
|
# Setup hass-release
|
||||||
RUN git clone --depth 1 https://github.com/home-assistant/hass-release \
|
RUN git clone --depth 1 https://github.com/home-assistant/hass-release \
|
||||||
&& pip3 install -e hass-release/
|
&& uv pip install --system -e hass-release/
|
||||||
|
|
||||||
WORKDIR /workspaces
|
USER vscode
|
||||||
|
ENV VIRTUAL_ENV="/home/vscode/.local/ha-venv"
|
||||||
|
RUN uv venv $VIRTUAL_ENV
|
||||||
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
# Install Python dependencies from requirements
|
# Install Python dependencies from requirements
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
COPY homeassistant/package_constraints.txt homeassistant/package_constraints.txt
|
COPY homeassistant/package_constraints.txt homeassistant/package_constraints.txt
|
||||||
RUN pip3 install -r requirements.txt
|
RUN uv pip install -r requirements.txt
|
||||||
COPY requirements_test.txt requirements_test_pre_commit.txt ./
|
COPY requirements_test.txt requirements_test_pre_commit.txt ./
|
||||||
RUN pip3 install -r requirements_test.txt
|
RUN uv pip install -r requirements_test.txt
|
||||||
RUN rm -rf requirements.txt requirements_test.txt requirements_test_pre_commit.txt homeassistant/
|
|
||||||
|
WORKDIR /workspaces
|
||||||
|
|
||||||
# Set the default shell to bash instead of sh
|
# Set the default shell to bash instead of sh
|
||||||
ENV SHELL /bin/bash
|
ENV SHELL /bin/bash
|
||||||
|
|
|
@ -7,6 +7,6 @@ set -e
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
echo "Installing development dependencies..."
|
echo "Installing development dependencies..."
|
||||||
python3 -m pip install wheel --constraint homeassistant/package_constraints.txt --upgrade
|
uv pip install wheel --constraint homeassistant/package_constraints.txt --upgrade
|
||||||
python3 -m pip install colorlog $(grep awesomeversion requirements.txt) --constraint homeassistant/package_constraints.txt --upgrade
|
uv pip install colorlog $(grep awesomeversion requirements.txt) --constraint homeassistant/package_constraints.txt --upgrade
|
||||||
python3 -m pip install -r requirements_test.txt -c homeassistant/package_constraints.txt --upgrade
|
uv pip install -r requirements_test.txt -c homeassistant/package_constraints.txt --upgrade
|
||||||
|
|
|
@ -268,7 +268,7 @@ def install_requirements(integration: Integration, requirements: set[str]) -> bo
|
||||||
if is_installed:
|
if is_installed:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
args = [sys.executable, "-m", "pip", "install", "--quiet"]
|
args = ["uv", "pip", "install", "--quiet"]
|
||||||
if install_args:
|
if install_args:
|
||||||
args.append(install_args)
|
args.append(install_args)
|
||||||
args.append(requirement_arg)
|
args.append(requirement_arg)
|
||||||
|
|
|
@ -32,8 +32,7 @@ def main() -> int | None:
|
||||||
requirements = gather_recursive_requirements(args.integration)
|
requirements = gather_recursive_requirements(args.integration)
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.executable,
|
"uv",
|
||||||
"-m",
|
|
||||||
"pip",
|
"pip",
|
||||||
"install",
|
"install",
|
||||||
"-c",
|
"-c",
|
||||||
|
|
|
@ -8,11 +8,11 @@ cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
command -v pytest >/dev/null 2>&1 || {
|
command -v pytest >/dev/null 2>&1 || {
|
||||||
echo >&2 "This script requires pytest but it's not installed." \
|
echo >&2 "This script requires pytest but it's not installed." \
|
||||||
"Aborting. Try: pip install pytest"; exit 1; }
|
"Aborting. Try: uv pip install pytest"; exit 1; }
|
||||||
|
|
||||||
command -v monkeytype >/dev/null 2>&1 || {
|
command -v monkeytype >/dev/null 2>&1 || {
|
||||||
echo >&2 "This script requires monkeytype but it's not installed." \
|
echo >&2 "This script requires monkeytype but it's not installed." \
|
||||||
"Aborting. Try: pip install monkeytype"; exit 1; }
|
"Aborting. Try: uv pip install monkeytype"; exit 1; }
|
||||||
|
|
||||||
if [ $# -eq 0 ]
|
if [ $# -eq 0 ]
|
||||||
then
|
then
|
||||||
|
|
|
@ -13,14 +13,18 @@ if [ -s .python-version ]; then
|
||||||
export PYENV_VERSION
|
export PYENV_VERSION
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# other common virtualenvs
|
if [ -n "${VIRTUAL_ENV}" ] && [ -f "${VIRTUAL_ENV}/bin/activate" ]; then
|
||||||
my_path=$(git rev-parse --show-toplevel)
|
. "${VIRTUAL_ENV}/bin/activate"
|
||||||
|
else
|
||||||
|
# other common virtualenvs
|
||||||
|
my_path=$(git rev-parse --show-toplevel)
|
||||||
|
|
||||||
for venv in venv .venv .; do
|
for venv in venv .venv .; do
|
||||||
if [ -f "${my_path}/${venv}/bin/activate" ]; then
|
if [ -f "${my_path}/${venv}/bin/activate" ]; then
|
||||||
. "${my_path}/${venv}/bin/activate"
|
. "${my_path}/${venv}/bin/activate"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
14
script/setup
14
script/setup
|
@ -16,15 +16,23 @@ fi
|
||||||
|
|
||||||
mkdir -p config
|
mkdir -p config
|
||||||
|
|
||||||
if [ ! -n "$DEVCONTAINER" ] && [ ! -n "$VIRTUAL_ENV" ];then
|
if [ ! -n "$VIRTUAL_ENV" ]; then
|
||||||
python3 -m venv venv
|
if [ -x "$(command -v uv)" ]; then
|
||||||
|
uv venv venv
|
||||||
|
else
|
||||||
|
python3 -m venv venv
|
||||||
|
fi
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [ -x "$(command -v uv)" ]; then
|
||||||
|
python3 -m pip install uv
|
||||||
|
fi
|
||||||
|
|
||||||
script/bootstrap
|
script/bootstrap
|
||||||
|
|
||||||
pre-commit install
|
pre-commit install
|
||||||
python3 -m pip install -e . --config-settings editable_mode=compat --constraint homeassistant/package_constraints.txt
|
uv pip install -e . --config-settings editable_mode=compat --constraint homeassistant/package_constraints.txt
|
||||||
python3 -m script.translations develop --all
|
python3 -m script.translations develop --all
|
||||||
|
|
||||||
hass --script ensure_config -c config
|
hass --script ensure_config -c config
|
||||||
|
|
Loading…
Add table
Reference in a new issue