Skip to content

Commit

Permalink
✨ Replace poetry with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
perdy committed Feb 14, 2025
1 parent 0ad24df commit 14a7eb7
Show file tree
Hide file tree
Showing 23 changed files with 2,786 additions and 3,953 deletions.
26 changes: 5 additions & 21 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,28 @@ feature, which is why we encourage you to follow the procedure depicted above as
Our code formatting rules are implicitly defined by using multiple tools. You can check your code against these
standards by running:

```commandline
make lint
```

This is a meta-rule that runs all the utilities used for checking and applying Flama coding standards, but it can be
done individually as follows:

### Code formatting

Flama uses Black for formatting the code to adhere to the Black code style ([PEP 8](https://peps.python.org/pep-0008/)
compliant):
Flama uses Ruff for formatting the code ([PEP 8](https://peps.python.org/pep-0008/) compliant):

```commandline
make black
```

### Imports ordering

Isort is used to reorganize library imports:

```commandline
make isort
make format
```

### Code quality checking

Ruff is used to determine if the code quality is high enough as required to be accepted:

```commandline
make ruff
make lint
```

### Static type checking

Flama is completely static typed. To make sure your code fulfils this constraint, you can check it using mypy:
Flama is completely static typed. To make sure your code fulfils this constraint, you can check it using pyright:

```commandline
make mypy
make typecheck
```

This will automatically fix any style violations in your code.
Expand Down
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
Loading

0 comments on commit 14a7eb7

Please sign in to comment.