Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* Renamed `pydel!` to `unsafe_pydel` and exported.
A `Py` is now always a valid, fixed, non-NULL Python object in the documented API.
* Python errors no longer automatically set `sys.last_traceback` etc. when displayed from Julia.
* Removed `CONFIG.auto_sys_last_traceback`.
* Added [`fix_qt_plugin_path` preference](@ref pythoncall-config), replacing `CONFIG.auto_fix_qt_plugin_path`.
* Removed `PythonCall.CONFIG`.
* Changes to `PythonCall.GC` (now more like `Base.GC`):
* `enable(true)` replaces `enable()`.
* `enable(false)` replaces `disable()`.
Expand Down
1 change: 1 addition & 0 deletions docs/src/pythoncall.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ variables.
| `exe` | `JULIA_PYTHONCALL_EXE` | Path to the Python executable, or special values (see below). |
| `lib` | `JULIA_PYTHONCALL_LIB` | Path to the Python library (usually inferred automatically). |
| `pickle` | `JULIA_PYTHONCALL_PICKLE` | Pickle module to use for serialization (`pickle` or `dill`). |
| `fix_qt_plugin_path=<true\|false>` | `JULIA_PYTHONCALL_FIX_QT_PLUGIN_PATH=<false\|true\|0\|1\|no\|yes>` | When true (the default), automatically [fix the Qt plugin path](@ref `PythonCall.fix_qt_plugin_path`) when activating a Qt-based event loop. |

The easiest way to set these preferences is with the
[`PreferenceTools`](https://github.com/cjdoris/PreferenceTools.jl)
Expand Down
7 changes: 7 additions & 0 deletions docs/src/v1-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ work.

* Instead of `pdb.pm()` use `pdb.post_mortem(err[1].exception)`.

The `PythonCall.CONFIG.auto_fix_qt_plugin_path` config has been replaced with the
[`fix_qt_plugin_path` preference](@ref pythoncall-config).

* Instead of `PythonCall.CONFIG.auto_fix_qt_plugin_path = false`, set preference
`pkg> preference add PythonCall fix_qt_plugin_path=false` or the env var
`JULIA_PYTHONCALL_FIX_QT_PLUGIN_PATH=0`.

## `PythonCall.GC`

This submodule has been changed to closer mimic the `Base.GC` API.
Expand Down
3 changes: 0 additions & 3 deletions src/API/publics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ if Base.VERSION ≥ v"1.11"
python_library_handle,
python_library_path,
python_version,

# Core
CONFIG,

# Compat
event_loop_off,
Expand Down
41 changes: 9 additions & 32 deletions src/Compat/gui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This fixes the problem that Qt does not know where to find its `qt.conf` file, b
always looks relative to `sys.executable`, which can be the Julia executable not the Python
one when using this package.

If `CONFIG.auto_fix_qt_plugin_path` is true, then this is run automatically before `PyQt4`, `PyQt5`, `PySide`, `PySide2` or `PySide6` are imported.
If the `fix_qt_plugin_path` preference is true, then this is run automatically before `PyQt4`, `PyQt5`, `PySide`, `PySide2` or `PySide6` are imported.
"""
function fix_qt_plugin_path()
C.CTX.exe_path === nothing && return false
Expand Down Expand Up @@ -53,30 +53,6 @@ function fix_qt_plugin_path()
return false
end

# """
# pyinteract(; force=false, sleep=0.1)

# Some Python GUIs can work interactively, meaning the GUI is available but the interactive prompt is returned (e.g. after calling `matplotlib.pyplot.ion()`).
# To use these from Julia, currently you must manually call `pyinteract()` each time you want to interact.

# Internally, this is calling the `PyOS_InputHook` asynchronously. Only one copy is run at a time unless `force` is true.

# The asynchronous task waits for `sleep` seconds before calling the hook function.
# This gives time for the next prompt to be printed and waiting for input.
# As a result, there will be a small delay before the GUI becomes interactive.
# """
# pyinteract(; force::Bool = false, sleep::Real = 0.1) =
# if !CONFIG.inputhookrunning || force
# CONFIG.inputhookrunning = true
# @async begin
# sleep > 0 && Base.sleep(sleep)
# C.PyOS_RunInputHook()
# CONFIG.inputhookrunning = false
# end
# nothing
# end
# export pyinteract

const EVENT_LOOPS = Dict{Symbol,Base.Timer}()

const new_event_loop_callback = pynew()
Expand Down Expand Up @@ -158,13 +134,14 @@ function init_gui()
pycopy!(new_event_loop_callback, g["new_event_loop_callback"])

# add a hook to automatically call fix_qt_plugin_path()
fixqthook =
Py(() -> (PythonCall.CONFIG.auto_fix_qt_plugin_path && fix_qt_plugin_path(); nothing))
pymodulehooks.add_hook("PyQt4", fixqthook)
pymodulehooks.add_hook("PyQt5", fixqthook)
pymodulehooks.add_hook("PySide", fixqthook)
pymodulehooks.add_hook("PySide2", fixqthook)
pymodulehooks.add_hook("PySide6", fixqthook)
if Utils.getpref_fix_qt_plugin_path()
fixqthook = Py(fix_qt_plugin_path)
pymodulehooks.add_hook("PyQt4", fixqthook)
pymodulehooks.add_hook("PyQt5", fixqthook)
pymodulehooks.add_hook("PySide", fixqthook)
pymodulehooks.add_hook("PySide2", fixqthook)
pymodulehooks.add_hook("PySide6", fixqthook)
end
end
end

Expand Down
1 change: 0 additions & 1 deletion src/Core/Core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ export

include("Py.jl")
include("err.jl")
include("config.jl")
include("consts.jl")
include("builtins.jl")
include("stdlib.jl")
Expand Down
6 changes: 0 additions & 6 deletions src/Core/config.jl

This file was deleted.

3 changes: 0 additions & 3 deletions src/PythonCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ include("Wrap/Wrap.jl")
include("JlWrap/JlWrap.jl")
include("Compat/Compat.jl")

# non-exported API
using .Core: CONFIG

# not API but used in tests
for k in [
:pyjlanytype,
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/Utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ end

checkpref(::Type{String}, x) = error("invalid preference of type $(type(x)), expecting a string")
checkpref(::Type{String}, x::AbstractString) = convert(String, x)
checkpref(::Type{Bool}, x::Bool) = x
checkpref(::Type{Bool}, x::AbstractString) = x in ("1", "yes", "true") ? true : x in ("0", "no", "false") ? false : error("expecting '0', 'no', 'false', '1', 'yes' or 'true'")

# Specific preference functions
getpref_exe() = getpref(String, "exe", "JULIA_PYTHONCALL_EXE", "")
getpref_lib() = getpref(String, "lib", "JULIA_PYTHONCALL_LIB", nothing)
getpref_pickle() = getpref(String, "pickle", "JULIA_PYTHONCALL_PICKLE", "pickle")
getpref_fix_qt_plugin_path() = getpref(Bool, "fix_qt_plugin_path", "JULIA_PYTHONCALL_FIX_QT_PLUGIN_PATH", true)

function explode_union(T)
@nospecialize T
Expand Down
Loading