build: introduce uv as Python package manager (#16317)
Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com>
This commit is contained in:
7
dev/mypy-check
Executable file
7
dev/mypy-check
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# run mypy checks
|
||||
uv run --directory api --group dev \
|
||||
python -m mypy --install-types --non-interactive .
|
14
dev/reformat
14
dev/reformat
@@ -2,20 +2,14 @@
|
||||
|
||||
set -x
|
||||
|
||||
# style checks rely on commands in path
|
||||
if ! command -v ruff &> /dev/null || ! command -v dotenv-linter &> /dev/null; then
|
||||
echo "Installing linting tools (Ruff, dotenv-linter ...) ..."
|
||||
poetry install -C api --only lint
|
||||
fi
|
||||
|
||||
# run ruff linter
|
||||
poetry run -C api ruff check --fix ./
|
||||
uv run --directory api --group lint ruff check --fix ./
|
||||
|
||||
# run ruff formatter
|
||||
poetry run -C api ruff format ./
|
||||
uv run --directory api --group lint ruff format ./
|
||||
|
||||
# run dotenv-linter linter
|
||||
poetry run -P api dotenv-linter ./api/.env.example ./web/.env.example
|
||||
uv run --project api --group lint dotenv-linter ./api/.env.example ./web/.env.example
|
||||
|
||||
# run mypy check
|
||||
dev/run-mypy
|
||||
dev/mypy-check
|
||||
|
@@ -2,10 +2,6 @@
|
||||
|
||||
set -x
|
||||
|
||||
if ! command -v mypy &> /dev/null; then
|
||||
poetry install -C api --with dev
|
||||
fi
|
||||
|
||||
# run mypy checks
|
||||
poetry run -C api \
|
||||
uv run --directory api --group dev \
|
||||
python -m mypy --install-types --non-interactive .
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# rely on `poetry` in path
|
||||
if ! command -v poetry &> /dev/null; then
|
||||
echo "Installing Poetry ..."
|
||||
pip install poetry
|
||||
fi
|
||||
|
||||
# check poetry.lock in sync with pyproject.toml
|
||||
poetry check -C api --lock
|
||||
if [ $? -ne 0 ]; then
|
||||
# update poetry.lock
|
||||
# refreshing lockfile only without updating locked versions
|
||||
echo "poetry.lock is outdated, refreshing without updating locked versions ..."
|
||||
poetry lock -C api
|
||||
else
|
||||
echo "poetry.lock is ready."
|
||||
fi
|
10
dev/sync-uv
Executable file
10
dev/sync-uv
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# rely on `uv` in path
|
||||
if ! command -v uv &> /dev/null; then
|
||||
echo "Installing uv ..."
|
||||
pip install uv
|
||||
fi
|
||||
|
||||
# check uv.lock in sync with pyproject.toml
|
||||
uv lock --project api
|
@@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# rely on `poetry` in path
|
||||
if ! command -v poetry &> /dev/null; then
|
||||
echo "Installing Poetry ..."
|
||||
pip install poetry
|
||||
fi
|
||||
|
||||
# refreshing lockfile, updating locked versions
|
||||
poetry update -C api
|
||||
|
||||
# check poetry.lock in sync with pyproject.toml
|
||||
poetry check -C api --lock
|
22
dev/update-uv
Executable file
22
dev/update-uv
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Update dependencies in dify/api project using uv
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
REPO_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
# rely on `poetry` in path
|
||||
if ! command -v uv &> /dev/null; then
|
||||
echo "Installing uv ..."
|
||||
pip install uv
|
||||
fi
|
||||
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
# refreshing lockfile, updating locked versions
|
||||
uv lock --project api --upgrade
|
||||
|
||||
# check uv.lock in sync with pyproject.toml
|
||||
uv lock --project api --check
|
Reference in New Issue
Block a user