Skip to content

Commit

Permalink
build: use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
bolinocroustibat committed Sep 23, 2024
1 parent 46a97fb commit ef69e50
Show file tree
Hide file tree
Showing 8 changed files with 1,088 additions and 448 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /home/www/word-generator-api
source /home/www/word-generator-api/.venv/bin/activate
pip install -r /home/www/word-generator-api/requirements.lock
uv sync
sudo systemctl restart word-generator-api.service
- name: Create Sentry release
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2 # Ruff version
rev: v0.6.5 # Ruff version
hooks:
# Run the linter
- id: ruff
Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

31 changes: 13 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

Python API with a PostgreSQL database, using FastAPI framework.

- Python 3.11
- [Rye](https://rye-up.com/)
- Python >=3.11
- [uv](https://docs.astral.sh/uv/)
- [FastAPI](https://fastapi.tiangolo.com/)
- [Tortoise ORM](https://tortoise-orm.readthedocs.io/)
- PostgreSQL database
- A PostgreSQL 15 database (not tested with other PostgreSQL versions)


## Endpoints
Expand Down Expand Up @@ -44,9 +44,9 @@ Python API with a PostgreSQL database, using FastAPI framework.

## Install

Create a virtual environnement and install the dependencies in it with [Rye](https://rye-up.com/) (or with [PDM](https://pdm.fming.dev/)) single command:
Create a virtual environnement and install the dependencies in it with [uv](https://docs.astral.sh/uv/) single command:
```bash
rye sync
uv sync
```

### Setup the config file
Expand Down Expand Up @@ -75,9 +75,9 @@ For the French language, you need to download the Spacy NLP data:
```bash
python3 -m spacy download fr_core_news_sm
```
or, with Rye:
or, with uv:
```bash
rye run python -m spacy download fr_core_news_sm
uv run python -m spacy download fr_core_news_sm
```

If any issue with the `fr_core_news_sm` model installing, one can install it manually with:
Expand All @@ -91,21 +91,21 @@ If any issue with pip in the venv for Spacy:
python3 -m ensurepip --default-pip
```

If Spacy lefff doesn't work, try to install it manually with pip and not with Rye/PDM in the venv:
If Spacy lefff doesn't work, try to install it manually with pip and not with uv in the venv:
```bash
pip install spacy-lefff
```
or, with Rye:
or, with uv:
```bash
rye run pip install spacy-lefff
uv run pip install spacy-lefff
```


## Run the API

Launch the web server with:
```bash
rye run uvicorn api:app --reload
uv run uvicorn api:app --reload
```

Inside the venv:
Expand All @@ -121,14 +121,9 @@ pre-commit install
```
Once this is done, code formatting and linting, as well as import sorting, will be automatically checked before each commit.

Lint with:
Lint and format with:
```bash
rye lint --fix
```

Format with:
```bash
rye fmt
uv run ruff check --fix && rye format
```

## Commands
Expand Down
15 changes: 4 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "word-generator-api"
version = "1.5.8"
version = "1.5.9"
description = "Generates words that don't exist but sound English, French, Spanish or Italian, along with their altered dictionary definitions."
authors = [{ name = "Adrien Carpentier", email = "[email protected]" }]
dependencies = [
Expand All @@ -19,21 +19,14 @@ dependencies = [
"uvicorn<1.0.0,>=0.17.5",
"spacy-lefff>=0.5.1",
]
requires-python = ">=3.11,<3.12"
requires-python = ">=3.12,<3.13"

[project.urls]
homepage = ""

[build-system]
requires = ["pdm-pep517>=1.0.0"]
build-backend = "pdm.pep517.api"

[tool.pdm]
dev-dependencies = { dev = ["ruff>=0.6.2"] }

[tool.ruff]
lint = { select = ["I"] }
line-length = 100

[tool.rye]
dev-dependencies = ["ruff>=0.6.2"]
[tool.uv]
dev-dependencies = ["ruff>=0.6.5"]
208 changes: 0 additions & 208 deletions requirements-dev.lock

This file was deleted.

Loading

0 comments on commit ef69e50

Please sign in to comment.