Skip to content

Commit 1c229db

Browse files
committed
✨ Replace poetry with uv
1 parent 0ad24df commit 1c229db

22 files changed

+2781
-3932
lines changed

.github/workflows/test_and_publish.yaml

+10-8
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ jobs:
2323
strategy:
2424
matrix:
2525
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
26-
container:
27-
image: python:${{ matrix.python }}
2826
steps:
2927
- uses: actions/checkout@master
3028
with:
@@ -35,20 +33,24 @@ jobs:
3533
uses: actions/setup-node@v3
3634
with:
3735
node-version: 16
36+
- name: Install uv
37+
uses: astral-sh/setup-uv@v5
38+
with:
39+
python-version: ${{ matrix.python }}
40+
enable-cache: true
41+
cache-dependency-glob: "uv.lock"
3842
- id: install
39-
name: Install requirements
40-
run: |
41-
pip install pip poetry --upgrade
42-
./scripts/install
43+
name: Install project
44+
run: ./scripts/install
4345
- id: format
4446
name: Code format checking
4547
run: ./scripts/format --check .
4648
- id: lint
4749
name: Code linting
4850
run: ./scripts/lint --output-format=github .
49-
- id: types
51+
- id: typecheck
5052
name: Static types check
51-
run: ./scripts/types
53+
run: ./scripts/typecheck
5254
- id: tests
5355
name: Tests
5456
run: ./scripts/test

.github/workflows/test_pull_request_branch.yaml

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
strategy:
1212
matrix:
1313
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
14-
container:
15-
image: python:${{ matrix.python }}
1614
steps:
1715
- uses: actions/checkout@master
1816
with:
@@ -23,20 +21,24 @@ jobs:
2321
uses: actions/setup-node@v3
2422
with:
2523
node-version: 16
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
python-version: ${{ matrix.python }}
28+
enable-cache: true
29+
cache-dependency-glob: "uv.lock"
2630
- id: install
27-
name: Install requirements
28-
run: |
29-
pip install pip poetry --upgrade
30-
./scripts/install
31+
name: Install project
32+
run: ./scripts/install
3133
- id: format
3234
name: Code format checking
3335
run: ./scripts/format --check .
3436
- id: lint
3537
name: Code linting
3638
run: ./scripts/lint --output-format=github .
37-
- id: types
39+
- id: typecheck
3840
name: Static types check
39-
run: ./scripts/types
41+
run: ./scripts/typecheck
4042
- id: tests
4143
name: Tests
4244
run: ./scripts/test

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ repos:
4040
exclude: "make"
4141
- id: types
4242
name: Static types check
43-
entry: ./scripts/types
43+
entry: ./scripts/typecheck
4444
language: system
4545
types: [file, python]
4646
exclude: "(make|tests/|examples/)"

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ lint: ## Runs code linting
3030
lint-fix: ## Runs code linting with autofixing
3131
@./scripts/lint --fix .
3232

33-
types: ## Runs static types checking
34-
@./scripts/types
33+
typecheck: ## Runs static types checking
34+
@./scripts/typecheck
3535

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

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

4242
help:

poetry.lock

-3,718
This file was deleted.

pyproject.toml

+57-69
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
[build-system]
2-
requires = ["poetry_core"]
3-
build-backend = "poetry.core.masonry.api"
4-
51
[project]
6-
requires-python = ">=3.9,<3.14"
72
name = "flama"
83
version = "1.9.8"
94
description = "Fire up your models with the flame 🔥"
@@ -38,13 +33,14 @@ classifiers = [
3833
"Topic :: Software Development :: Libraries",
3934
"Topic :: Software Development :: Libraries :: Application Frameworks",
4035
]
36+
requires-python = ">=3.9,<3.14"
4137
dependencies = [
42-
"starlette (>=0.31,<1.0.0)",
43-
"click (>=8.1,<9.0)",
44-
"uvicorn[standard] (>=0.23,<1.0.0)",
45-
"Jinja2 (>=3.1.2,<4.0)",
46-
"pyyaml (>=6.0,<7.0)",
47-
"typing-extensions (>=4.4,<5.0) ; python_version < '3.10'",
38+
"starlette>=0.31,<1.0.0",
39+
"click>=8.1,<9.0",
40+
"uvicorn[standard]>=0.23,<1.0.0",
41+
"Jinja2>=3.1.2,<4.0",
42+
"pyyaml>=6.0,<7.0",
43+
"typing-extensions>=4.4,<5.0; python_version < '3.10'",
4844
]
4945

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

5551
[project.optional-dependencies]
56-
pydantic = ["pydantic (>=2.0,<3.0)"]
57-
typesystem = ["typesystem (>=0.4.1,<1.0)"]
58-
marshmallow = ["marshmallow (>=3.0,<4.0)", "apispec (>=6.0,<7.0)"]
59-
database = ["SQLAlchemy[asyncio] (>=2.0,<3.0)"]
60-
client = ["httpx (>=0.25,<1.0)"]
52+
pydantic = ["pydantic>=2.0,<3.0"]
53+
typesystem = ["typesystem>=0.4.1,<1.0"]
54+
marshmallow = ["marshmallow>=3.0,<4.0", "apispec>=6.0,<7.0"]
55+
database = ["SQLAlchemy[asyncio]>=2.0,<3.0"]
56+
client = ["httpx>=0.25,<1.0"]
6157
full = [
62-
"pydantic (>=2.0,<3.0)",
63-
"typesystem (>=0.4.1,<1.0)",
64-
"marshmallow (>=3.0,<4.0)",
65-
"apispec (>=6.0,<7.0)",
66-
"SQLAlchemy[asyncio] (>=2.0,<3.0)",
67-
"httpx (>=0.25,<1.0)",
58+
"pydantic>=2.0,<3.0",
59+
"typesystem>=0.4.1,<1.0",
60+
"marshmallow>=3.0,<4.0",
61+
"apispec>=6.0,<7.0",
62+
"SQLAlchemy[asyncio]>=2.0,<3.0",
63+
"httpx>=0.25,<1.0",
6864
]
6965

7066
[project.scripts]
7167
flama = 'flama.cli.__main__:cli'
7268

73-
[tool.poetry]
74-
include = [
75-
{ path = "flama", format = [
76-
"sdist",
77-
"wheel",
78-
] },
79-
{ path = "flama/templates/**/*", format = [
80-
"sdist",
81-
"wheel",
82-
] },
69+
[dependency-groups]
70+
dev = [
71+
"pytest>=8.3",
72+
"pytest-xdist[psutil]>=3.3",
73+
"pytest-cov>=6.0",
74+
"pytest-asyncio>=0.24",
75+
"ipython>=8.0",
76+
"ruff>=0.9.6",
77+
"pyright>=1.1.393",
78+
"pre-commit>=3.4",
79+
"python-multipart>=0.0.6",
80+
"httpx>=0.25,<1.0.0",
81+
"aiosqlite>=0.19.0,<1.0.0",
82+
"Faker>=8.2",
83+
"gevent>=23.9.1",
84+
"scikit-learn>=1.5.2; platform_system == 'Linux'",
85+
"tensorflow-cpu>=2.17.0; platform_system == 'Linux' and python_version >= '3.9' and python_version < '3.13'",
86+
"torch>=2.5.0; platform_system == 'Linux'",
87+
]
88+
89+
[build-system]
90+
requires = ["hatchling", "hatch-build-scripts"]
91+
build-backend = "hatchling.build"
92+
93+
[tool.hatch.build]
94+
exclude = [
95+
".github",
96+
".gitignore",
97+
".dockerignore",
98+
"CHANGELOG.md",
99+
"CODE_OF_CONDUCT.md",
100+
"CONTRIBUTING.md",
101+
"SECURITY.md",
83102
]
84-
exclude = []
85-
86-
[tool.poetry.group.dev]
87-
optional = true
88-
89-
[tool.poetry.group.dev.dependencies]
90-
pytest = "^8.3"
91-
pytest-xdist = { version = "^3.3", extras = ["psutil"] }
92-
pytest-cov = "^6.0"
93-
pytest-asyncio = "^0.24"
94-
ipython = "^8.0"
95-
ruff = "^0.9.6"
96-
pyright = "^1.1.393"
97-
pre-commit = "^3.4"
98-
python-multipart = "^0.0.6"
99-
httpx = ">=0.25,<1.0.0"
100-
aiosqlite = ">=0.19.0,<1.0.0"
101-
Faker = "^8.2"
102-
SQLAlchemy = { version = "^2.0", extras = ["asyncio"] }
103-
gevent = "^23.9.1"
104-
105-
[tool.poetry.group.schemas]
106-
optional = true
107-
108-
[tool.poetry.group.schemas.dependencies]
109-
pydantic = "^2.4"
110-
marshmallow = "^3.20"
111-
apispec = "^6.3"
112-
typesystem = "^0.4"
113-
114-
[tool.poetry.group.ml]
115-
optional = true
116-
117-
[tool.poetry.group.ml.dependencies] # Only testable on linux and before 3.13, because numpy old versions are not providing binaries
118-
scikit-learn = { version = "~1.5.2", platform = "linux", python = ">=3.9,<3.13" }
119-
tensorflow-cpu = { version = "~2.17.0", platform = "linux", python = ">=3.9,<3.13" }
120-
torch = { version = "~2.5.0", platform = "linux", python = ">=3.9,<3.13" }
103+
artifacts = ["flama/templates/**/*"]
104+
105+
[[tool.hatch.build.hooks.build-scripts.scripts]]
106+
work_dir = "templates"
107+
commands = ["npm i", "npm run build"]
108+
artifacts = ["flama/templates/"]
121109

122110
[tool.ruff]
123111
line-length = 120

scripts/black

-12
This file was deleted.

scripts/build

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ set -e
44
source scripts/str_lib.sh
55
source scripts/clean
66

7-
build_pkg() {
8-
local arg="$1"
9-
10-
if [[ "$arg" == "-c" || "$arg" == "--clean" ]]; then
11-
clean_folder
7+
build() {
8+
if [[ "$1" == "-c" || "$1" == "--clean" ]]; then
9+
clean
1210
fi
1311

14-
echo "🔥 Build package:"
15-
poetry build
16-
12+
message "info" "Build package"
13+
uv build
14+
message "success" "Build completed"
1715
}
1816

1917
if [[ "${#BASH_SOURCE[@]}" -eq 1 ]]; then
20-
build_pkg "$@"
18+
build "$@"
2119
fi

scripts/check

+15-26
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,40 @@ set -e
33

44
source scripts/str_lib.sh
55

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

9-
install_poetry() {
10-
curl $POETRY_URL --output $POETRY_INSTALLER
11-
python $POETRY_INSTALLER -y
12-
rm $POETRY_INSTALLER
13-
}
14-
15-
install_poetry_menu() {
16-
printf "%b" "\n⚠️ ${C_YELLOW1} Poetry is not available:${NO_FORMAT}\n"
8+
install_uv() {
9+
message "warning" "UV is not available"
1710
while true; do
18-
read -p "- Do you wish to install this program? (Y/N) -> " yn
11+
read -p "- Do you wish to install this program? (Y/N/q): " yn
1912
case $yn in
2013
[Yy]*)
21-
install_poetry
14+
curl -LsSf $UV_URL | sh
15+
message "success" "UV installation completed ($(uv --version))"
2216
break
2317
;;
2418
[Nn]*)
25-
printf "%b" "\n🚨 ${F_BOLD}${C_RED1}Poetry won't be installed.${NO_FORMAT}"
26-
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
19+
message "error" "UV will not be installed"
20+
message "warning" "The development team recommends the installation of UV for the packaging and management of dependencies"
2721
exit
2822
;;
2923
[q]*)
30-
printf "\n"
3124
exit
3225
;;
33-
*) printf "%b" "\nPlease answer yes (Y) or no (N).\n" ;;
26+
*) message "Please answer yes (Y) or no (N)" ;;
3427
esac
3528
done
3629
}
3730

38-
install_success_message() {
39-
printf "%b" "${C_SPRINGGREEN2}Poetry is installed:${NO_FORMAT} $(poetry --version)\n"
40-
}
41-
42-
check_poetry() {
43-
echo "🔥 Check dependencies:"
44-
if ! (command -v poetry &>/dev/null); then
45-
install_poetry_menu
31+
check() {
32+
message "info" "Check dependencies"
33+
if ! (command -v uv &>/dev/null); then
34+
install_uv
4635
else
47-
install_success_message
36+
message "success" "UV is available ($(uv --version))"
4837
fi
4938
}
5039

5140
if [[ "${#BASH_SOURCE[@]}" -eq 1 ]]; then
52-
check_poetry "$@"
41+
check "$@"
5342
fi

scripts/clean

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ source scripts/str_lib.sh
55

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

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

2121
if [[ "${#BASH_SOURCE[@]}" -eq 1 ]]; then
22-
clean_folder "$@"
22+
clean "$@"
2323
fi

0 commit comments

Comments
 (0)