Skip to content

Commit

Permalink
Upgrade python to version 3.12 (#3067)
Browse files Browse the repository at this point in the history
* Upgrade project to python version 3.12

Signed-off-by: jamshale <[email protected]>

* Fix a unit test

Signed-off-by: jamshale <[email protected]>

* Remove old loop argument from wait_for in demo

Signed-off-by: jamshale <[email protected]>

* Add small sleep for holder deleted credential tests

Signed-off-by: jamshale <[email protected]>

* Update more dockerfiles and docs to python 3.12

Signed-off-by: jamshale <[email protected]>

* Update python in RTD's

Signed-off-by: jamshale <[email protected]>

* Update poetry.lock after rebase

Signed-off-by: jamshale <[email protected]>

* Update poetry.lock after rebase

Signed-off-by: jamshale <[email protected]>

---------

Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale authored Jul 5, 2024
1 parent 314062b commit 8d4ee58
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 106 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.9-bullseye",
"VARIANT": "3.12-bullseye",
"POETRY_VERSION": "1.7.1"
}
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/nigthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: "ubuntu-20.04"
tools:
python: "3.9"
python: "3.12"

sphinx:
builder: dirhtml
Expand Down
21 changes: 12 additions & 9 deletions aries_cloudagent/core/tests/test_plugin_registry.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion demo/features/steps/0453-issue-credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']}",
)
Expand Down
2 changes: 1 addition & 1 deletion demo/playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion demo/playground/examples/Dockerfile.test.runner
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-slim
FROM python:3.12-slim
WORKDIR /usr/src/app

# install poetry
Expand Down
2 changes: 1 addition & 1 deletion demo/playground/examples/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = ""
authors = ["Jason Sherman <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.9"
python = "^3.12"
pytest = "^7.4.4"
pytest-asyncio = "^0.23.7"
asynctest = "^0.13.0"
Expand Down
2 changes: 2 additions & 0 deletions demo/runners/agent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions demo/runners/support/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.demo
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.indy
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.run
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion docs/features/devcontainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
75 changes: 3 additions & 72 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ sonar.projectKey=hyperledger_aries-cloudagent-python
sonar.organization=hyperledger
sonar.projectName=aries-cloudagent-python

sonar.python.version=3.9
sonar.python.version=3.12

0 comments on commit 8d4ee58

Please sign in to comment.