Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace poetry with uv #177

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/test_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
container:
image: python:${{ matrix.python }}
steps:
- uses: actions/checkout@master
with:
Expand All @@ -35,20 +33,24 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- id: install
name: Install requirements
run: |
pip install pip poetry --upgrade
./scripts/install
name: Install project
run: ./scripts/install
- id: format
name: Code format checking
run: ./scripts/format --check .
- id: lint
name: Code linting
run: ./scripts/lint --output-format=github .
- id: types
- id: typecheck
name: Static types check
run: ./scripts/types
run: ./scripts/typecheck
- id: tests
name: Tests
run: ./scripts/test
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/test_pull_request_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
container:
image: python:${{ matrix.python }}
steps:
- uses: actions/checkout@master
with:
Expand All @@ -23,20 +21,24 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- id: install
name: Install requirements
run: |
pip install pip poetry --upgrade
./scripts/install
name: Install project
run: ./scripts/install
- id: format
name: Code format checking
run: ./scripts/format --check .
- id: lint
name: Code linting
run: ./scripts/lint --output-format=github .
- id: types
- id: typecheck
name: Static types check
run: ./scripts/types
run: ./scripts/typecheck
- id: tests
name: Tests
run: ./scripts/test
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
exclude: "make"
- id: types
name: Static types check
entry: ./scripts/types
entry: ./scripts/typecheck
language: system
types: [file, python]
exclude: "(make|tests/|examples/)"
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ lint: ## Runs code linting
lint-fix: ## Runs code linting with autofixing
@./scripts/lint --fix .

types: ## Runs static types checking
@./scripts/types
typecheck: ## Runs static types checking
@./scripts/typecheck

docker_push: ## Push docker images to registry
@./scripts/docker_push .

.PHONY: help check clean install build tests publish version format lint lint-fix types docker_push
.PHONY: help check clean install build tests publish version format lint lint-fix typecheck docker_push
.DEFAULT_GOAL := help

help:
Expand Down
3,718 changes: 0 additions & 3,718 deletions poetry.lock

This file was deleted.

126 changes: 57 additions & 69 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
[build-system]
requires = ["poetry_core"]
build-backend = "poetry.core.masonry.api"

[project]
requires-python = ">=3.9,<3.14"
name = "flama"
version = "1.9.8"
description = "Fire up your models with the flame 🔥"
Expand Down Expand Up @@ -38,13 +33,14 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Application Frameworks",
]
requires-python = ">=3.9,<3.14"
dependencies = [
"starlette (>=0.31,<1.0.0)",
"click (>=8.1,<9.0)",
"uvicorn[standard] (>=0.23,<1.0.0)",
"Jinja2 (>=3.1.2,<4.0)",
"pyyaml (>=6.0,<7.0)",
"typing-extensions (>=4.4,<5.0) ; python_version < '3.10'",
"starlette>=0.31,<1.0.0",
"click>=8.1,<9.0",
"uvicorn[standard]>=0.23,<1.0.0",
"Jinja2>=3.1.2,<4.0",
"pyyaml>=6.0,<7.0",
"typing-extensions>=4.4,<5.0; python_version < '3.10'",
]

[project.urls]
Expand All @@ -53,71 +49,63 @@ homepage = "https://flama.dev"
documentation = "https://flama.dev/docs/"

[project.optional-dependencies]
pydantic = ["pydantic (>=2.0,<3.0)"]
typesystem = ["typesystem (>=0.4.1,<1.0)"]
marshmallow = ["marshmallow (>=3.0,<4.0)", "apispec (>=6.0,<7.0)"]
database = ["SQLAlchemy[asyncio] (>=2.0,<3.0)"]
client = ["httpx (>=0.25,<1.0)"]
pydantic = ["pydantic>=2.0,<3.0"]
typesystem = ["typesystem>=0.4.1,<1.0"]
marshmallow = ["marshmallow>=3.0,<4.0", "apispec>=6.0,<7.0"]
database = ["SQLAlchemy[asyncio]>=2.0,<3.0"]
client = ["httpx>=0.25,<1.0"]
full = [
"pydantic (>=2.0,<3.0)",
"typesystem (>=0.4.1,<1.0)",
"marshmallow (>=3.0,<4.0)",
"apispec (>=6.0,<7.0)",
"SQLAlchemy[asyncio] (>=2.0,<3.0)",
"httpx (>=0.25,<1.0)",
"pydantic>=2.0,<3.0",
"typesystem>=0.4.1,<1.0",
"marshmallow>=3.0,<4.0",
"apispec>=6.0,<7.0",
"SQLAlchemy[asyncio]>=2.0,<3.0",
"httpx>=0.25,<1.0",
]

[project.scripts]
flama = 'flama.cli.__main__:cli'

[tool.poetry]
include = [
{ path = "flama", format = [
"sdist",
"wheel",
] },
{ path = "flama/templates/**/*", format = [
"sdist",
"wheel",
] },
[dependency-groups]
dev = [
"pytest>=8.3",
"pytest-xdist[psutil]>=3.3",
"pytest-cov>=6.0",
"pytest-asyncio>=0.24",
"ipython>=8.0",
"ruff>=0.9.6",
"pyright>=1.1.393",
"pre-commit>=3.4",
"python-multipart>=0.0.6",
"httpx>=0.25,<1.0.0",
"aiosqlite>=0.19.0,<1.0.0",
"Faker>=8.2",
"gevent>=23.9.1",
"scikit-learn>=1.5.2; platform_system == 'Linux'",
"tensorflow-cpu>=2.17.0; platform_system == 'Linux' and python_version >= '3.9' and python_version < '3.13'",
"torch>=2.5.0; platform_system == 'Linux'",
]

[build-system]
requires = ["hatchling", "hatch-build-scripts"]
build-backend = "hatchling.build"

[tool.hatch.build]
exclude = [
".github",
".gitignore",
".dockerignore",
"CHANGELOG.md",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"SECURITY.md",
]
exclude = []

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
pytest = "^8.3"
pytest-xdist = { version = "^3.3", extras = ["psutil"] }
pytest-cov = "^6.0"
pytest-asyncio = "^0.24"
ipython = "^8.0"
ruff = "^0.9.6"
pyright = "^1.1.393"
pre-commit = "^3.4"
python-multipart = "^0.0.6"
httpx = ">=0.25,<1.0.0"
aiosqlite = ">=0.19.0,<1.0.0"
Faker = "^8.2"
SQLAlchemy = { version = "^2.0", extras = ["asyncio"] }
gevent = "^23.9.1"

[tool.poetry.group.schemas]
optional = true

[tool.poetry.group.schemas.dependencies]
pydantic = "^2.4"
marshmallow = "^3.20"
apispec = "^6.3"
typesystem = "^0.4"

[tool.poetry.group.ml]
optional = true

[tool.poetry.group.ml.dependencies] # Only testable on linux and before 3.13, because numpy old versions are not providing binaries
scikit-learn = { version = "~1.5.2", platform = "linux", python = ">=3.9,<3.13" }
tensorflow-cpu = { version = "~2.17.0", platform = "linux", python = ">=3.9,<3.13" }
torch = { version = "~2.5.0", platform = "linux", python = ">=3.9,<3.13" }
artifacts = ["flama/templates/**/*"]

[[tool.hatch.build.hooks.build-scripts.scripts]]
work_dir = "templates"
commands = ["npm i", "npm run build"]
artifacts = ["flama/templates/"]

[tool.ruff]
line-length = 120
Expand Down
12 changes: 0 additions & 12 deletions scripts/black

This file was deleted.

16 changes: 7 additions & 9 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ set -e
source scripts/str_lib.sh
source scripts/clean

build_pkg() {
local arg="$1"

if [[ "$arg" == "-c" || "$arg" == "--clean" ]]; then
clean_folder
build() {
if [[ "$1" == "-c" || "$1" == "--clean" ]]; then
clean
fi

echo "🔥 Build package:"
poetry build

message "info" "Build package"
uv build
message "success" "Build completed"
}

if [[ "${#BASH_SOURCE[@]}" -eq 1 ]]; then
build_pkg "$@"
build "$@"
fi
41 changes: 15 additions & 26 deletions scripts/check
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,40 @@ set -e

source scripts/str_lib.sh

POETRY_INSTALLER="/tmp/poetry_install.py"
POETRY_URL="https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py"
UV_URL="https://astral.sh/uv/install.sh"

install_poetry() {
curl $POETRY_URL --output $POETRY_INSTALLER
python $POETRY_INSTALLER -y
rm $POETRY_INSTALLER
}

install_poetry_menu() {
printf "%b" "\n⚠️ ${C_YELLOW1} Poetry is not available:${NO_FORMAT}\n"
install_uv() {
message "warning" "UV is not available"
while true; do
read -p "- Do you wish to install this program? (Y/N) -> " yn
read -p "- Do you wish to install this program? (Y/N/q): " yn
case $yn in
[Yy]*)
install_poetry
curl -LsSf $UV_URL | sh
message "success" "UV installation completed ($(uv --version))"
break
;;
[Nn]*)
printf "%b" "\n🚨 ${F_BOLD}${C_RED1}Poetry won't be installed.${NO_FORMAT}"
printf "%b" "\n${C_YELLOW1}WARNING: ${F_ITALIC}The development team recommends the installation of Poetry for the packaging and management of dependencies.${NO_FORMAT}\n" | fold -w 99
message "error" "UV will not be installed"
message "warning" "The development team recommends the installation of UV for the packaging and management of dependencies"
exit
;;
[q]*)
printf "\n"
exit
;;
*) printf "%b" "\nPlease answer yes (Y) or no (N).\n" ;;
*) message "Please answer yes (Y) or no (N)" ;;
esac
done
}

install_success_message() {
printf "%b" "✅ ${C_SPRINGGREEN2}Poetry is installed:${NO_FORMAT} $(poetry --version)\n"
}

check_poetry() {
echo "🔥 Check dependencies:"
if ! (command -v poetry &>/dev/null); then
install_poetry_menu
check() {
message "info" "Check dependencies"
if ! (command -v uv &>/dev/null); then
install_uv
else
install_success_message
message "success" "UV is available ($(uv --version))"
fi
}

if [[ "${#BASH_SOURCE[@]}" -eq 1 ]]; then
check_poetry "$@"
check "$@"
fi
10 changes: 5 additions & 5 deletions scripts/clean
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ source scripts/str_lib.sh

FOLDERS="dist flama.egg-info pip-wheel-metadata site test-results .coverage .pytest_cache .mypy_cache .ruff_cache flama/templates"

clean_folder() {
echo "🔥 Clean directory..."
clean() {
message "info" "Clean project"
for folder in $FOLDERS; do
if [[ ! -d $folder ]]; then
printf "%b" "${C_YELLOW1}- Folder not found${NO_FORMAT}: $folder\n"
message "warning" "Not found: $folder"
else
printf "%b" "🧹 ${C_SPRINGGREEN2}Deleting folder${NO_FORMAT}: $folder\n"
message "success" "Deleted: $folder"
rm -r "$folder" 2>/dev/null
fi
done
find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf
}

if [[ "${#BASH_SOURCE[@]}" -eq 1 ]]; then
clean_folder "$@"
clean "$@"
fi
Loading
Loading