Skip to content

Commit

Permalink
Manage poetry dependencies with groups
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Dec 15, 2022
1 parent bfbf4b5 commit 606562c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 64 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ jobs:
steps:
- checkout

- run:
name: Use latest poetry
command: curl -sSL https://install.python-poetry.org | python3 -

- run:
name: Code lint
command: make lint
Expand All @@ -16,6 +20,10 @@ jobs:
steps:
- checkout

- run:
name: Use latest poetry
command: curl -sSL https://install.python-poetry.org | python3 -

- run:
name: Test
command: make tests
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ EXPOSE 8000
# run as non priviledged user
USER app

RUN poetry install --extras=remotesettings --extras=taskcluster --no-dev --no-interaction --verbose
RUN poetry install --with remotesettings,taskcluster --without dev --no-ansi --no-interaction --verbose

ENTRYPOINT ["/app/scripts/run.sh"]
CMD ["server"]
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ COMMIT := $(shell git log --pretty=format:'%H' -n 1)
install: $(INSTALL_STAMP) $(COMMIT_HOOK)
$(INSTALL_STAMP): pyproject.toml poetry.lock
@if [ -z $(POETRY) ]; then echo "Poetry could not be found. See https://python-poetry.org/docs/"; exit 2; fi
$(POETRY) install --extras=remotesettings --extras=taskcluster
$(POETRY) --version
$(POETRY) install --with remotesettings,taskcluster --no-ansi --no-interaction --verbose
touch $(INSTALL_STAMP)

$(COMMIT_HOOK):
Expand Down
68 changes: 32 additions & 36 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 18 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@ backoff = "^2.2.1"
python-decouple = "^3.6"
logging-color-formatter = "^1.0.3"
google-cloud-bigquery = "^3.4.0"
# Extra dependencies for checks.
kinto-http = { version = "^11.0.0", optional = true }
cryptography = { version = "^38.0.4", optional = true }
websockets = { version = "^10.4", optional = true }
requests = { version = "^2.28.1", optional = true }
beautifulsoup4 = { version = "^4.11.1", optional = true }
autograph-utils = { version = "^0.1.1", optional = true }
canonicaljson-rs = { version = "^0.4.0", optional = true }
taskcluster = { version = "^44.23.4", optional = true }

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "^7.2.0"
aioresponses = "^0.7.3"
pytest-aiohttp = "^1.0.4"
Expand All @@ -42,19 +33,23 @@ types-toml = "^0.10.8"
types-requests = "^2.28.11"
types-termcolor = "^1.1.6"

[tool.poetry.extras]
remotesettings = [
"kinto-http",
"cryptography",
"websockets",
"requests",
"beautifulsoup4",
"autograph-utils",
"canonicaljson-rs",
]
taskcluster = [
"taskcluster",
]
[tool.poetry.group.remotesettings]
optional = true

[tool.poetry.group.taskcluster]
optional = true

[tool.poetry.group.remotesettings.dependencies]
kinto-http = "^11.0.0"
cryptography = "^38.0.4"
websockets = "^10.4"
requests = "^2.28.1"
beautifulsoup4 = "^4.11.1"
autograph-utils = "^0.1.1"
canonicaljson-rs = "^0.4.0"

[tool.poetry.group.taskcluster.dependencies]
taskcluster = "^44.23.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
4 changes: 1 addition & 3 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ elif [ $1 == "check" ]; then
exec poetry run python -m telescope $@

elif [ $1 == "test" ]; then
# Note: poetry has no option to only install dev dependencies.
# https://github.com/python-poetry/poetry/issues/2572
poetry install --extras=remotesettings --extras=taskcluster
poetry install --only dev --no-ansi --no-interaction --verbose
poetry run pytest tests

else
Expand Down

0 comments on commit 606562c

Please sign in to comment.