Skip to content

Commit

Permalink
Merge pull request #1660 from GaloisInc/rem/fix-1653/fix-1645
Browse files Browse the repository at this point in the history
Update cryptol-remote-api to Python 3.12
  • Loading branch information
mccleeary-galois authored May 15, 2024
2 parents be32aaa + 5d3335b commit 079de61
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 176 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: '3.12'

- uses: abatilo/[email protected]
with:
Expand Down Expand Up @@ -322,7 +322,7 @@ jobs:
- if: matrix.suite == 'rpc'
uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: '3.12'

- if: matrix.suite == 'rpc'
uses: abatilo/[email protected]
Expand Down Expand Up @@ -464,7 +464,7 @@ jobs:
- if: matrix.image == 'ghcr.io/galoisinc/cryptol-remote-api'
uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: '3.12'

- if: matrix.image == 'ghcr.io/galoisinc/cryptol-remote-api'
uses: abatilo/[email protected]
Expand Down
5 changes: 5 additions & 0 deletions cryptol-remote-api/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,8 @@ cryptol.connect(url="http://localhost:8080/", reset_server=True)

will connect to a Cryptol server running at `http://localhost:8080/` and will
guarantee any previous state on the server is cleared.


## Supported Python Versions

Currently, `cryptol-remote-api` officially supports python `3.12`. The `cryptol-remote-api` Docker image currently uses Python 3.10 and will be updated in issue #1661.
2 changes: 1 addition & 1 deletion cryptol-remote-api/python/cryptol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from enum import Enum
from dataclasses import dataclass
from distutils.spawn import find_executable
from shutil import which
from typing import Any, List, NoReturn, Optional, Union
from typing_extensions import Literal

Expand Down
6 changes: 3 additions & 3 deletions cryptol-remote-api/python/cryptol/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import os
import sys
from distutils.spawn import find_executable
from shutil import which
from typing import Any, List, Optional, Union, TextIO
from typing_extensions import Literal

Expand Down Expand Up @@ -77,7 +77,7 @@ def connect(command : Optional[str]=None,
if c is None:
command = os.getenv('CRYPTOL_SERVER')
if command is not None:
command = find_executable(command)
command = which(command)
if command is not None:
c = CryptolConnection(command+" socket", cryptol_path=cryptol_path, log_dest=log_dest, timeout=timeout)
# Check `CRYPTOL_SERVER_URL` env var if no connection identified yet
Expand All @@ -87,7 +87,7 @@ def connect(command : Optional[str]=None,
c = CryptolConnection(ServerConnection(HttpProcess(url,verify=verify)), cryptol_path, log_dest=log_dest, timeout=timeout)
# Check if `cryptol-remote-api` is in the PATH if no connection identified yet
if c is None:
command = find_executable('cryptol-remote-api')
command = which('cryptol-remote-api')
if command is not None:
c = CryptolConnection(command+" socket", cryptol_path=cryptol_path, log_dest=log_dest, timeout=timeout)
# Raise an error if still no connection identified yet
Expand Down
2 changes: 1 addition & 1 deletion cryptol-remote-api/python/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
no_implicit_optional = True
python_version = 3.7
python_version = 3.12
warn_return_any = True
warn_unused_configs = True
warn_unused_ignores = True
Expand Down
290 changes: 145 additions & 145 deletions cryptol-remote-api/python/poetry.lock

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions cryptol-remote-api/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ BitVector = "^3.4.9"
argo-client = "0.0.11"
typing-extensions = "^4.1.1"

# cryptol does not directly depend on these but mypy does depend on these.
# These not being locked caused CI to fail due to these updating automatically, see https://github.com/GaloisInc/cryptol/issues/1643.
# We will want to unlock these at some point, see https://github.com/GaloisInc/cryptol/issues/1645.
requests = "<2.31.0.20240310"
urllib3 = "<2.2.0"
types-requests = "<2.31.0.20240310"
requests = ">=2.31.0"
urllib3 = ">=2.2.0"
types-requests = ">=2.31.0"

[tool.poetry.dev-dependencies]
mypy = "^0.991"
mypy = "^1.10"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
4 changes: 2 additions & 2 deletions cryptol-remote-api/python/tests/cryptol/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io
import os
import time
from distutils.spawn import find_executable
from shutil import which
import cryptol
import cryptol.cryptoltypes
from cryptol.single_connection import *
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_check_timeout(self):

def test_interrupt(self):
# Check if this test is using a local server, if not we assume it's a remote HTTP server
if os.getenv('CRYPTOL_SERVER') is not None or find_executable('cryptol-remote-api'):
if os.getenv('CRYPTOL_SERVER') is not None or which('cryptol-remote-api'):
c = self.c
c.load_file(str(Path('tests','cryptol','test-files', 'examples','AES.cry')))

Expand Down
10 changes: 5 additions & 5 deletions cryptol-remote-api/python/tests/cryptol/test_cryptol_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time
import unittest
import signal
from distutils.spawn import find_executable
from shutil import which
import cryptol
import argo_client.connection as argo
import cryptol.cryptoltypes
Expand Down Expand Up @@ -186,9 +186,9 @@ def setUpClass(self):
else:
server = os.getenv('CRYPTOL_SERVER')
if server is not None:
server = find_executable(server)
server = which(server)
if server is None:
server = find_executable('cryptol-remote-api')
server = which('cryptol-remote-api')
if server is not None:
self.p = subprocess.Popen(
[server, "http", "/", "--port", "8080"],
Expand Down Expand Up @@ -248,9 +248,9 @@ def setUpClass(self):
os.system('openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt')
server = os.getenv('CRYPTOL_SERVER')
if server is not None:
server = find_executable(server)
server = which(server)
if server is None:
server = find_executable('cryptol-remote-api')
server = which('cryptol-remote-api')
if server is not None:
self.p = subprocess.Popen(
[server, "http", "/", "--port", "8081", "--tls"],
Expand Down
8 changes: 4 additions & 4 deletions cryptol-remote-api/python/tests/cryptol/test_low_level_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import argo_client.connection as argo
import cryptol
from distutils.spawn import find_executable
from shutil import which

# cryptol_path = dir_path.joinpath('data')

Expand Down Expand Up @@ -39,7 +39,7 @@ class LowLevelCryptolApiTests(unittest.TestCase):
def setUpClass(self):
server = os.getenv('CRYPTOL_SERVER')
if server:
server = find_executable(server)
server = which(server)
if server:
self.c = argo.ServerConnection(argo.DynamicSocketProcess(server + " socket"))
else:
Expand All @@ -49,7 +49,7 @@ def setUpClass(self):
if server:
self.c = argo.ServerConnection(argo.HttpProcess(server, verify=False))
else:
server = find_executable('cryptol-remote-api')
server = which('cryptol-remote-api')
if server:
self.c = argo.ServerConnection(argo.StdIOProcess(server + " stdio"))
else:
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_low_level_api(self):
# env = os.environ.copy()
# env['CRYPTOLPATH'] = cryptol_path

# if find_executable("cryptol-remote-api"):
# if which("cryptol-remote-api"):
# p = subprocess.Popen(
# ["cryptol-remote-api", "socket", "--port", "50005"],
# stdout=subprocess.DEVNULL,
Expand Down
6 changes: 3 additions & 3 deletions cryptol-remote-api/python/tests/cryptol_eval/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess
import time
import unittest
from distutils.spawn import find_executable
from shutil import which
import cryptol
from cryptol.bitvector import BV

Expand Down Expand Up @@ -61,9 +61,9 @@ def setUpClass(self):
dir_path = Path(os.path.dirname(os.path.realpath(__file__)), "test-files")
server = os.getenv('CRYPTOL_SERVER')
if server is not None:
server = find_executable(server)
server = which(server)
if server is None:
server = find_executable('cryptol-eval-server')
server = which('cryptol-eval-server')
if server is not None:
new_env = os.environ.copy()
new_env["CRYPTOLPATH"] = str(dir_path)
Expand Down
2 changes: 1 addition & 1 deletion cryptol-remote-api/test.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11
FROM python:3.12
# Intended to be built from the root of the cryptol git repository

COPY cryptol-remote-api/python python
Expand Down

0 comments on commit 079de61

Please sign in to comment.