From 8d4ee585097f1f6f12427de4bdefdf8dda272678 Mon Sep 17 00:00:00 2001 From: jamshale <31809382+jamshale@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:54:51 -0700 Subject: [PATCH] Upgrade python to version 3.12 (#3067) * Upgrade project to python version 3.12 Signed-off-by: jamshale * Fix a unit test Signed-off-by: jamshale * Remove old loop argument from wait_for in demo Signed-off-by: jamshale * Add small sleep for holder deleted credential tests Signed-off-by: jamshale * Update more dockerfiles and docs to python 3.12 Signed-off-by: jamshale * Update python in RTD's Signed-off-by: jamshale * Update poetry.lock after rebase Signed-off-by: jamshale * Update poetry.lock after rebase Signed-off-by: jamshale --------- Signed-off-by: jamshale --- .devcontainer/Dockerfile | 4 +- .devcontainer/devcontainer.json | 2 +- .github/workflows/format.yml | 2 +- .github/workflows/nigthly.yml | 2 +- .github/workflows/pr-tests.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/sonar-merge-main.yml | 2 +- .readthedocs.yaml | 2 +- .../core/tests/test_plugin_registry.py | 21 +++--- demo/features/steps/0453-issue-credential.py | 2 +- demo/playground/README.md | 2 +- .../examples/Dockerfile.test.runner | 2 +- demo/playground/examples/pyproject.toml | 2 +- demo/runners/agent_container.py | 2 + demo/runners/support/agent.py | 4 +- docker/Dockerfile | 2 +- docker/Dockerfile.demo | 2 +- docker/Dockerfile.indy | 2 +- docker/Dockerfile.run | 4 +- docker/Dockerfile.test | 2 +- docs/features/devcontainer.md | 2 +- docs/readthedocs.yaml | 2 +- poetry.lock | 75 +------------------ pyproject.toml | 2 +- sonar-project.properties | 2 +- 25 files changed, 42 insertions(+), 106 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 12b6218ab4..7c00242956 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,6 @@ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.134.0/containers/python-3/.devcontainer/base.Dockerfile -ARG VARIANT="3.9" -FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} +ARG VARIANT="3.12" +FROM mcr.microsoft.com/devcontainers/python:${VARIANT} ARG POETRY_VERSION="1.4" ENV POETRY_HOME="/opt/poetry" \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c377a666fe..6eeb824f40 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,7 @@ "dockerfile": "Dockerfile", "context": "..", "args": { - "VARIANT": "3.9-bullseye", + "VARIANT": "3.12-bullseye", "POETRY_VERSION": "1.7.1" } }, diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 17a6ba3942..77918ae3f3 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -13,6 +13,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.12" - name: Ruff Format and Lint Check uses: chartboost/ruff-action@v1 diff --git a/.github/workflows/nigthly.yml b/.github/workflows/nigthly.yml index 7427d28d21..ef28b719e1 100644 --- a/.github/workflows/nigthly.yml +++ b/.github/workflows/nigthly.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest"] - python-version: ["3.9", "3.10"] + python-version: ["3.12"] if: github.repository == 'hyperledger/aries-cloudagent-python' || github.event_name == 'workflow_dispatch' steps: - name: checkout diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index 6813b88dc0..0403ca1548 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -16,6 +16,6 @@ jobs: - name: Tests uses: ./.github/actions/run-unit-tests with: - python-version: "3.9" + python-version: "3.12" os: "ubuntu-latest" is_pr: "true" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8195dc1b7c..9a0b9a88a0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,7 +42,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9'] + python-version: ['3.12'] name: Publish ACA-Py Image runs-on: ubuntu-latest diff --git a/.github/workflows/sonar-merge-main.yml b/.github/workflows/sonar-merge-main.yml index 0962261203..e63f649f7e 100644 --- a/.github/workflows/sonar-merge-main.yml +++ b/.github/workflows/sonar-merge-main.yml @@ -15,7 +15,7 @@ jobs: - name: Tests uses: ./.github/actions/run-unit-tests with: - python-version: "3.9" + python-version: "3.12" os: "ubuntu-latest" is_pr: "false" - name: Adjust Test Coverage Source diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 1463fd36ef..4865ff8187 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -3,7 +3,7 @@ version: 2 build: os: "ubuntu-20.04" tools: - python: "3.9" + python: "3.12" sphinx: builder: dirhtml diff --git a/aries_cloudagent/core/tests/test_plugin_registry.py b/aries_cloudagent/core/tests/test_plugin_registry.py index 07c3bd0f69..f348f64c52 100644 --- a/aries_cloudagent/core/tests/test_plugin_registry.py +++ b/aries_cloudagent/core/tests/test_plugin_registry.py @@ -1,17 +1,16 @@ +from unittest import IsolatedAsyncioTestCase +from unittest.mock import call + import pytest from aries_cloudagent.tests import mock -from unittest import IsolatedAsyncioTestCase -from unittest.mock import call from ...config.injection_context import InjectionContext from ...utils.classloader import ClassLoader, ModuleLoadError - +from ..error import ProtocolDefinitionValidationError +from ..goal_code_registry import GoalCodeRegistry from ..plugin_registry import PluginRegistry from ..protocol_registry import ProtocolRegistry -from ..goal_code_registry import GoalCodeRegistry - -from ..error import ProtocolDefinitionValidationError class TestPluginRegistry(IsolatedAsyncioTestCase): @@ -365,9 +364,13 @@ async def test_validate_version_list_correct(self): ) as load_module: assert self.registry.validate_version(versions, mod_name) is True - load_module.has_calls( - call(versions[0]["path"], mod_name), - call(versions[1]["path"], mod_name), + load_module.assert_has_calls( + [ + call("v1_0", "test_mod"), + call().__bool__(), + call("v2_0", "test_mod"), + call().__bool__(), + ] ) async def test_validate_version_list_extra_attributes_ok(self): diff --git a/demo/features/steps/0453-issue-credential.py b/demo/features/steps/0453-issue-credential.py index 6dc33f428d..d42d3866cf 100644 --- a/demo/features/steps/0453-issue-credential.py +++ b/demo/features/steps/0453-issue-credential.py @@ -98,7 +98,7 @@ def step_impl(context, issuer, credential_data): context.cred_exchange = cred_exchange # delete this immediately, hopefully this is committed before the holder "accepts" it - resp = agent_container_DELETE( + agent_container_DELETE( agent["agent"], f"/issue-credential-2.0/records/{cred_exchange['cred_ex_id']}", ) diff --git a/demo/playground/README.md b/demo/playground/README.md index fd8004ed0d..418a1ee188 100644 --- a/demo/playground/README.md +++ b/demo/playground/README.md @@ -26,7 +26,7 @@ These configuration files are provided to the ACA-Py start command via the `AGEN ### Dockerfile and start.sh -[`Dockerfile.acapy`](./Dockerfile.acapy) assembles the image to run. Currently based on [Aries Cloudagent Python 0.8.1](ghcr.io/hyperledger/aries-cloudagent-python:py3.9-indy-1.16.0-0.8.1), we need [jq](https://stedolan.github.io/jq/) to setup (or not) the ngrok tunnel and execute the Aca-py start command - see [`start.sh`](./start.sh). You may note that the start command is very sparse, additional configuration is done via environment variables in the [docker compose file](./docker-compose.yml). +[`Dockerfile.acapy`](./Dockerfile.acapy) assembles the image to run. Currently based on [Aries Cloudagent Python 0.21.1](ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.12.1), we need [jq](https://stedolan.github.io/jq/) to setup (or not) the ngrok tunnel and execute the Aca-py start command - see [`start.sh`](./start.sh). You may note that the start command is very sparse, additional configuration is done via environment variables in the [docker compose file](./docker-compose.yml). ### ngrok diff --git a/demo/playground/examples/Dockerfile.test.runner b/demo/playground/examples/Dockerfile.test.runner index 95f0d2461c..18b7bb6e1b 100644 --- a/demo/playground/examples/Dockerfile.test.runner +++ b/demo/playground/examples/Dockerfile.test.runner @@ -1,4 +1,4 @@ -FROM python:3.9-slim +FROM python:3.12-slim WORKDIR /usr/src/app # install poetry diff --git a/demo/playground/examples/pyproject.toml b/demo/playground/examples/pyproject.toml index fd4b622227..2a4ee5ae58 100644 --- a/demo/playground/examples/pyproject.toml +++ b/demo/playground/examples/pyproject.toml @@ -5,7 +5,7 @@ description = "" authors = ["Jason Sherman "] [tool.poetry.dependencies] -python = "^3.9" +python = "^3.12" pytest = "^7.4.4" pytest-asyncio = "^0.23.7" asynctest = "^0.13.0" diff --git a/demo/runners/agent_container.py b/demo/runners/agent_container.py index 9a84f54aef..9598412e00 100644 --- a/demo/runners/agent_container.py +++ b/demo/runners/agent_container.py @@ -274,6 +274,8 @@ async def handle_issue_credential_v2_0(self, message): elif state == "offer-received": log_status("#15 After receiving credential offer, send credential request") + # Should wait for a tiny bit for the delete tests + await asyncio.sleep(0.2) if not message.get("by_format"): # this should not happen, something hinky when running in IDE... # this will work if using indy payloads diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index a1391a4e3f..703261cf34 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -943,7 +943,7 @@ async def start_process(self, python_path: str = None, wait: bool = True): future = loop.run_in_executor( self.thread_pool_executor, self._process, agent_args, my_env, loop ) - self.proc = await asyncio.wait_for(future, 20, loop=loop) + self.proc = await asyncio.wait_for(future, 20) if wait: await asyncio.sleep(1.0) await self.detect_process() @@ -970,7 +970,7 @@ async def terminate(self): loop = asyncio.get_event_loop() if self.proc: future = loop.run_in_executor(self.thread_pool_executor, self._terminate) - result = await asyncio.wait_for(future, 10, loop=loop) + await asyncio.wait_for(future, 10) async def listen_webhooks(self, webhook_port): self.webhook_port = webhook_port diff --git a/docker/Dockerfile b/docker/Dockerfile index 3b485b39ec..c5e6294c80 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -ARG python_version=3.9.18 +ARG python_version=3.12 FROM python:${python_version}-slim-bullseye AS build WORKDIR /src diff --git a/docker/Dockerfile.demo b/docker/Dockerfile.demo index a518150a9d..a841f9aa75 100644 --- a/docker/Dockerfile.demo +++ b/docker/Dockerfile.demo @@ -1,4 +1,4 @@ -ARG from_image=ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.9.0 +ARG from_image=ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.12.1 FROM ${from_image} ENV ENABLE_PTVSD 0 diff --git a/docker/Dockerfile.indy b/docker/Dockerfile.indy index 65b5ae83cc..0218fef0da 100644 --- a/docker/Dockerfile.indy +++ b/docker/Dockerfile.indy @@ -1,4 +1,4 @@ -ARG python_version=3.9.18 +ARG python_version=3.12.4 ARG rust_version=1.46 # This image could be replaced with an "indy" image from another repo, diff --git a/docker/Dockerfile.run b/docker/Dockerfile.run index 79839a3d93..d18b976e3a 100644 --- a/docker/Dockerfile.run +++ b/docker/Dockerfile.run @@ -1,5 +1,5 @@ -ARG python_version=3.9.16 -FROM python:3.9-slim-bullseye +ARG python_version=3.12.4 +FROM python:3.12-slim-bullseye RUN apt-get update -y && \ apt-get install -y --no-install-recommends \ diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test index 6ad3c1e933..8fa16bb1b6 100644 --- a/docker/Dockerfile.test +++ b/docker/Dockerfile.test @@ -1,4 +1,4 @@ -ARG python_version=3.9.18 +ARG python_version=3.12.4 FROM python:${python_version}-slim-bullseye RUN apt-get update -y && \ diff --git a/docs/features/devcontainer.md b/docs/features/devcontainer.md index d6bb547e33..73dc62b1f4 100644 --- a/docs/features/devcontainer.md +++ b/docs/features/devcontainer.md @@ -44,7 +44,7 @@ To open ACA-Py in a devcontainer, we open the *root* of this repository. We can #### devcontainer.json -When the [.devcontainer/devcontainer.json](https://github.com/hyperledger/aries-cloudagent-python/blob/main/.devcontainer/devcontainer.json) is opened, you will see it building... it is building a Python 3.9 image (bash shell) and loading it with all the ACA-Py requirements. We also load a few Visual Studio settings (for running Pytests and formatting with Ruff). +When the [.devcontainer/devcontainer.json](https://github.com/hyperledger/aries-cloudagent-python/blob/main/.devcontainer/devcontainer.json) is opened, you will see it building... it is building a Python 3.12 image (bash shell) and loading it with all the ACA-Py requirements. We also load a few Visual Studio settings (for running Pytests and formatting with Ruff). ### Poetry diff --git a/docs/readthedocs.yaml b/docs/readthedocs.yaml index 58126736d6..a1cdf7e435 100644 --- a/docs/readthedocs.yaml +++ b/docs/readthedocs.yaml @@ -5,7 +5,7 @@ version: 2 build: os: "ubuntu-20.04" tools: - python: "3.7" + python: "3.12" # Build from the docs/ directory with Sphinx sphinx: diff --git a/poetry.lock b/poetry.lock index 4c29bdeabf..5602f78b7e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "aiohttp" @@ -87,7 +87,6 @@ files = [ [package.dependencies] aiosignal = ">=1.1.2" -async-timeout = {version = ">=4.0,<5.0", markers = "python_version < \"3.11\""} attrs = ">=17.3.0" frozenlist = ">=1.1.1" multidict = ">=4.5,<7.0" @@ -565,9 +564,6 @@ files = [ {file = "coverage-7.5.4.tar.gz", hash = "sha256:a44963520b069e12789d0faea4e9fdb1e410cdc4aab89d94f7f55cbb7fef0353"}, ] -[package.dependencies] -tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} - [package.extras] toml = ["tomli"] @@ -903,20 +899,6 @@ dev = ["build (>=0.9.0)", "bumpversion (>=0.5.3)", "eth-hash[pycryptodome]", "hy docs = ["sphinx (>=6.0.0)", "sphinx-autobuild (>=2021.3.14)", "sphinx-rtd-theme (>=1.0.0)", "towncrier (>=21,<22)"] test = ["hypothesis (>=4.43.0)", "mypy (==1.5.1)", "pytest (>=7.0.0)", "pytest-xdist (>=2.4.0)"] -[[package]] -name = "exceptiongroup" -version = "1.2.1" -description = "Backport of PEP 654 (exception groups)" -optional = false -python-versions = ">=3.7" -files = [ - {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, - {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, -] - -[package.extras] -test = ["pytest (>=6)"] - [[package]] name = "filelock" version = "3.15.4" @@ -1097,25 +1079,6 @@ files = [ {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, ] -[[package]] -name = "importlib-metadata" -version = "8.0.0" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "importlib_metadata-8.0.0-py3-none-any.whl", hash = "sha256:15584cf2b1bf449d98ff8a6ff1abef57bf20f3ac6454f431736cd3e660921b2f"}, - {file = "importlib_metadata-8.0.0.tar.gz", hash = "sha256:188bd24e4c346d3f0a933f275c2fec67050326a856b9a359881d7c2a697e8812"}, -] - -[package.dependencies] -zipp = ">=0.5" - -[package.extras] -doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -perf = ["ipython"] -test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] - [[package]] name = "indy-credx" version = "1.1.1" @@ -1379,9 +1342,6 @@ files = [ {file = "Markdown-3.6.tar.gz", hash = "sha256:ed4f41f6daecbeeb96e576ce414c41d2d876daa9a16cb35fa8ed8c2ddfad0224"}, ] -[package.dependencies] -importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""} - [package.extras] docs = ["mdx-gh-links (>=0.2)", "mkdocs (>=1.5)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"] testing = ["coverage", "pyyaml"] @@ -2080,11 +2040,9 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} -exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" pluggy = ">=1.5,<2.0" -tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] @@ -2392,7 +2350,6 @@ babel = ">=2.9" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} docutils = ">=0.14,<0.20" imagesize = ">=1.3" -importlib-metadata = {version = ">=4.8", markers = "python_version < \"3.10\""} Jinja2 = ">=3.0" packaging = ">=21.0" Pygments = ">=2.12" @@ -2537,17 +2494,6 @@ lint = ["docutils-stubs", "flake8", "mypy"] standalone = ["Sphinx (>=5)"] test = ["pytest"] -[[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" -optional = false -python-versions = ">=3.7" -files = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] - [[package]] name = "toolz" version = "0.12.1" @@ -2851,21 +2797,6 @@ files = [ idna = ">=2.0" multidict = ">=4.0" -[[package]] -name = "zipp" -version = "3.19.2" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.8" -files = [ - {file = "zipp-3.19.2-py3-none-any.whl", hash = "sha256:f091755f667055f2d02b32c53771a7a6c8b47e1fdbc4b72a8b9072b3eef8015c"}, - {file = "zipp-3.19.2.tar.gz", hash = "sha256:bf1dcf6450f873a13e952a29504887c89e6de7506209e5b1bcc3460135d4de19"}, -] - -[package.extras] -doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] - [extras] askar = ["anoncreds", "aries-askar", "indy-credx", "indy-vdr"] bbs = ["ursa-bbs-signatures"] @@ -2873,5 +2804,5 @@ didcommv2 = ["didcomm-messaging"] [metadata] lock-version = "2.0" -python-versions = "^3.9" -content-hash = "b9b5c9bd6d1d376e8757cd1f8bada6436221c239743ea92f2fd41ea325de2d20" +python-versions = "^3.12" +content-hash = "58a564395c05d000e594b4813ab610137fc3be343f8e1238c5c1c1df8935ca23" diff --git a/pyproject.toml b/pyproject.toml index 7c7e612fb1..23172a7365 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ repository = "https://github.com/hyperledger/aries-cloudagent-python" [tool.poetry.dependencies] -python = "^3.9" +python = "^3.12" aiohttp="~3.9.4" aiohttp-apispec-acapy="~3.0.2" aiohttp-cors="~0.7.0" diff --git a/sonar-project.properties b/sonar-project.properties index 03ad4b3b74..6c87546ee1 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,4 +2,4 @@ sonar.projectKey=hyperledger_aries-cloudagent-python sonar.organization=hyperledger sonar.projectName=aries-cloudagent-python -sonar.python.version=3.9 \ No newline at end of file +sonar.python.version=3.12 \ No newline at end of file