JuliaPy / JuliaPy/PythonCall.jl

Support Python 3.13 (and t version of it)

Offen
#568 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Julia
Sterne
1.1k
Forks
86
Ø Merge
1 T. 22 Std.
Gemergte PRs (30 T.)
3

Beschreibung

**Affects:**
PythonCall (probably both)

**Describe the bug**
I didn't ask for the free-threaded version (wouldn't know how), it's off by default at least in official Python (though maybe not in conda?). Julia should work with default, default of conda version if different, and the free-threaded (ideally):

https://docs.python.org/3.13/whatsnew/3.13.html#whatsnew313-free-threaded-cpython
I do have both installed(???) seemingly but most likely t version is not run, and the default name python3.13" runs without showing “experimental free-threading build”, I think I've confined I do not run it, i.e. with default python3.13 executable:

/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3-config
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3.1 [strange synonym for 3.13 if run..]
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3.13
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3.13-config
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3.13t
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3.13t-config

[Actually that's an output from `locate`, and I'm not sure I actually even have "python3.13t" there since I can't run it or list it, but had it at some point?]

https://docs.python.org/3/howto/free-threading-python.html#identifying-free-threaded-python
"to check if the current interpreter supports free-threading, .. “experimental free-threading build”. The new sys._is_gil_enabled()"

```
/home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python3.13
Python 3.13.0 | packaged by conda-forge | (main, Oct 8 2024, 20:04:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys
>>> sys._is_gil_enabled()
True
```

I managed to config (disable "build" in /home/pharaldsson/CondaPkg.toml if I recall the only major change, at least the last one that allowed me to install):

```
[deps.python]
channel = "conda-forge"
# build = "*cpython*"
```

and I get an error:

```
o libstdcxx-ng 14.2.0 h4852527_1 conda-forge Cached
o python 3.13.0 h6355ac2_0_cp313t conda-forge Cached

Ptr{PythonCall.C.PyObject} @0x00007f6eef72e880
SystemError: Type does not define the tp_name field.
ERROR: InitError: Error initializing 'juliacall.ValueBase'
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] init_c()
@ PythonCall.JlWrap.Cjl ~/.julia/dev/PythonCall/src/JlWrap/C.jl:333
[3] __init__()
@ PythonCall.JlWrap.Cjl ~/.julia/dev/PythonCall/src/JlWrap/C.jl:338
[4] run_module_init(mod::Module, i::Int64)
@ Base ./loading.jl:1336
[5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
@ Base ./loading.jl:1324
[6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
@ Base ./loading.jl:1213
[7] _include_from_serialized (repeats 2 times)
@ ./loading.jl:1169 [inlined]
[8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{String, Int64}, DEPOT_PATH::Vector{String})
@ Base ./loading.jl:1985
[9] _require(pkg::Base.PkgId, env::String)
@ Base ./loading.jl:2450
[10] __require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:2315
[11] #invoke_in_world#3
@ ./essentials.jl:1089 [inlined]
[12] invoke_in_world
@ ./essentials.jl:1086 [inlined]
[13] _require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:2302
[14] macro expansion
@ ./loading.jl:2241 [inlined]
[15] macro expansion
@ ./lock.jl:273 [inlined]
[16] __require(into::Module, mod::Symbol)
@ Base ./loading.jl:2198
[17] #invoke_in_world#3
@ ./essentials.jl:1089 [inlined]
[18] invoke_in_world
@ ./essentials.jl:1086 [inlined]
[19] require(into::Module, mod::Symbol)
@ Base ./loading.jl:2191
[20] macro expansion
@ ./timing.jl:581 [inlined]
[21] top-level scope
@ ./REPL[1]:1
during initialization of module Cjl

The pointer seems valid, note, I added a line to dump it before the erroring line, so you see line with off-by-one number.

I think 3.13 may have introduced a breaking change, I see others had trouble (but overcome), showing same tp_name error message:

https://github.com/python/cpython/issues/124768#issuecomment-2381596730

https://github.com/dpdani/cereggii/actions/runs/11444942806/job/31840954441

https://github.com/dpdani/cereggii/pull/27/files

https://github.com/python/cpython/issues/124768#issuecomment-2427273190

Please include the steps required to reproduce the bug. This should include not just code but **all** the steps required to reproduce the bug

I can try to add missing steps, though the config is I think for you trivial.

**Your system**
Please provide detailed information about your system:

Linux Mint (Ubuntu basically)

Julia 1.11.1 (also problem for 1.10).

Latest PythonCall v0.9.23 (deved here but also failed on unchanged)

- The operating system
- The version of Julia, Python, PythonCall, JuliaCall and any other affected packages
- If an issue with PythonCall, the output of `Base.versioninfo()`, `Pkg.status()` and `CondaPkg.status()`.
- If an issue with JuliaCall, the output of `pip list` or `conda list` and `juliapkg.status()`.

julia> Pkg.status()
Status `~/Project.toml`
⌃ [09cdc199] BasicAutoloads v1.0.1
[992eb4ea] CondaPkg v0.2.23
[1f15a43c] CxxWrap v0.16.0
[a10d1c49] DBInterface v2.6.1
[a93c6f00] DataFrames v1.7.0
[be6f12e9] ODBC v1.1.2
[5736bd91] ObjectOriented v0.1.4
⌃ [7240a794] Oracle v0.3.2
[6099a3de] PythonCall v0.9.23 `~/.julia/dev/PythonCall`
[6f49c342] RCall v0.14.6
[2b41e42f] StippleMarkdown v0.2.0
⌃ [f0413319] Tidier v1.3.0
⌃ [86993f9b] TidierDB v0.4.1
[3eaa8342] libcxxwrap_julia_jll v0.13.2+0

julia> CondaPkg.status()
CondaPkg Status /home/pharaldsson/CondaPkg.toml
Environment
/home/pharaldsson/.CondaPkg/env
Packages
libstdcxx-ng v14.2.0 (channel=conda-forge)
python v3.13.0 (>=3.7,<4, channel=conda-forge)

julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 16 × Intel(R) Xeon(R) CPU D-1541 @ 2.10GHz
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, broadwell)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
Environment:
JULIA_MAX_NUM_PRECOMPILE_FILES = 2
JULIA_NUM_PRECOMPILE_TASKS = 3
JULIA_PKG_PRESERVE_TIERED_INSTALLED = true

**Additional context**
Add any other context about the problem here.

Also to consider supporting/testing:
https://discuss.python.org/t/python-3-14-0-alpha-1/68039

maybe the problem goes away there? I can hope... in case Python screwed up and reverted. Julia just did so in 1.11 making juliacall, i.e. that other R package no longer work... And could fix in patch or next version.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

The reported failure occurs during JlWrap.Cjl.init_c in src/JlWrap/C.jl around lines 333-338; first reproduce it with the CondaPkg.toml Python 3.13 configuration and inspect that initialization path. Done means Python 3.13's default and free-threaded builds initialize PythonCall without the tp_name SystemError.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
julia, python
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.