Skip to content

Commit

Permalink
Rename distutils.sysconfig to sysconfig (#1068)
Browse files Browse the repository at this point in the history
* Rename `distutils.sysconfig` to `sysconfig`

- Required for Python 3.12 as distutils is removed.

* Fallback to `distutils.sysconfig`
  • Loading branch information
MilesCranmer authored Dec 16, 2023
1 parent d407513 commit 790e62f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion deps/buildutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ import Conda, Libdl

pyvar(python::AbstractString, mod::AbstractString, var::AbstractString) = chomp(read(pythonenv(`$python -c "import $mod; print($mod.$(var))"`), String))

pyconfigvar(python::AbstractString, var::AbstractString) = pyvar(python, "distutils.sysconfig", "get_config_var('$(var)')")
function pyconfigvar(python::AbstractString, var::AbstractString)
try
pyvar(python, "sysconfig", "get_config_var('$(var)')")
catch e
emsg = sprint(showerror, e)
@warn "Encountered error on using `sysconfig`: $emsg. Falling back to `distutils.sysconfig`."
pyvar(python, "distutils.sysconfig", "get_config_var('$(var)')")
end
end
pyconfigvar(python, var, default) = let v = pyconfigvar(python, var)
v == "None" ? default : v
end
Expand Down

0 comments on commit 790e62f

Please sign in to comment.