Update project manager pdm to uv (#440)

* Update project manager pdm to uv

* Fix ci venv

* Fix ci venv source
This commit is contained in:
Wu Clan
2024-10-12 18:09:41 +08:00
committed by GitHub
parent a3d079cfdf
commit 0810647c48
14 changed files with 2040 additions and 2249 deletions

View File

@@ -17,17 +17,21 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup pdm
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd backend
pdm install
uv venv
uv pip install -r requirements.txt
- name: Run lint
run: |
cd backend
pdm lint
source .venv/bin/activate
chmod 755 scripts/lint.sh
./scripts/lint.sh

View File

@@ -19,19 +19,19 @@ repos:
- '--unsafe-fixes'
- id: ruff-format
- repo: https://github.com/pdm-project/pdm
rev: 2.18.1
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.20
hooks:
- id: pdm-export
- id: uv-lock
args:
- '-p'
- '--directory'
- 'backend'
files: backend/uv\.lock$
- id: uv-export
args:
- '--directory'
- 'backend'
- '-o'
- 'backend/requirements.txt'
- '--without-hashes'
files: backend/pdm\.lock$
- id: pdm-lock-check
args:
- '-p'
- 'backend'
files: backend/pdm\.lock$
- 'requirements.txt'
- '--no-hashes'
files: backend/uv\.lock$

View File

@@ -1,4 +1,4 @@
__pycache__/
venv/
.venv/
.pdm-python
.python-version

2
backend/.gitignore vendored
View File

@@ -8,5 +8,5 @@ alembic/versions/
static/media/
.ruff_cache/
.pytest_cache/
.pdm-python
.python-version
celerybeat-schedule.*

View File

@@ -26,7 +26,7 @@
- Any Python version between Python >= 3.10
- virtualenv or other virtual environment tool
- git
- [PDM](https://pdm-project.org/latest/)
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
2. Installation and setup
@@ -36,8 +36,9 @@
cd fastapi_best_architecture/backend
# Install requirements.txt
pdm install
vv venv
uv pip install -r requirements.txt
```
3. Check out a new branch and make your changes
@@ -52,7 +53,7 @@
```shell
# Run automated code formatting and linting
pdm lint
pre-commit run --all-files
```
5. Commit and push your changes
@@ -71,8 +72,8 @@
- `celery-start.sh`: For celery docker script, implementation is not recommended
- `format.sh`: Perform ruff format check
- `scripts/format.sh`: Perform ruff format check
- `lint.sh`: Perform pre-commit formatting
- `scripts/lint.sh`: Perform pre-commit formatting
- `pdm_export.sh`: Execute pdm export dependency package
- `scripts/export.sh`: Execute uv export dependency package

2162
backend/pdm.lock generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -4,4 +4,4 @@ alembic revision --autogenerate
alembic upgrade head
python ./scripts/init_data.py
python3 ./scripts/init_data.py

View File

@@ -9,6 +9,9 @@ and as a template library free open source.
authors = [
{ name = "Wu Clan", email = "jianhengwu0407@gmail.com" },
]
readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.10,<3.13"
dependencies = [
"alembic>=1.13.0",
"asgiref>=3.8.0",
@@ -51,21 +54,12 @@ dependencies = [
"celery-aio-pool==0.1.0rc6",
"asgi-correlation-id>=4.3.3",
]
requires-python = ">=3.10,<3.13"
readme = "README.md"
license = { text = "MIT" }
[tool.pdm.dev-dependencies]
lint = [
[tool.uv]
package = false
python-downloads = "manual"
dev-dependencies = [
"ruff>=0.5.0",
]
deploy = [
"supervisor>=4.2.5",
"wait-for-it>=2.2.2",
]
[tool.pdm]
distribution = false
[tool.pdm.scripts]
lint = "pre-commit run --all-files"

View File

@@ -1,18 +1,17 @@
# This file is @generated by PDM.
# Please do not edit it manually.
# This file was autogenerated by uv via the following command:
# uv export --directory backend -o requirements.txt --no-hashes
aiofiles==24.1.0
alembic==1.13.2
alembic==1.13.3
amqp==5.2.0
annotated-types==0.7.0
anyio==4.4.0
anyio==4.6.0
asgi-correlation-id==4.3.3
asgiref==3.8.1
async-timeout==4.0.3; python_full_version < "3.11.3"
async-timeout==4.0.3 ; python_full_version < '3.11.3'
asyncmy==0.2.9
attrs==24.2.0
bcrypt==4.0.1
billiard==4.2.0
billiard==4.2.1
casbin==1.34.0
casbin-async-sqlalchemy-adapter==1.4.0
celery==5.3.6
@@ -24,40 +23,39 @@ click==8.1.7
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.3.0
colorama==0.4.6; sys_platform == "win32" or platform_system == "Windows"
colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows'
cryptography==41.0.7
distlib==0.3.8
dnspython==2.6.1
distlib==0.3.9
dnspython==2.7.0
ecdsa==0.19.0
email-validator==2.2.0
exceptiongroup==1.2.2; python_version < "3.11"
exceptiongroup==1.2.2 ; python_full_version < '3.11'
fast-captcha==0.3.2
fastapi==0.111.0
fastapi-cli==0.0.5
fastapi-limiter==0.1.6
fastapi-oauth20==0.0.1a2
fastapi-pagination==0.12.13
fastapi[all]==0.111.0
filelock==3.16.0
filelock==3.16.1
flower==2.0.1
greenlet==3.0.3; platform_machine == "win32" or platform_machine == "WIN32" or platform_machine == "AMD64" or platform_machine == "amd64" or platform_machine == "x86_64" or platform_machine == "ppc64le" or platform_machine == "aarch64"
greenlet==3.1.1 ; platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'
gunicorn==21.2.0
h11==0.14.0
hiredis==3.0.0
httpcore==1.0.5
httpcore==1.0.6
httptools==0.6.1
httpx==0.25.2
humanize==4.10.0
identify==2.6.0
idna==3.8
humanize==4.11.0
identify==2.6.1
idna==3.10
iniconfig==2.0.0
itsdangerous==2.1.2
jinja2==3.1.4
kombu==5.4.0
kombu==5.4.2
loguru==0.7.2
mako==1.3.5
markdown-it-py==3.0.0
markupsafe==2.1.5
markupsafe==3.0.1
mdurl==0.1.2
msgspec==0.18.5
nodeenv==1.9.1
@@ -67,57 +65,55 @@ passlib==1.7.4
path==15.1.2
phonenumbers==8.13.27
pillow==10.4.0
platformdirs==4.3.2
platformdirs==4.3.6
pluggy==1.5.0
pre-commit==3.2.2
prometheus-client==0.20.0
prompt-toolkit==3.0.47
prometheus-client==0.21.0
prompt-toolkit==3.0.48
psutil==5.9.6
pyasn1==0.6.0
pyasn1==0.6.1
pycparser==2.22
pydantic==2.9.1
pydantic-core==2.23.3
pydantic-extra-types==2.9.0
pydantic-settings==2.4.0
pydantic-settings==2.5.2
pygments==2.18.0
pytest==7.2.2
pytest-pretty==1.2.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-jose==3.3.0
python-multipart==0.0.9
pytz==2024.1
python-multipart==0.0.12
pytz==2024.2
pyyaml==6.0.2
redis==5.1.0
redis[hiredis]==5.1.0
rich==13.8.0
rich==13.9.2
rsa==4.9
ruff==0.6.4
setuptools==74.1.2
ruff==0.6.9
setuptools==75.1.0
shellingham==1.5.4
simpleeval==0.9.13
simpleeval==1.0.0
six==1.16.0
sniffio==1.3.1
sqlalchemy==2.0.30
sqlalchemy-crud-plus==1.3.0
starlette==0.37.2
supervisor==4.2.5
tomli==2.0.1; python_version < "3.11"
tomli==2.0.2 ; python_full_version < '3.11'
tornado==6.4.1
typer==0.12.5
typing-extensions==4.12.2
tzdata==2024.1
tzdata==2024.2
ua-parser==0.18.0
ujson==5.10.0
user-agents==2.2.0
uvicorn==0.29.0
uvicorn[standard]==0.29.0
uvloop==0.20.0; (sys_platform != "cygwin" and sys_platform != "win32") and platform_python_implementation != "PyPy"
uvloop==0.20.0 ; platform_python_implementation != 'PyPy' and sys_platform != 'cygwin' and sys_platform != 'win32'
vine==5.1.0
virtualenv==20.26.4
virtualenv==20.26.6
wait-for-it==2.2.2
watchfiles==0.24.0
wcwidth==0.2.13
websockets==13.0.1
win32-setctime==1.1.0; sys_platform == "win32"
websockets==13.1
win32-setctime==1.1.0 ; sys_platform == 'win32'
xdbsearchip==1.0.2

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
uv export --no-hashes -o requirements.txt

2
backend/scripts/lint.sh Normal file → Executable file
View File

@@ -1,3 +1,3 @@
#!/usr/bin/env bash
pdm lint
pre-commit run --all-files

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
pdm lock --python=">=3.10" --append

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
pdm export -p . -o requirements.txt --without-hashes

1961
backend/uv.lock generated Normal file
View File

File diff suppressed because it is too large Load Diff