Skip to content

Commit 2f0eb05

Browse files
committed
build: move to poetry dependency management
1 parent bc9704b commit 2f0eb05

12 files changed

+1571
-67
lines changed

.dockerignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
*
23
!docs
34
!gitopscli/
@@ -7,8 +8,9 @@
78
!mkdocs.yml
89
!Makefile
910
!mypy.ini
10-
!requirements-docs.txt
11-
!requirements-test.txt
12-
!setup.py
11+
!poetry.lock
12+
!poetry.toml
13+
!pyproject.toml
14+
!README.md
1315

14-
**/__pycache__/
16+
**/__pycache__/

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
__pycache__
33
.vscode
44
.coverage
5+
dist/
56
htmlcov/
6-
venv/
7+
.venv/
78
testrepo/
89
.idea
910
*.iml
1011
.eggs/
1112
site/
1213
build/
13-
.mypy_cache
14+
.mypy_cache

.releaserc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ plugins:
66
- "@semantic-release/release-notes-generator"
77
- - "semantic-release-replace-plugin"
88
- replacements:
9-
- files: [ "setup.py" ]
9+
- files: [ "pyproject.toml" ]
1010
from: "version=\"0.0.0\""
1111
to: "version=\"${nextRelease.version}\""
1212
countMatches: true
1313
results:
14-
- file: "setup.py"
14+
- file: "pyproject.toml"
1515
hasChanged: true
1616
numMatches: 1
1717
numReplacements: 1

Dockerfile

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,56 @@
11
# =========
2-
FROM python:3.10-alpine AS base
2+
FROM alpine:3.18 AS base
33

4-
ENV PATH="/opt/venv/bin:$PATH"
5-
RUN apk add --no-cache git
4+
ENV PATH="/app/.venv/bin:$PATH" \
5+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
6+
PIP_NO_CACHE_DIR=1 \
7+
PYTHONFAULTHANDLER=1 \
8+
PYTHONHASHSEED=random \
9+
PYTHONUNBUFFERED=1
10+
RUN apk add --no-cache git python3
611

712
# =========
813
FROM base AS dev
914

10-
WORKDIR /workdir
11-
RUN apk add --no-cache gcc linux-headers musl-dev make
12-
RUN python -m venv /opt/venv
13-
RUN python -m pip install --upgrade pip
15+
WORKDIR /app
16+
RUN apk add --no-cache gcc linux-headers musl-dev make poetry python3-dev
17+
COPY pyproject.toml poetry.lock poetry.toml ./
1418

1519
# =========
1620
FROM dev AS deps
1721

18-
COPY setup.py .
19-
RUN pip install .
22+
RUN poetry install --only main
2023

2124
# =========
2225
FROM deps AS test
2326

24-
COPY requirements-test.txt .
25-
RUN pip install -r requirements-test.txt
27+
RUN poetry install --with test
2628
COPY . .
2729
RUN pip install .
2830
RUN make checks
2931

3032
# =========
31-
FROM dev AS docs
33+
FROM deps AS docs
3234

33-
COPY requirements-docs.txt .
34-
RUN pip install -r requirements-docs.txt
35+
RUN poetry install --with docs
3536
COPY docs ./docs
3637
COPY CONTRIBUTING.md mkdocs.yml ./
3738
RUN mkdocs build
3839

3940
# =========
4041
FROM scratch AS docs-site
4142

42-
COPY --from=docs /workdir/site /site
43+
COPY --from=docs /app/site /site
4344

4445
# =========
4546
FROM deps AS install
4647

4748
COPY . .
48-
RUN pip install .
49+
RUN poetry build
50+
RUN pip install dist/gitopscli-*.whl
4951

5052
# =========
5153
FROM base as final
5254

53-
COPY --from=install /opt/venv /opt/venv
55+
COPY --from=install /app/.venv /app/.venv
5456
ENTRYPOINT ["gitopscli"]

Makefile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
BLACK_ARGS = -l 120 -t py310 gitopscli tests setup.py
1+
BLACK_ARGS = -l 120 -t py310 gitopscli tests
22

33
init:
4-
pip3 install --editable .
5-
pip3 install -r requirements-test.txt
6-
pip3 install -r requirements-docs.txt
4+
poetry install
75
pre-commit install
86

97
format:
10-
python3 -m black $(BLACK_ARGS)
8+
poetry run black $(BLACK_ARGS)
119

1210
format-check:
13-
python3 -m black $(BLACK_ARGS) --check
11+
poetry run black $(BLACK_ARGS) --check
1412

1513
lint:
16-
python3 -m pylint gitopscli
14+
poetry run pylint gitopscli
1715

1816
mypy:
19-
python3 -m mypy --install-types --non-interactive .
17+
poetry run mypy --install-types --non-interactive .
2018

2119
test:
22-
python3 -m pytest -vv -s --typeguard-packages=gitopscli
20+
poetry run pytest -vv -s --typeguard-packages=gitopscli
2321

2422
coverage:
2523
coverage run -m pytest
@@ -34,4 +32,7 @@ image:
3432
docs:
3533
mkdocs serve
3634

37-
.PHONY: init format format-check lint mypy test coverage checks image docs
35+
update:
36+
poetry lock
37+
38+
.PHONY: init format format-check lint mypy test coverage checks image docs update

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ Currently, we support BitBucket Server, GitHub and Gitlab.
3838
### Setup
3939

4040
```bash
41-
python3 -m venv venv # create and activate virtual environment
42-
source venv/bin/activate # enter virtual environment
4341
make init # install dependencies, setup dev gitopscli, install pre-commit hooks, ...
44-
deactivate # leave virtual environment (after development)
4542
```
4643

4744
### Commands

poetry.lock

Lines changed: 1478 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[virtualenvs]
2+
create = true
3+
in-project = true

pyproject.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[tool.poetry]
2+
name = "gitopscli"
3+
version = "0.0.0"
4+
description = "GitOps CLI is a command line interface (CLI) to perform operations on GitOps managed infrastructure repositories, including updates in YAML files."
5+
authors = ["Christian Siegel <[email protected]>"]
6+
readme = "README.md"
7+
repository = "https://github.com/baloise/gitopscli"
8+
9+
[tool.poetry.scripts]
10+
gitopscli = "gitopscli.__main__:main"
11+
12+
[tool.poetry.dependencies]
13+
python = "^3.10"
14+
gitpython = "==3.1.37"
15+
"ruamel.yaml" = "==0.16.5"
16+
jsonpath-ng = "==1.5.3"
17+
atlassian-python-api = "==1.14.5"
18+
pygithub = "==1.53"
19+
python-gitlab = "==2.6.0"
20+
21+
[tool.poetry.group.test.dependencies]
22+
black = "==22.10.0"
23+
coverage = "==5.3"
24+
pylint = "==2.17.2"
25+
pytest = "==7.1.3"
26+
mypy = "==0.982"
27+
typeguard = "==2.13.3"
28+
pre-commit = "==2.20.0"
29+
30+
[tool.poetry.group.docs.dependencies]
31+
mkdocs = "==1.3.0"
32+
mkdocs-material = "==8.2.12"
33+
markdown-include = "==0.6.0"
34+
pymdown-extensions = "==10.0"
35+
Markdown = "==3.3.7"
36+
37+
[tool.ruff]
38+
line-length = 120
39+
40+
[tool.ruff.per-file-ignores]
41+
"**/__init__.py" = ["F401"]
42+
"tests/*.py" = ["E501"]
43+
44+
[build-system]
45+
requires = ["poetry-core>=1.0.0"]
46+
build-backend = "poetry.core.masonry.api"
47+
48+
[virtualenvs]
49+
in-project = true

requirements-docs.txt

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

0 commit comments

Comments
 (0)