Skip to content

Commit

Permalink
Introduce poetry to lock dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanfei Shen committed Mar 1, 2021
1 parent 441978e commit 5018477
Show file tree
Hide file tree
Showing 12 changed files with 1,396 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ python:
- "3.7"
- "3.8"
- "3.9"
install: pip install -r requirements_plus_development_frozen.txt
install: poetry install
script: pytest
deploy:
provider: script
Expand Down
27 changes: 17 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
FROM python:3.9-slim AS builder

ARG POETRY_VERSION=1.1.4
RUN pip install poetry==$POETRY_VERSION

WORKDIR /src

COPY pyproject.toml poetry.lock README.md pylintrc ./
COPY marge/ ./marge/
RUN poetry export -o requirements.txt && \
poetry build


FROM python:3.9-slim

RUN apt-get update && apt-get install -y \
git-core \
&& \
rm -rf /var/lib/apt/lists/*

WORKDIR /src

ADD requirements_frozen.txt ./
RUN pip install -r ./requirements_frozen.txt
COPY --from=builder /src/requirements.txt /src/dist/marge-*.tar.gz /tmp/

ADD version ./
ADD setup.py ./
ADD marge.app ./
ADD marge/ ./marge/
RUN python ./setup.py install
RUN pip install -r /tmp/requirements.txt && \
pip install /tmp/marge-*.tar.gz

ENTRYPOINT ["marge.app"]
ENTRYPOINT ["marge"]
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ all: dockerize
.PHONY: bump
bump: bump-requirements

.PHONY: bump-requirements
bump-requirements: clean requirements_frozen.txt
poetry.lock:
poetry install

requirements.txt: poetry.lock
poetry export -o $@

requirements_development.txt: poetry.lock
poetry export --dev -o $@

requirements_frozen.txt: requirements.txt
pip freeze -r $^ > $@
.PHONY: bump-poetry-lock
bump-poetry-lock:
poetry update

requirements_plus_development_frozen.txt: requirements_frozen.txt
pip freeze -r $^ -r requirements_development.txt > $@
.PHONY: clean-requirements
clean-requirements:
rm -rf requirements.txt requirements_development.txt

.PHONY: bump-requirements
bump-requirements: bump-poetry-lock clean-requirements requirements.txt requirements_development.txt

.PHONY: dockerize
dockerize:
Expand Down
12 changes: 0 additions & 12 deletions marge.app

This file was deleted.

19 changes: 19 additions & 0 deletions marge/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from marge.app import main


def run():
try:
main()
except Exception as err:
print('Exception occured')
if hasattr(err, 'stdout'):
# pylint: disable=no-member
print(f'stdout was: {err.stdout}')
if hasattr(err, 'stderr'):
# pylint: disable=no-member
print(f'stderr was: {err.stderr}')
raise


if __name__ == '__main__':
run()
Loading

0 comments on commit 5018477

Please sign in to comment.