Skip to content

Commit 9c10ea8

Browse files
author
Hanfei Shen
committed
Introduce poetry to lock dependencies
1 parent be02f38 commit 9c10ea8

12 files changed

+1401
-111
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ env:
1414
jobs:
1515
test:
1616
runs-on: ubuntu-20.04
17+
strategy:
18+
matrix:
19+
poetry-version: [1.1.6]
1720
steps:
1821
- uses: actions/checkout@v2
1922
- uses: actions/setup-python@v2
23+
- name: Install Poetry
24+
run: pip install poetry==${{ matrix.poetry-version }}
2025
- name: Install requirements
21-
run: pip install -r requirements_plus_development_frozen.txt
26+
run: poetry install
2227
- name: Run tests
2328
run: pytest

Dockerfile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1+
FROM python:3.9-slim AS builder
2+
3+
ARG POETRY_VERSION=1.1.4
4+
RUN pip install poetry==$POETRY_VERSION
5+
6+
WORKDIR /src
7+
8+
COPY pyproject.toml poetry.lock README.md pylintrc ./
9+
COPY marge/ ./marge/
10+
RUN poetry export -o requirements.txt && \
11+
poetry build
12+
13+
114
FROM python:3.9-slim
215

316
RUN apt-get update && apt-get install -y \
417
git-core \
518
&& \
619
rm -rf /var/lib/apt/lists/*
720

8-
WORKDIR /src
9-
10-
ADD requirements_frozen.txt ./
11-
RUN pip install -r ./requirements_frozen.txt
21+
COPY --from=builder /src/requirements.txt /src/dist/marge-*.tar.gz /tmp/
1222

13-
ADD version ./
14-
ADD setup.py ./
15-
ADD marge.app ./
16-
ADD marge/ ./marge/
17-
RUN python ./setup.py install
23+
RUN pip install -r /tmp/requirements.txt && \
24+
pip install /tmp/marge-*.tar.gz
1825

19-
ENTRYPOINT ["marge.app"]
26+
ENTRYPOINT ["marge"]

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ all: dockerize
66
.PHONY: bump
77
bump: bump-requirements
88

9-
.PHONY: bump-requirements
10-
bump-requirements: clean requirements_frozen.txt
9+
poetry.lock:
10+
poetry install
11+
12+
requirements.txt: poetry.lock
13+
poetry export -o $@
14+
15+
requirements_development.txt: poetry.lock
16+
poetry export --dev -o $@
1117

12-
requirements_frozen.txt: requirements.txt
13-
pip freeze -r $^ > $@
18+
.PHONY: bump-poetry-lock
19+
bump-poetry-lock:
20+
poetry update
1421

15-
requirements_plus_development_frozen.txt: requirements_frozen.txt
16-
pip freeze -r $^ -r requirements_development.txt > $@
22+
.PHONY: clean-requirements
23+
clean-requirements:
24+
rm -rf requirements.txt requirements_development.txt
25+
26+
.PHONY: bump-requirements
27+
bump-requirements: bump-poetry-lock clean-requirements requirements.txt requirements_development.txt
1728

1829
.PHONY: dockerize
1930
dockerize:

marge.app

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

marge/__main__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from marge.app import main
2+
3+
4+
def run():
5+
try:
6+
main()
7+
except Exception as err:
8+
print('Exception occured')
9+
if hasattr(err, 'stdout'):
10+
# pylint: disable=no-member
11+
print(f'stdout was: {err.stdout}')
12+
if hasattr(err, 'stderr'):
13+
# pylint: disable=no-member
14+
print(f'stderr was: {err.stderr}')
15+
raise
16+
17+
18+
if __name__ == '__main__':
19+
run()

0 commit comments

Comments
 (0)