Fix issue with pyo3 (PyO3)

This commit is contained in:
Michael Mintz 2023-08-14 20:20:12 -04:00
parent 0c12eb5d01
commit 4a704b2847
3 changed files with 30 additions and 1 deletions

View File

@ -19,6 +19,18 @@ class DatabaseManager:
constants.PipInstall.FINDLOCK
)
with pip_find_lock:
if sys.version_info >= (3, 7) and sys.version_info < (3, 9):
# Fix bug in newer cryptography for Python 3.7 and 3.8:
# "pyo3_runtime.PanicException: Python API call failed"
# (Match the version needed for pdfminer.six functions)
try:
import cryptography
if cryptography.__version__ != "39.0.2":
shared_utils.pip_install(
"cryptography", version="39.0.2"
)
except Exception:
shared_utils.pip_install("cryptography", version="39.0.2")
try:
import cryptography # noqa: F401
import pymysql

View File

@ -6380,6 +6380,22 @@ class BaseCase(unittest.TestCase):
constants.PipInstall.FINDLOCK
)
with pip_find_lock:
if (
sys.version_info >= (3, 7)
and sys.version_info < (3, 9)
):
# Fix bug in newer cryptography for Python 3.7 and 3.8:
# "pyo3_runtime.PanicException: Python API call failed"
try:
import cryptography
if cryptography.__version__ != "39.0.2":
shared_utils.pip_install(
"cryptography", version="39.0.2"
)
except Exception:
shared_utils.pip_install(
"cryptography", version="39.0.2"
)
try:
from pdfminer.high_level import extract_text
except Exception:

View File

@ -264,7 +264,8 @@ setup(
'pdfminer.six==20211012;python_version<"3.7"',
'pdfminer.six==20221105;python_version>="3.7"',
'cryptography==36.0.2;python_version<"3.7"',
'cryptography==41.0.3;python_version>="3.7"',
'cryptography==39.0.2;python_version>="3.7" and python_version<"3.9"', # noqa: E501
'cryptography==41.0.3;python_version>="3.9"',
"cffi==1.15.1",
"pycparser==2.21",