refactors from pipenv to poetry

This commit is contained in:
msramalho
2025-02-10 22:39:02 +00:00
parent f8c45e2d92
commit c2dff5c121
6 changed files with 4535 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
VERSION = "0.8.0"
VERSION = "0.9.0"
API_DESCRIPTION = """
#### API for the Auto-Archiver project, a tool to archive web pages and Google Sheets.

View File

@@ -3,8 +3,8 @@ from loguru import logger
# logging configurations
logger.add("logs/api_logs.log", retention="30 days", rotation="3 days")
logger.add("logs/error_logs.log", retention="30 days", level="ERROR")
logger.add("app/logs/api_logs.log", retention="30 days", rotation="3 days")
logger.add("app/logs/error_logs.log", retention="30 days", level="ERROR")
def log_error(e: Exception, traceback_str: str = None, extra:str = ""):

View File

@@ -13,9 +13,11 @@ services:
worker:
#TODO: add watchmedo
command: watchmedo auto-restart --patterns="*.py" --recursive --ignore-directories -- celery -- --app=app.worker.main.celery worker --loglevel=info --logfile=/aa-api/app/logs/celery.log
restart: "no"
env_file: .env.dev
volumes:
- ./app:/aa-api/app # for watchmedo
redis:
command: redis-server /conf/redis.conf --requirepass ${REDIS_PASSWORD}

4462
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

51
pyproject.toml Normal file
View File

@@ -0,0 +1,51 @@
[project]
name = "auto-archiver-api"
version = "0.9.0"
description = "API wrapper for Bellingcat's Auto Archiver, supports users, groups, sheet and url archives."
authors = [
{ name = "Bellingcat", email = "contact-tech@bellingcat.com" },
]
license = {text = "MIT"}
readme = "README.md"
keywords = ["archive", "oosi", "osint", "scraping"]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3"
]
requires-python = ">=3.10,<4.0"
dependencies = [
"auto-archiver (>=0.12.0,<0.13.0)",
"oscrypto @ git+https://github.com/wbond/oscrypto.git@d5f3437ed24257895ae1edd9e503cfb352e635a8",
"celery (>=5.0)",
"redis (==3.5.3)",
"loguru (>=0.7.3,<0.8.0)",
"pydantic-settings (>=2.7.1,<3.0.0)",
"sqlalchemy (>=2.0.38,<3.0.0)",
"requests (>=2.25.1)",
"pyopenssl (==23.3.0)",
]
[tool.poetry.group.worker.dependencies]
watchdog = ">=6.0.0,<7.0.0"
[tool.poetry.group.web.dependencies]
fastapi = ">=0.115.8,<0.116.0"
requests = ">=2.32.3,<3.0.0"
aiosqlite = ">=0.21.0,<0.22.0"
alembic = ">=1.14.1,<2.0.0"
fastapi-utils = ">=0.8.0,<0.9.0"
prometheus-fastapi-instrumentator = ">=7.0.2,<8.0.0"
fastapi-mail = ">=1.4.2,<2.0.0"
uvicorn = ">=0.13.4"
[tool.poetry.group.dev.dependencies]
pytest = ">=8.3.4,<9.0.0"
httpx = ">=0.28.1,<0.29.0"
coverage = ">=7.6.11,<8.0.0"
pytest-asyncio = ">=0.25.3,<0.26.0"

View File

@@ -7,14 +7,23 @@ WORKDIR /aa-api
RUN curl -fsSL https://get.docker.com -o get-docker.sh && \
sh get-docker.sh
# set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV LANG=C.UTF-8 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1
# install dependencies
RUN apt update -y && \
apt install -y python3-venv && \
python3 -m venv ./poetry-venv && \
./poetry-venv/bin/python -m pip install --upgrade pip && \
./poetry-venv/bin/python -m pip install "poetry>=2.0.0,<3.0.0"
COPY pyproject.toml poetry.lock ./
RUN ./poetry-venv/bin/poetry install --without dev --no-root --no-cache
# install dependencies
RUN pip install --upgrade pip && \
apt-get update
COPY ./Pipfile* ./
RUN pipenv install
# copy source code and .env files over
COPY alembic.ini ./
@@ -22,4 +31,4 @@ COPY .env* ./app/
COPY ./secrets/ ./secrets/
COPY ./app/ ./app/
ENTRYPOINT ["pipenv", "run"]
ENTRYPOINT ["./poetry-venv/bin/poetry", "run"]