Skip to content

Commit 30ce0bb

Browse files
committed
Updated Windows support
1 parent 95d7c86 commit 30ce0bb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

PythonKit/Python.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ extension PythonObject : CustomStringConvertible {
124124
}
125125
}
126126

127+
#if !swift(>=5)
127128
// Make `PythonObject` show up nicely in the Xcode Playground results sidebar.
128129
extension PythonObject : CustomPlaygroundQuickLookable {
129130
public var customPlaygroundQuickLook: PlaygroundQuickLook {
130131
return .text(description)
131132
}
132133
}
134+
#endif
133135

134136
// Mirror representation, used by debugger/REPL.
135137
extension PythonObject : CustomReflectable {

PythonKit/PythonLibrary.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public struct PythonLibrary {
5959
#if canImport(Darwin) || canImport(Glibc)
6060
return dlsym(libraryHandle, name)
6161
#elseif os(Windows)
62-
return GetProcAddress(libraryHandle, name)
62+
let moduleHandle = libraryHandle
63+
.assumingMemoryBound(to: HINSTANCE__.self)
64+
let moduleSymbol = GetProcAddress(moduleHandle, name)
65+
return unsafeBitCast(moduleSymbol, to: UnsafeMutableRawPointer?.self)
6366
#endif
6467
}
6568

@@ -225,7 +228,7 @@ private extension PythonLibrary {
225228
// modules may depend on this .so file.
226229
let pythonLibraryHandle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL)
227230
#elseif os(Windows)
228-
let pythonLibraryHandle = LoadLibraryA(path)
231+
let pythonLibraryHandle = UnsafeMutableRawPointer(LoadLibraryA(path))
229232
#endif
230233

231234
if pythonLibraryHandle != nil {

0 commit comments

Comments
 (0)