Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use poetry for dependency management #394

Merged
merged 17 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .readthedocs.yaml
grahamalama marked this conversation as resolved.
Show resolved Hide resolved
grahamalama marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
version: 2

python:
install:
- requirements: docs/requirements.txt

build:
os: "ubuntu-22.04"
tools:
python: "3.11"
jobs:
post_create_environment:
- pip install poetry
- poetry config virtualenvs.create false
post_install:
- poetry install --only docs
28 changes: 22 additions & 6 deletions IntegrationTests.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
FROM python:3.11.2-slim
FROM python:3.11.2-slim as build

ENV PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
POETRY_HOME="/opt/poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
VIRTUAL_ENV=/opt/.venv \
PATH="/opt/.venv/bin:$PATH"

# Install Poetry
RUN python -m venv $POETRY_HOME && \
$POETRY_HOME/bin/pip install poetry==1.4.1 && \
$POETRY_HOME/bin/poetry --version

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH" \
WORKDIR /opt
COPY pyproject.toml poetry.lock ./
RUN $POETRY_HOME/bin/poetry install --only tests --no-root

FROM python:3.11.2-slim
ENV PATH="/opt/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
VIRTUAL_ENV=/opt/.venv \
PYTHONPATH="/app:$PYTHONPATH"

COPY /bin/update_and_install_system_packages.sh /opt
RUN /opt/update_and_install_system_packages.sh wget

COPY tests/requirements.txt /opt
RUN pip install --no-cache-dir -r /opt/requirements.txt
COPY --from=build $VIRTUAL_ENV $VIRTUAL_ENV

WORKDIR /app
COPY tests/ pyproject.toml ./
Expand Down
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ maintainer-clean: distclean
$(VENV)/bin/python:
python3 -m venv $(VENV)

$(INSTALL_STAMP): $(VENV)/bin/python requirements.txt requirements-dev.txt
$(VENV)/bin/python -m pip install --upgrade pip wheel setuptools
$(VENV)/bin/pip install -r requirements.txt
install: $(INSTALL_STAMP)
$(INSTALL_STAMP): poetry.lock
@if [ -z $(shell command -v poetry 2> /dev/null) ]; then echo "Poetry could not be found. See https://python-poetry.org/docs/"; exit 2; fi
POETRY_VIRTUALENVS_IN_PROJECT=1 poetry install --no-root
$(VENV)/bin/pip install -e kinto-remote-settings
$(VENV)/bin/pip install -r requirements-dev.txt
touch $(INSTALL_STAMP)

format: $(INSTALL_STAMP)
Expand Down Expand Up @@ -78,12 +78,7 @@ stop:
down:
docker-compose down

install-docs: $(DOC_STAMP)
$(DOC_STAMP): $(VENV)/bin/python docs/requirements.txt
$(VENV)/bin/pip install -Ur docs/requirements.txt
touch $(DOC_STAMP)

docs: install-docs
docs: install
$(VENV)/bin/sphinx-build -a -W -n -b html -d $(SPHINX_BUILDDIR)/doctrees docs $(SPHINX_BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(SPHINX_BUILDDIR)/html/index.html"
Expand Down
26 changes: 18 additions & 8 deletions RemoteSettings.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
FROM python:3.11.2 as compile

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
POETRY_HOME="/opt/poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
VIRTUAL_ENV=/opt/.venv \
PATH="/opt/.venv/bin:$PATH"

# Install Poetry
RUN python -m venv $POETRY_HOME && \
$POETRY_HOME/bin/pip install poetry==1.4.1 && \
$POETRY_HOME/bin/poetry --version

WORKDIR /opt
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt && \
COPY ./poetry.lock ./pyproject.toml ./
RUN $POETRY_HOME/bin/poetry install --only main --no-root && \
uwsgi --build-plugin https://github.com/Datadog/uwsgi-dogstatsd

COPY ./kinto-remote-settings ./kinto-remote-settings
COPY VERSION .
RUN pip install --no-cache-dir ./kinto-remote-settings
RUN pip install ./kinto-remote-settings

FROM python:3.11.2-slim as production

ENV KINTO_INI=config/local.ini \
PATH="/opt/venv/bin:$PATH" \
PATH="/opt/.venv/bin:$PATH" \
PORT=8888 \
PYTHONUNBUFFERED=1 \
VIRTUAL_ENV=/opt/venv
VIRTUAL_ENV=/opt/.venv

COPY /bin/update_and_install_system_packages.sh /opt
RUN /opt/update_and_install_system_packages.sh \
Expand Down
2 changes: 0 additions & 2 deletions docs/requirements.txt

This file was deleted.

3,383 changes: 3,383 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,54 @@ asyncio_mode = "strict"
"from",
"import"
]

[tool.poetry]
name = "remote-settings"
version = "0"
description = "Easily manage evergreen settings data in Firefox"
authors = ["@mozilla/remote-settings-reviewers"]
license = "MPL"
readme = "README.rst"

[tool.poetry.dependencies]
python = "^3.11"
canonicaljson-rs = "0.5.0"
cryptography = "39.0.2"
ecdsa = "0.18.0"
kinto = { version = "15.1.1", extras = ["postgresql","memcached","monitoring"] }
kinto-attachment = "6.3.1"
kinto-emailer = "2.1.0"
requests-hawk = "1.1.1"
uwsgi = "2.0.21"

[tool.poetry.group.kinto-remote-settings.dependencies]
kinto-remote-settings = { path = "./kinto-remote-settings", develop = true }

[tool.poetry.group.dev.dependencies]
black = "23.1.0"
flake8="6.0.0"
isort="5.12.0"
pytest="6.2.5"
webtest="3.0.0"
coverage={ version = "7.2.2", extras = ["toml"] }


[tool.poetry.group.tests.dependencies]
aiohttp = "3.8.4"
autograph-utils = "0.1.1"
canonicaljson-rs = "0.5.0"
httpie = "3.2.1"
kinto-http = "11.0.0"
pytest = "6.2.5"
pytest-asyncio = "0.20.3"
pytest-selenium = "4.0.0"
webtest = "3.0.0"


[tool.poetry.group.docs.dependencies]
docutils = "0.19"
sphinx = "6.1.3"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements.in

This file was deleted.

Loading