PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Other
11.42k stars 690 forks source link

Add support for Python interpreter version 3.13 - PyCharm #4248

Open testerops01 opened 2 weeks ago

testerops01 commented 2 weeks ago

Bug Description

While installing langchain using Pycharm Community edition, I encountered error which says that PyO3's maximum supported version is 3.12.

With release of version 3.13 of Python interpreter, please add support for this version too.

Steps to Reproduce

  1. Update/Install Python to version 3.13

  2. Create a new project in PyCharm community addition

    PyCharm 2023.3.6 (Community Edition)
    Build #PC-233.15325.20, built on June 5, 2024
  3. Add langchain in requirements.txt.

  4. Try to install the requirements from the prompt coming in Pycharm.

Backtrace

Collecting langchain
  Using cached langchain-0.2.4-py3-none-any.whl.metadata (7.0 kB)
Collecting PyYAML>=5.3 (from langchain)
  Using cached PyYAML-6.0.1.tar.gz (125 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting SQLAlchemy<3,>=1.4 (from langchain)
  Using cached SQLAlchemy-2.0.30-py3-none-any.whl.metadata (9.6 kB)
Collecting aiohttp<4.0.0,>=3.8.3 (from langchain)
  Using cached aiohttp-3.9.5.tar.gz (7.5 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting langchain-core<0.3.0,>=0.2.6 (from langchain)
  Using cached langchain_core-0.2.6-py3-none-any.whl.metadata (5.8 kB)
Collecting langchain-text-splitters<0.3.0,>=0.2.0 (from langchain)
  Using cached langchain_text_splitters-0.2.1-py3-none-any.whl.metadata (2.2 kB)
Collecting langsmith<0.2.0,>=0.1.17 (from langchain)
  Using cached langsmith-0.1.77-py3-none-any.whl.metadata (13 kB)
Collecting numpy<2.0.0,>=1.26.0 (from langchain)
  Using cached numpy-1.26.4-cp313-cp313-macosx_14_0_arm64.whl
Collecting pydantic<3,>=1 (from langchain)
  Using cached pydantic-2.7.4-py3-none-any.whl.metadata (109 kB)
Collecting requests<3,>=2 (from langchain)
  Using cached requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting tenacity<9.0.0,>=8.1.0 (from langchain)
  Using cached tenacity-8.3.0-py3-none-any.whl.metadata (1.2 kB)
Collecting aiosignal>=1.1.2 (from aiohttp<4.0.0,>=3.8.3->langchain)
  Using cached aiosignal-1.3.1-py3-none-any.whl.metadata (4.0 kB)
Collecting attrs>=17.3.0 (from aiohttp<4.0.0,>=3.8.3->langchain)
  Using cached attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)
Collecting frozenlist>=1.1.1 (from aiohttp<4.0.0,>=3.8.3->langchain)
  Using cached frozenlist-1.4.1-py3-none-any.whl.metadata (12 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp<4.0.0,>=3.8.3->langchain)
  Using cached multidict-6.0.5-py3-none-any.whl.metadata (4.2 kB)
Collecting yarl<2.0,>=1.0 (from aiohttp<4.0.0,>=3.8.3->langchain)
  Using cached yarl-1.9.4-py3-none-any.whl.metadata (31 kB)
Collecting jsonpatch<2.0,>=1.33 (from langchain-core<0.3.0,>=0.2.6->langchain)
  Using cached jsonpatch-1.33-py2.py3-none-any.whl.metadata (3.0 kB)
Collecting packaging<25,>=23.2 (from langchain-core<0.3.0,>=0.2.6->langchain)
  Using cached packaging-24.1-py3-none-any.whl.metadata (3.2 kB)
Collecting orjson<4.0.0,>=3.9.14 (from langsmith<0.2.0,>=0.1.17->langchain)
  Using cached orjson-3.10.5.tar.gz (5.2 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting annotated-types>=0.4.0 (from pydantic<3,>=1->langchain)
  Downloading annotated_types-0.7.0-py3-none-any.whl.metadata (15 kB)
Collecting pydantic-core==2.18.4 (from pydantic<3,>=1->langchain)
  Downloading pydantic_core-2.18.4.tar.gz (385 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 385.1/385.1 kB 13.6 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting typing-extensions>=4.6.1 (from pydantic<3,>=1->langchain)
  Using cached typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
Collecting charset-normalizer<4,>=2 (from requests<3,>=2->langchain)
  Downloading charset_normalizer-3.3.2-py3-none-any.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests<3,>=2->langchain)
  Downloading idna-3.7-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests<3,>=2->langchain)
  Downloading urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests<3,>=2->langchain)
  Downloading certifi-2024.6.2-py3-none-any.whl.metadata (2.2 kB)
Collecting jsonpointer>=1.9 (from jsonpatch<2.0,>=1.33->langchain-core<0.3.0,>=0.2.6->langchain)
  Downloading jsonpointer-3.0.0-py2.py3-none-any.whl.metadata (2.3 kB)
Downloading langchain-0.2.4-py3-none-any.whl (974 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 974.2/974.2 kB 39.9 MB/s eta 0:00:00
Downloading langchain_core-0.2.6-py3-none-any.whl (315 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 315.5/315.5 kB 29.0 MB/s eta 0:00:00
Downloading langchain_text_splitters-0.2.1-py3-none-any.whl (23 kB)
Downloading langsmith-0.1.77-py3-none-any.whl (125 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.2/125.2 kB 18.3 MB/s eta 0:00:00
Downloading pydantic-2.7.4-py3-none-any.whl (409 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 409.0/409.0 kB 34.1 MB/s eta 0:00:00
Downloading requests-2.32.3-py3-none-any.whl (64 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.9/64.9 kB 13.3 MB/s eta 0:00:00
Downloading SQLAlchemy-2.0.30-py3-none-any.whl (1.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 46.1 MB/s eta 0:00:00
Using cached tenacity-8.3.0-py3-none-any.whl (25 kB)
Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Downloading annotated_types-0.7.0-py3-none-any.whl (13 kB)
Downloading attrs-23.2.0-py3-none-any.whl (60 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.8/60.8 kB 8.6 MB/s eta 0:00:00
Downloading certifi-2024.6.2-py3-none-any.whl (164 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 164.4/164.4 kB 22.5 MB/s eta 0:00:00
Downloading charset_normalizer-3.3.2-py3-none-any.whl (48 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.5/48.5 kB 6.0 MB/s eta 0:00:00
Downloading frozenlist-1.4.1-py3-none-any.whl (11 kB)
Downloading idna-3.7-py3-none-any.whl (66 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.8/66.8 kB 9.4 MB/s eta 0:00:00
Using cached jsonpatch-1.33-py2.py3-none-any.whl (12 kB)
Downloading multidict-6.0.5-py3-none-any.whl (9.7 kB)
Using cached packaging-24.1-py3-none-any.whl (53 kB)
Using cached typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Downloading urllib3-2.2.1-py3-none-any.whl (121 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 121.1/121.1 kB 13.8 MB/s eta 0:00:00
Downloading yarl-1.9.4-py3-none-any.whl (31 kB)
Downloading jsonpointer-3.0.0-py2.py3-none-any.whl (7.6 kB)
Building wheels for collected packages: aiohttp, pydantic-core, PyYAML, orjson
  Building wheel for aiohttp (pyproject.toml): started
  Building wheel for aiohttp (pyproject.toml): finished with status 'done'
  Created wheel for aiohttp: filename=aiohttp-3.9.5-cp313-cp313-macosx_10_9_universal2.whl size=569356 sha256=d299935b8e772d5adc71f84e7accb85860451f18c84f3e79330991be177e52cc
  Stored in directory: /Users/shrijanki/Library/Caches/pip/wheels/db/56/97/21e908bcd785edbe5da61989a649959a1c68b9217dcb8740a9
  Building wheel for pydantic-core (pyproject.toml): started
  Building wheel for pydantic-core (pyproject.toml): finished with status 'error'
  Building wheel for PyYAML (pyproject.toml): started
  Building wheel for PyYAML (pyproject.toml): finished with status 'done'
  Created wheel for PyYAML: filename=PyYAML-6.0.1-cp313-cp313-macosx_10_9_universal2.whl size=45370 sha256=39a12b0e022807435805899c7d60a83d3ecb82226b0acf406df41424c5bdddee
  Stored in directory: /Users/shrijanki/Library/Caches/pip/wheels/9c/9e/34/1e1548811b63a9d001469f21797e8b7d5c216d8eb928e7d6ad
  Building wheel for orjson (pyproject.toml): started
  Building wheel for orjson (pyproject.toml): finished with status 'error'
Successfully built aiohttp PyYAML
Failed to build pydantic-core orjson

  error: subprocess-exited-with-error

  × Building wheel for pydantic-core (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [99 lines of output]
      Running `maturin pep517 build-wheel -i /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13 --compatibility off`
      📦 Including license file "/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/pydantic-core_ebe711e249aa4faab520c9b4981d32f0/LICENSE"
      🍹 Building a mixed python/rust project
      🔗 Found pyo3 bindings
      🐍 Found CPython 3.13 at /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13
      📡 Using build options features, bindings from pyproject.toml
      💻 Using `MACOSX_DEPLOYMENT_TARGET=11.0` for aarch64-apple-darwin by default
         Compiling target-lexicon v0.12.9
         Compiling autocfg v1.1.0
         Compiling proc-macro2 v1.0.76
         Compiling python3-dll-a v0.2.9
         Compiling once_cell v1.18.0
         Compiling unicode-ident v1.0.10
         Compiling libc v0.2.147
         Compiling heck v0.4.1
         Compiling cfg-if v1.0.0
         Compiling rustversion v1.0.13
         Compiling version_check v0.9.4
         Compiling parking_lot_core v0.9.8
         Compiling portable-atomic v1.6.0
         Compiling scopeguard v1.1.0
         Compiling static_assertions v1.1.0
         Compiling smallvec v1.13.2
         Compiling radium v0.7.0
         Compiling tinyvec_macros v0.1.1
         Compiling ahash v0.8.10
         Compiling tinyvec v1.6.0
         Compiling num-traits v0.2.16
         Compiling lock_api v0.4.10
         Compiling num-integer v0.1.45
         Compiling memoffset v0.9.0
         Compiling num-bigint v0.4.4
         Compiling lexical-util v0.8.5
         Compiling serde v1.0.203
         Compiling memchr v2.6.3
         Compiling tap v1.0.1
         Compiling wyz v0.5.1
         Compiling aho-corasick v1.0.2
         Compiling quote v1.0.35
         Compiling syn v2.0.48
         Compiling parking_lot v0.12.1
         Compiling lexical-parse-integer v0.8.6
         Compiling getrandom v0.2.10
         Compiling unicode-normalization v0.1.22
         Compiling serde_json v1.0.116
         Compiling unindent v0.2.3
         Compiling hashbrown v0.14.3
         Compiling equivalent v1.0.1
         Compiling unicode-bidi v0.3.13
         Compiling pyo3-build-config v0.21.2
         Compiling indoc v2.0.4
         Compiling percent-encoding v2.3.1
         Compiling funty v2.0.0
         Compiling regex-syntax v0.8.2
         Compiling zerocopy v0.7.32
         Compiling form_urlencoded v1.2.1
         Compiling indexmap v2.2.2
         Compiling idna v0.5.0
         Compiling lexical-parse-float v0.8.5
         Compiling itoa v1.0.8
         Compiling ryu v1.0.14
         Compiling url v2.5.0
         Compiling base64 v0.21.7
         Compiling serde_derive v1.0.203
         Compiling strum_macros v0.25.3
         Compiling regex-automata v0.4.5
         Compiling bitvec v1.0.1
         Compiling strum_macros v0.26.1
         Compiling enum_dispatch v0.3.13
         Compiling uuid v1.8.0
         Compiling regex v1.10.4
         Compiling pyo3-macros-backend v0.21.2
         Compiling pyo3-ffi v0.21.2
         Compiling pyo3 v0.21.2
         Compiling jiter v0.4.1
         Compiling pydantic-core v2.18.4 (/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/pydantic-core_ebe711e249aa4faab520c9b4981d32f0)
         Compiling strum v0.25.0
         Compiling pyo3-macros v0.21.2
      error: failed to run custom build command for `pyo3-ffi v0.21.2`

      Caused by:
        process didn't exit successfully: `/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/pydantic-core_ebe711e249aa4faab520c9b4981d32f0/target/release/build/pyo3-ffi-ee52a8caa6c649cb/build-script-build` (exit status: 1)
        --- stdout
        cargo:rerun-if-env-changed=PYO3_CROSS
        cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR
        cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_VERSION
        cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_IMPLEMENTATION
        cargo:rerun-if-env-changed=PYO3_PRINT_CONFIG
        cargo:rerun-if-env-changed=PYO3_USE_ABI3_FORWARD_COMPATIBILITY

        --- stderr
        error: the configured Python interpreter version (3.13) is newer than PyO3's maximum supported version (3.12)
        = help: please check if an updated version of PyO3 is available. Current version: 0.21.2
        = help: set PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 to suppress this check and build anyway using the stable ABI
      warning: build failed, waiting for other jobs to finish...
      💥 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit status: 101": `env -u CARGO MACOSX_DEPLOYMENT_TARGET="11.0" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.13-64bit" PYO3_PYTHON="/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13" PYTHON_SYS_EXECUTABLE="/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13" "cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/pydantic-core_ebe711e249aa4faab520c9b4981d32f0/Cargo.toml" "--release" "--lib" "--crate-type" "cdylib" "--" "-C" "link-arg=-undefined" "-C" "link-arg=dynamic_lookup" "-C" "link-args=-Wl,-install_name,@rpath/pydantic_core._pydantic_core.cpython-313-darwin.so"`
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13', '--compatibility', 'off'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pydantic-core
  error: subprocess-exited-with-error

  × Building wheel for orjson (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [63 lines of output]
      Running `maturin pep517 build-wheel -i /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13 --compatibility off`
      📦 Including license file "/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/orjson_b2e3f2ee5b2741a0b3c65c1df1c4ccaa/LICENSE-APACHE"
      📦 Including license file "/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/orjson_b2e3f2ee5b2741a0b3c65c1df1c4ccaa/LICENSE-MIT"
      🍹 Building a mixed python/rust project
      🔗 Found pyo3-ffi bindings
      🐍 Found CPython 3.13 at /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13
      💻 Using `MACOSX_DEPLOYMENT_TARGET=11.0` for aarch64-apple-darwin by default
         Compiling target-lexicon v0.12.14
         Compiling once_cell v1.19.0
         Compiling crunchy v0.2.2
         Compiling serde v1.0.203
         Compiling libc v0.2.155
         Compiling tiny-keccak v2.0.2
         Compiling version_check v0.9.4
         Compiling rustversion v1.0.17
         Compiling cfg-if v1.0.0
         Compiling autocfg v1.3.0
         Compiling cc v1.0.99
         Compiling serde_json v1.0.117
         Compiling ahash v0.8.11
         Compiling num-traits v0.2.19
         Compiling ryu v1.0.18
         Compiling itoa v1.0.11
         Compiling zerocopy v0.7.34
         Compiling static_assertions v1.1.0
         Compiling half v2.4.1
         Compiling encoding_rs v0.8.34
         Compiling bytecount v0.6.8
         Compiling simdutf8 v0.1.4
         Compiling associative-cache v2.0.0
         Compiling itoap v1.0.1
         Compiling smallvec v1.13.2
         Compiling castaway v0.2.2
         Compiling getrandom v0.2.15
         Compiling const-random-macro v0.1.16
         Compiling const-random v0.1.18
         Compiling beef v0.5.2
         Compiling arrayvec v0.7.4
         Compiling pyo3-build-config v0.21.2
         Compiling chrono v0.4.34
         Compiling compact_str v0.7.1
         Compiling pyo3-ffi v0.21.2
         Compiling orjson v3.10.5 (/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/orjson_b2e3f2ee5b2741a0b3c65c1df1c4ccaa)
      error: failed to run custom build command for `pyo3-ffi v0.21.2`

      Caused by:
        process didn't exit successfully: `/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/orjson_b2e3f2ee5b2741a0b3c65c1df1c4ccaa/target/release/build/pyo3-ffi-8f8e53112ffdff2e/build-script-build` (exit status: 1)
        --- stdout
        cargo:rerun-if-env-changed=PYO3_CROSS
        cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR
        cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_VERSION
        cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_IMPLEMENTATION
        cargo:rerun-if-env-changed=PYO3_PRINT_CONFIG
        cargo:rerun-if-env-changed=PYO3_USE_ABI3_FORWARD_COMPATIBILITY

        --- stderr
        error: the configured Python interpreter version (3.13) is newer than PyO3's maximum supported version (3.12)
        = help: please check if an updated version of PyO3 is available. Current version: 0.21.2
        = help: set PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 to suppress this check and build anyway using the stable ABI
      💥 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit status: 101": `env -u CARGO MACOSX_DEPLOYMENT_TARGET="11.0" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.13-64bit" PYO3_PYTHON="/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13" PYTHON_SYS_EXECUTABLE="/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/private/var/folders/_k/2ttscjxs1gzc516mqvppfsp40000gn/T/pip-install-vx69984d/orjson_b2e3f2ee5b2741a0b3c65c1df1c4ccaa/Cargo.toml" "--release" "--lib" "--" "-C" "link-arg=-undefined" "-C" "link-arg=dynamic_lookup" "-C" "link-args=-Wl,-install_name,@rpath/orjson.cpython-313-darwin.so"`
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13', '--compatibility', 'off'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for orjson
ERROR: Could not build wheels for pydantic-core, orjson, which is required to install pyproject.toml-based projects

Your operating system and version

MacOS Sonoma 14.3.1

Your Python version (python --version)

3.13

Your Rust version (rustc --version)

1.78.0

Your PyO3 version

0.21.2

How did you install python? Did you use a virtualenv?

Yes

Additional Info

No response

davidhewitt commented 2 weeks ago

PyO3 0.22 is releasing soon and we'll be shipping 3.13 support in it.