Skip to content

Commit c4a60c3

Browse files
Kostiantyn Krykunepmd-edp
authored andcommitted
feat: Updating the application according to PEP 517/518
1 parent 2ba28f2 commit c4a60c3

8 files changed

Lines changed: 95 additions & 47 deletions

File tree

.dockerignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
*.egg-info/
10+
.eggs/
11+
dist/
12+
build/
13+
.venv/
14+
venv/
15+
.pytest_cache/
16+
17+
# IDE
18+
.idea/
19+
.vscode/
20+
21+
# Tests
22+
tests/
23+
test-report.xml
24+
.coverage
25+
26+
# Docs
27+
*.md
28+
LICENSE

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
FROM public.ecr.aws/docker/library/python:3.8-slim
1+
FROM public.ecr.aws/docker/library/python:3.13-slim
22

33
WORKDIR /app
44

5-
# Install required packages
6-
COPY requirements.txt ./
5+
# Install build dependencies and the package
6+
COPY pyproject.toml requirements.txt ./
7+
COPY version/ ./version/
78
RUN pip install --no-cache-dir -r requirements.txt
89

910
# Copy the application code
10-
COPY . .
11+
COPY app.py ./
1112

1213
# Create a non-root user to run the application
1314
RUN useradd --create-home appuser

pyproject.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[build-system]
2+
requires = ["setuptools>=69.5.1"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "hello_world"
7+
dynamic = ["version"]
8+
description = "A simple hello world Flask app"
9+
readme = "README.md"
10+
license = "Apache-2.0"
11+
requires-python = ">=3.13"
12+
dependencies = [
13+
"click==8.1.7",
14+
"Flask==3.1.2",
15+
"itsdangerous==2.2.0",
16+
"Jinja2==3.1.6",
17+
"MarkupSafe==3.0.3",
18+
"Werkzeug==3.1.5",
19+
]
20+
21+
[project.optional-dependencies]
22+
test = [
23+
"pytest>=7.4.4",
24+
"flake8>=7.0.0",
25+
"pylint>=3.0.0",
26+
]
27+
dev = [
28+
"twine>=5.1.1",
29+
]
30+
31+
[tool.setuptools.dynamic]
32+
version = {attr = "version.__version__"}
33+
34+
[tool.setuptools.packages.find]
35+
include = ["version*"]
36+
exclude = ["tests*"]
37+
38+
[tool.pytest.ini_options]
39+
testpaths = ["tests"]
40+
addopts = "-rsxX -l --tb=short --junitxml=test-report.xml"
41+
42+
[tool.flake8]
43+
max-line-length = 120
44+
exclude = [".git", "__pycache__", "build", "dist", "*.egg-info"]
45+
46+
[tool.pylint.messages_control]
47+
disable = ["C0114", "C0115", "C0116"]
48+
49+
[tool.pylint.format]
50+
max-line-length = 120

requirements.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
# Runtime dependencies - synced with pyproject.toml
12
click==8.1.7
2-
Flask==3.0.0
3-
itsdangerous==2.1.2
3+
Flask==3.1.2
4+
itsdangerous==2.2.0
45
Jinja2==3.1.6
5-
MarkupSafe==2.1.3
6-
Werkzeug==3.1.4
6+
MarkupSafe==3.0.3
7+
Werkzeug==3.1.5
8+
pylint>=3.0.0
9+
flake8>=7.0.0
10+
pytest>=7.4.4
11+
twine==6.2.0

setup.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

test-requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Test package."""

app_test.py renamed to tests/test_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"""Unit test for application."""
1+
"""Unit tests for the Flask application."""
22
from app import app
33

44

55
def test_hello():
6-
"""Returns Hello, World."""
6+
"""Test that the root endpoint returns Hello, World."""
77
response = app.test_client().get('/')
88

99
assert response.status_code == 200

0 commit comments

Comments
 (0)