diff --git a/Package.swift b/Package.swift index c1ea0aa..fd0151d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.1 +// swift-tools-version: 6.2 import PackageDescription @@ -13,11 +13,15 @@ let package = Package( targets: [ .target( name: "PythonKit", - path: "PythonKit" + path: "PythonKit", + swiftSettings: [ + .defaultIsolation(MainActor.self) + ] ), .testTarget( name: "PythonKitTests", dependencies: ["PythonKit"] ), - ] + ], + swiftLanguageModes: [.v5] ) diff --git a/PythonKit/Python.swift b/PythonKit/Python.swift index 35d2fcb..87cf6cf 100644 --- a/PythonKit/Python.swift +++ b/PythonKit/Python.swift @@ -37,7 +37,7 @@ typealias OwnedPyObjectPointer = PyObjectPointer // `PythonObject` will define copy constructors, move constructors, etc. to // implement move semantics. @usableFromInline @_fixed_layout -final class PyReference { +nonisolated final class PyReference { private var pointer: OwnedPyObjectPointer // This `PyReference`, once deleted, will make no delta change to the @@ -207,6 +207,7 @@ public extension PythonObject { } /// An error produced by a failable Python operation. +@MainActor public enum PythonError : Error, Equatable { /// A Python runtime exception, produced by calling a Python function. case exception(PythonObject, traceback: PythonObject?) diff --git a/PythonKit/PythonLibrary.swift b/PythonKit/PythonLibrary.swift index ab94a3f..55afb3d 100644 --- a/PythonKit/PythonLibrary.swift +++ b/PythonKit/PythonLibrary.swift @@ -30,6 +30,7 @@ import WinSDK //===----------------------------------------------------------------------===// public struct PythonLibrary { + @MainActor public enum Error: Swift.Error, Equatable, CustomStringConvertible { case pythonLibraryNotFound