From 5ce68d2d23a24505b0591e51562323163b2a7a43 Mon Sep 17 00:00:00 2001 From: Yukihiro Okada Date: Thu, 29 May 2025 14:13:40 +0900 Subject: [PATCH 1/3] Use orjson instead of json --- setup.py | 4 +++- trino/client.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e497ab36..a38715d4 100755 --- a/setup.py +++ b/setup.py @@ -32,12 +32,13 @@ # PyPy compatibility issue https://github.com/jborean93/pykrb5/issues/49 "krb5 == 0.5.1"] sqlalchemy_require = ["sqlalchemy >= 1.3"] +orjson_require = ["orjson >= 3.0.0"] external_authentication_token_cache_require = ["keyring"] # We don't add localstorage_require to all_require as users must explicitly opt in to use keyring. all_require = kerberos_require + sqlalchemy_require -tests_require = all_require + gssapi_require + [ +tests_require = all_require + gssapi_require + orjson_require + [ # httpretty >= 1.1 duplicates requests in `httpretty.latest_requests` # https://github.com/gabrielfalcao/HTTPretty/issues/425 "httpretty < 1.1", @@ -96,6 +97,7 @@ "kerberos": kerberos_require, "gssapi": gssapi_require, "sqlalchemy": sqlalchemy_require, + "orjson": orjson_require, "tests": tests_require, "external-authentication-token-cache": external_authentication_token_cache_require, }, diff --git a/trino/client.py b/trino/client.py index 7cc1f0f2..c474c0a5 100644 --- a/trino/client.py +++ b/trino/client.py @@ -39,7 +39,10 @@ import base64 import copy import functools -import json +try: + import orjson as json +except ImportError: + import json import os import random import re From f46e56d8e61f4bde1d55aa8b451ab152f62fd99f Mon Sep 17 00:00:00 2001 From: Yukihiro Okada Date: Thu, 29 May 2025 18:38:07 +0900 Subject: [PATCH 2/3] Exclude pypy --- trino/client.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/trino/client.py b/trino/client.py index c474c0a5..b6e453b4 100644 --- a/trino/client.py +++ b/trino/client.py @@ -39,13 +39,10 @@ import base64 import copy import functools -try: - import orjson as json -except ImportError: - import json import os import random import re +import sys import threading import urllib.parse import warnings @@ -87,6 +84,14 @@ from trino.mapper import RowMapper from trino.mapper import RowMapperFactory +try: + if sys.implementation.name == 'pypy': + import json + else: + import orjson as json +except ImportError: + import json + __all__ = [ "ClientSession", "TrinoQuery", From b9ab39a4355c259c054eb617e39415281567235e Mon Sep 17 00:00:00 2001 From: Yukihiro Okada Date: Thu, 29 May 2025 18:50:25 +0900 Subject: [PATCH 3/3] fixup! Exclude pypy --- .github/workflows/ci.yml | 8 ++++++++ setup.py | 2 +- trino/client.py | 6 +----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c36c9a30..8c2141e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,14 @@ jobs: cache: "pip" cache-dependency-path: setup.py - name: Install dependencies + if: matrix.python != 'pypy-3.9' && matrix.python != 'pypy-3.10' + run: | + sudo apt-get update + sudo apt-get install libkrb5-dev + pip install wheel + pip install .[tests,gssapi,orjson] sqlalchemy${{ matrix.sqlalchemy }} + - name: Install dependencies in pypy + if: matrix.python == 'pypy-3.9' || matrix.python == 'pypy-3.10' run: | sudo apt-get update sudo apt-get install libkrb5-dev diff --git a/setup.py b/setup.py index a38715d4..e196e49d 100755 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ # We don't add localstorage_require to all_require as users must explicitly opt in to use keyring. all_require = kerberos_require + sqlalchemy_require -tests_require = all_require + gssapi_require + orjson_require + [ +tests_require = all_require + gssapi_require + [ # httpretty >= 1.1 duplicates requests in `httpretty.latest_requests` # https://github.com/gabrielfalcao/HTTPretty/issues/425 "httpretty < 1.1", diff --git a/trino/client.py b/trino/client.py index b6e453b4..7404bf5e 100644 --- a/trino/client.py +++ b/trino/client.py @@ -42,7 +42,6 @@ import os import random import re -import sys import threading import urllib.parse import warnings @@ -85,10 +84,7 @@ from trino.mapper import RowMapperFactory try: - if sys.implementation.name == 'pypy': - import json - else: - import orjson as json + import orjson as json except ImportError: import json