Skip to content

Commit 73500f0

Browse files
chore: port package manager (#154)
* chore: port package manager * actions
1 parent 10aae0e commit 73500f0

File tree

10 files changed

+831
-1280
lines changed

10 files changed

+831
-1280
lines changed

.github/workflows/ci.yaml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,40 @@ jobs:
77
steps:
88
- name: Checkout Code
99
uses: actions/checkout@v4
10-
- name: Cache
11-
uses: actions/cache@v3
12-
with:
13-
path: ~/.cache/pypoetry/virtualenvs
14-
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
10+
1511
- name: Setup Python
1612
uses: actions/setup-python@v4
1713
with:
1814
python-version: 3.9
19-
- name: Install Python Dependencies
20-
run: |
21-
pip install poetry cookiecutter
22-
- name: Check
15+
16+
- name: Install UV
17+
run: pip install uv cookiecutter
18+
19+
- name: Cache Dependencies
20+
uses: actions/cache@v3
21+
with:
22+
path: ~/.cache/uv
23+
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-uv-${{ hashFiles('pyproject.toml') }}
24+
25+
- name: Generate Project with Cookiecutter
2326
run: |
2427
ls -l
2528
cookiecutter --no-input .
2629
cd name-of-the-project
27-
make install
30+
31+
- name: Create Virtual Environment for UV
32+
run: |
33+
cd name-of-the-project
34+
uv venv .venv # Criando ambiente virtual
35+
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
36+
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
37+
38+
- name: Install Dependencies
39+
run: |
40+
cd name-of-the-project
41+
uv pip install -e ".[dev]"
42+
43+
- name: Run Tests
44+
run: |
45+
cd name-of-the-project
2846
make test

CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ This document is in order you need PR some feature/fix/idea to cookiecutter-fast
44

55
## Development Requirements
66

7-
- Python3.8.2
8-
- Pip
9-
- Poetry (Python Package Manager)
7+
- Python 3.11+
8+
- uv (Python Package Manager)
109

1110
## Installation
1211

@@ -49,4 +48,4 @@ Application parts are:
4948
├── services - logic that is not just crud related.
5049
└── main.py - FastAPI application creation and configuration.
5150
├──
52-
tests - pytest.
51+
tests - pytest.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
In order to create a template to FastAPI projects. :rocket:
44

55
## Important
6+
67
To use this project you don't need fork it. Just run cookiecutter CLI and voilà!
78

89
## Cookiecutter

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"machine_learn_model_name": "model.pkl",
77
"input_example_path": "./ml/model/examples/example.json",
88
"full_name": "Your name",
9-
"email": "you <you@example.com>",
9+
"email": "[email protected]",
1010
"release_date": "{% now 'local' %}",
1111
"version": "0.1.0",
1212
"_copy_without_render": [

{{cookiecutter.project_slug}}/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ ENV PYTHONUNBUFFERED 1
44

55
WORKDIR /app
66

7-
COPY poetry.lock pyproject.toml ./
7+
COPY pyproject.toml ./
88
RUN pip install --upgrade pip && \
9-
pip install poetry && \
10-
poetry config virtualenvs.create false
9+
pip install uv && \
10+
uv pip install -e . # Installs dependencies using uv
1111

1212
ARG DEV=false
13-
RUN if [ "$DEV" = "true" ] ; then poetry install --with dev ; else poetry install --only main ; fi
13+
RUN if [ "$DEV" = "true" ] ; then uv pip install -e .[dev] ; fi
1414

1515
COPY ./app/ ./
1616
COPY ./ml/model/ ./ml/model/
1717

1818
ENV PYTHONPATH "${PYTHONPATH}:/app"
1919

2020
EXPOSE 8080
21-
CMD uvicorn main:app --host 0.0.0.0 --port 8080
21+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

{{cookiecutter.project_slug}}/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ endif
2222
all: clean test install run deploy down
2323

2424
test:
25-
poetry run pytest tests -vv --show-capture=all
25+
uv pip install -e ".[dev]"
26+
uv run pytest tests -vv --show-capture=all
2627

2728
install: generate_dot_env
2829
pip install --upgrade pip
29-
pip install poetry
30-
poetry install --with dev
30+
pip install uv
31+
uv pip install -e ".[dev]"
3132

3233
run:
33-
PYTHONPATH=app/ poetry run uvicorn main:app --reload --host 0.0.0.0 --port 8080
34+
PYTHONPATH=app/ uvicorn main:app --reload --host 0.0.0.0 --port 8080
3435

3536
deploy: generate_dot_env
3637
docker-compose build

{{cookiecutter.project_slug}}/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
## Development Requirements
66

7-
- Python3.11.0
8-
- Pip
9-
- Poetry (Python Package Manager)
7+
- Python 3.11+
8+
- Uv (Python Package Manager)
109

1110
### M.L Model Environment
1211

{{cookiecutter.project_slug}}/poetry.lock

Lines changed: 0 additions & 1224 deletions
This file was deleted.
Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
[tool.poetry]
2-
name = "{{cookiecutter.project_name}}"
1+
[project]
2+
requires-python = ">=3.9"
3+
name = "{{cookiecutter.project_slug}}"
34
version = "0.1.0"
45
description = "{{cookiecutter.project_short_description}}"
5-
authors = ["{{cookiecutter.full_name}} <{{cookiecutter.email}}>"]
6+
authors = [
7+
{ name = "{{cookiecutter.full_name}}", email = "{{cookiecutter.email}}" },
8+
]
9+
dependencies = [
10+
"fastapi>=0.103.0",
11+
"uvicorn==0.23.2",
12+
"pydantic>=2.0.0",
13+
"requests>=2.32.0",
14+
"loguru>=0.7.0",
15+
"joblib>=1.2.0",
16+
"scikit-learn>=1.5.0"
17+
]
618

7-
[tool.poetry.dependencies]
8-
python = "^3.9"
9-
fastapi = "^0.103.0"
10-
uvicorn = "0.23.2"
11-
pydantic = "^2.0.0"
12-
requests = "^2.32.0"
13-
loguru = "^0.7.0"
14-
joblib = "^1.2.0"
15-
scikit-learn = "^1.5.0"
16-
17-
[tool.poetry.group.dev.dependencies]
18-
pytest = "^7.2"
19-
black = {version = "^24.3", allow-prereleases = true}
20-
autopep8 = "^2.0.0"
21-
ipdb = "^0.13.0"
22-
pylint = "^3.0.0"
23-
24-
[tool.poetry.group.aws]
25-
optional = true
26-
27-
[tool.poetry.group.aws.dependencies]
28-
mangum = "^0.17.0"
29-
30-
[build-system]
31-
requires = ["poetry>=0.12"]
32-
build-backend = "poetry.masonry.api"
19+
[project.optional-dependencies]
20+
dev = [
21+
"pytest>=7.2",
22+
"black>=24.3",
23+
"autopep8>=2.0.0",
24+
"ipdb>=0.13.0",
25+
"pylint>=3.0.0"
26+
]
27+
aws = [
28+
"mangum>=0.17.0"
29+
]
3330

3431
[tool.black]
3532
line-length = 88
@@ -45,3 +42,10 @@ exclude = '''
4542
|Jenkinfile
4643
)/
4744
'''
45+
46+
[build-system]
47+
requires = ["setuptools", "wheel"]
48+
build-backend = "setuptools.build_meta"
49+
50+
[tool.setuptools.packages.find]
51+
where = ["."]

0 commit comments

Comments
 (0)