From 606562c7d65c05f8479e324435ba9b14ee74c9db Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Thu, 15 Dec 2022 13:02:33 +0100 Subject: [PATCH] Manage poetry dependencies with groups --- .circleci/config.yml | 8 ++++++ Dockerfile | 2 +- Makefile | 3 +- poetry.lock | 68 +++++++++++++++++++++----------------------- pyproject.toml | 41 ++++++++++++-------------- scripts/run.sh | 4 +-- 6 files changed, 62 insertions(+), 64 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fede8c6e..6799525d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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 diff --git a/Dockerfile b/Dockerfile index efb1e230..9f90015d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Makefile b/Makefile index 333ab1b6..68da07bc 100644 --- a/Makefile +++ b/Makefile @@ -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): diff --git a/poetry.lock b/poetry.lock index e4bef5af..c260377b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -77,8 +77,8 @@ tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy" name = "autograph-utils" version = "0.1.1" description = "A library to simplify use of Autograph" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.dependencies] @@ -118,8 +118,8 @@ yaml = ["PyYAML"] name = "beautifulsoup4" version = "4.11.1" description = "Screen-scraping library" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.6.0" [package.dependencies] @@ -162,8 +162,8 @@ python-versions = "~=3.7" name = "canonicaljson-rs" version = "0.4.0" description = "Python bindings for canonical_json" -category = "main" -optional = true +category = "dev" +optional = false python-versions = "*" [[package]] @@ -178,8 +178,8 @@ python-versions = ">=3.6" name = "cffi" version = "1.15.0" description = "Foreign Function Interface for Python calling C code." -category = "main" -optional = true +category = "dev" +optional = false python-versions = "*" [package.dependencies] @@ -200,7 +200,7 @@ unicode-backport = ["unicodedata2"] name = "click" version = "8.1.3" description = "Composable command line interface toolkit" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -233,8 +233,8 @@ toml = ["tomli"] name = "cryptography" version = "38.0.4" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.6" [package.dependencies] @@ -265,8 +265,8 @@ sanic = ["sanic"] name = "ecdsa" version = "0.17.0" description = "ECDSA cryptographic signature library (pure python)" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [package.dependencies] @@ -533,8 +533,8 @@ requirements-deprecated-finder = ["pip-api", "pipreqs"] name = "kinto-http" version = "11.0.0" description = "Kinto client" -category = "main" -optional = true +category = "dev" +optional = false python-versions = "*" [package.dependencies] @@ -565,8 +565,8 @@ python-versions = ">=3.6" name = "mohawk" version = "1.1.0" description = "Library for Hawk HTTP authorization" -category = "main" -optional = true +category = "dev" +optional = false python-versions = "*" [package.dependencies] @@ -730,8 +730,8 @@ python-versions = ">=3.6" name = "pycparser" version = "2.21" description = "C parser in Python" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] @@ -936,8 +936,8 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" name = "slugid" version = "2.0.0" description = "Base64 encoded uuid v4 slugs" -category = "main" -optional = true +category = "dev" +optional = false python-versions = "*" [[package]] @@ -952,8 +952,8 @@ python-versions = ">=3.6" name = "soupsieve" version = "2.3.2.post1" description = "A modern CSS selector implementation for Beautiful Soup." -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.6" [[package]] @@ -971,8 +971,8 @@ pbr = ">=2.0.0,<2.1.0 || >2.1.0" name = "taskcluster" version = "44.23.4" description = "Python client for Taskcluster" -category = "main" -optional = true +category = "dev" +optional = false python-versions = "*" [package.dependencies] @@ -990,8 +990,8 @@ test = ["aiofiles", "coverage", "flake8", "httmock", "httptest", "hypothesis", " name = "taskcluster-urls" version = "13.0.1" description = "Standardized url generator for taskcluster resources." -category = "main" -optional = true +category = "dev" +optional = false python-versions = "*" [[package]] @@ -1068,8 +1068,8 @@ python-versions = ">=3.7" name = "unidecode" version = "1.3.4" description = "ASCII transliterations of Unicode text" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.5" [[package]] @@ -1089,8 +1089,8 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] name = "websockets" version = "10.4" description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.7" [[package]] @@ -1105,14 +1105,10 @@ python-versions = ">=3.6" idna = ">=2.0" multidict = ">=4.0" -[extras] -remotesettings = ["kinto-http", "cryptography", "websockets", "requests", "beautifulsoup4", "autograph-utils", "canonicaljson-rs"] -taskcluster = ["taskcluster"] - [metadata] lock-version = "1.1" python-versions = ">=3.10,<3.11" -content-hash = "b960d1987a0c7899bae4c319b97bee130018a036214c5f37902d9099544b4066" +content-hash = "2e299560e7c686b3ba314f826f10025f3471096628f632dac1d72e99f9b3f960" [metadata.files] aiohttp = [ diff --git a/pyproject.toml b/pyproject.toml index 730645a6..0c279dcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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"] diff --git a/scripts/run.sh b/scripts/run.sh index 7e936e61..f9b42c78 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -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