Skip to content

Commit

Permalink
Merge pull request #418 from yuyichao/0.7
Browse files Browse the repository at this point in the history
Fix most of 0.7 depwarns
  • Loading branch information
Keno authored Jul 25, 2017
2 parents 658addd + 6be19bf commit bde073b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 36 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.5
Compat 0.20.0
Compat 0.27.0
Conda 0.2
MacroTools 0.3
17 changes: 7 additions & 10 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pysys(python::AbstractString, var::AbstractString) = pyvar(python, "sys", var)

#########################################################################

const dlprefix = is_windows() ? "" : "lib"
const dlprefix = Compat.Sys.iswindows() ? "" : "lib"

# return libpython name, libpython pointer
function find_libpython(python::AbstractString)
Expand All @@ -62,8 +62,8 @@ function find_libpython(python::AbstractString)

# it is ridiculous that it is this hard to find the path of libpython
libpaths = [pyconfigvar(python, "LIBDIR"),
(is_windows() ? dirname(pysys(python, "executable")) : joinpath(dirname(dirname(pysys(python, "executable"))), "lib"))]
if is_apple()
(Compat.Sys.iswindows() ? dirname(pysys(python, "executable")) : joinpath(dirname(dirname(pysys(python, "executable"))), "lib"))]
if Compat.Sys.isapple()
push!(libpaths, pyconfigvar(python, "PYTHONFRAMEWORKPREFIX"))
end

Expand Down Expand Up @@ -144,7 +144,7 @@ include("depsutils.jl")

const python = try
let py = get(ENV, "PYTHON", isfile("PYTHON") ? readchomp("PYTHON") :
is_linux() || Sys.ARCH (:i686, :x86_64) ? "python" : ""),
Compat.Sys.islinux() || Sys.ARCH (:i686, :x86_64) ? "python" : ""),
vers = isempty(py) ? v"0.0" : convert(VersionNumber, pyconfigvar(py,"VERSION","0.0"))
if vers < v"2.7"
if isempty(py)
Expand Down Expand Up @@ -172,7 +172,7 @@ catch e1
info( "No system-wide Python was found; got the following error:\n",
"$e1\nusing the Python distribution in the Conda package")
end
abspath(Conda.PYTHONDIR, "python" * (is_windows() ? ".exe" : ""))
abspath(Conda.PYTHONDIR, "python" * (Compat.Sys.iswindows() ? ".exe" : ""))
else
error("No system-wide Python was found; got the following error:\n",
"$e1")
Expand All @@ -198,7 +198,7 @@ PYTHONHOME = if !haskey(ENV, "PYTHONHOME") || use_conda
# to always be the same on Windows, where it causes
# problems if we try to include both.
exec_prefix = pysys(python, "exec_prefix")
is_windows() ? exec_prefix : pysys(python, "prefix") * ":" * exec_prefix
Compat.Sys.iswindows() ? exec_prefix : pysys(python, "prefix") * ":" * exec_prefix
else
ENV["PYTHONHOME"]
end
Expand All @@ -215,10 +215,7 @@ end
# A couple of key strings need to be stored as constants so that
# they persist throughout the life of the program. In Python 3,
# they need to be wchar_t* data.
wstringconst(s) =
VERSION < v"0.5.0-dev+4859" ?
string("wstring(\"", escape_string(s), "\")") :
string("Base.cconvert(Cwstring, \"", escape_string(s), "\")")
wstringconst(s) = string("Base.cconvert(Cwstring, \"", escape_string(s), "\")")

# we write configuration files only if they change, both
# to prevent unnecessary recompilation and to minimize
Expand Down
5 changes: 2 additions & 3 deletions src/PyCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ end

#########################################################################

@static if is_windows()
@static if Compat.Sys.iswindows()
# Many python extensions are linked against a very specific version of the
# MSVC runtime library. To load this library, libpython declares an
# appropriate manifest, but unfortunately most extensions do not.
Expand Down Expand Up @@ -831,8 +831,7 @@ for (mime, method) in ((MIME"text/html", "_repr_html_"),
r = pycall(o[$method], PyObject)
r.o != pynothing[] && return write(io, convert($T, r))
end
throw(MethodError($(VERSION < v"0.5.0-dev+4340") ? writemime : show,
(io, mime, o)))
throw(MethodError(show, (io, mime, o)))
end
mimewritable(::$mime, o::PyObject) =
o.o != C_NULL && haskey(o, $method) && let meth = o[$method]
Expand Down
17 changes: 0 additions & 17 deletions src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,23 +548,6 @@ function next{K,V}(d::PyDict{K,V,false}, s)
return (convert(Pair{K,V}, s[1]), (nxt, s[2]))
end

if VERSION < v"0.5.0-dev+9920" # julia PR #14937
# We can't use the Base.filter! implementation because it worked
# by `for (k,v) in d; !f(k,v) && delete!(d,k); end`, but the PyDict_Next
# iterator function in Python is explicitly documented to say that
# you shouldn't modify the dictionary during iteration.
function filter!(f::Function, d::PyDict)
badkeys = Array{keytype(d)}(0)
for (k,v) in d
f(k,v) || push!(badkeys, k)
end
for k in badkeys
delete!(d, k)
end
return d
end
end

#########################################################################
# Dictionary conversions (copies)

Expand Down
2 changes: 1 addition & 1 deletion src/pyinit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function __init__()
end

# Will get reinitialized properly on first use
is_windows() && (PyActCtx[] = C_NULL)
Compat.Sys.iswindows() && (PyActCtx[] = C_NULL)

# Make sure python wasn't upgraded underneath us
new_pyversion = convert(VersionNumber, split(unsafe_string(ccall(@pysym(:Py_GetVersion),
Expand Down
8 changes: 4 additions & 4 deletions src/startup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# and if so do not use the deps.jl file, getting everything we need from the
# current process instead.

proc_handle = unsafe_load(@static is_windows() ? cglobal(:jl_exe_handle, Ptr{Void}) : cglobal(:jl_dl_handle, Ptr{Void}))
proc_handle = unsafe_load(@static Compat.Sys.iswindows() ? cglobal(:jl_exe_handle, Ptr{Void}) : cglobal(:jl_dl_handle, Ptr{Void}))

immutable Dl_info
dli_fname::Ptr{UInt8}
Expand All @@ -17,7 +17,7 @@ EnumProcessModules(hProcess, lphModule, cb, lpcbNeeded) =
hProcess, lphModule, cb, lpcbNeeded)

symbols_present = false
@static if is_windows()
@static if Compat.Sys.iswindows()
lpcbneeded = Ref{UInt32}()
proc_handle = ccall(:GetCurrentProcess, stdcall, Ptr{Void}, ())
handles = Vector{Ptr{Void}}(20)
Expand Down Expand Up @@ -49,7 +49,7 @@ if !symbols_present
# need SetPythonHome to avoid warning, #299
Py_SetPythonHome(libpy_handle, PYTHONHOME, wPYTHONHOME, pyversion_build)
else
@static if is_windows()
@static if Compat.Sys.iswindows()
pathbuf = Vector{UInt16}(1024)
ret = ccall(:GetModuleFileNameW, stdcall, UInt32,
(Ptr{Void}, Ptr{UInt16}, UInt32),
Expand Down Expand Up @@ -109,7 +109,7 @@ else
end

# hashes changed from long to intptr_t in Python 3.2
const Py_hash_t = pyversion < v"3.2" ? Clong:Int
const Py_hash_t = pyversion < v"3.2" ? Clong : Int

# whether to use unicode for strings by default, ala Python 3
const pyunicode_literals = pyversion >= v"3.0"
Expand Down

0 comments on commit bde073b

Please sign in to comment.