The Python <-> Objective-C Bridge with bindings for macOS frameworks
Bot releases are visible (Hide)
Fix installation on OSX 10.10 when using "pip install pyobjc".
Issues #102, #103.
Fix crash when sys.modules
contains an object that is not a string.
Issue #95.
Fix crash on OSX 10.8 or later when using a 32-bit build and accessing
an instance of "Object" (that is, pre-Nextstep classes).
Fix a crash when using blocks without metadata, but with a block
signature from the block runtime.
Issue #106
PyObjCTools.MachSignals
likely hasn't worked at all since PyObjC 2.0
because it uses a C module that was never ported to PyObjC 2.0. This private
module is reintroduced in this release (with a slightly changed API)
Issue #109
Fix value of FLT_MAX
and FLT_MIN
in framework bindings.
Fix for the functions in PyObjCTools.AppHelper
: those functions didn't work
correctly when the calling thread didn't have a runloop.
Patch by Max Bélanger.
Issue #126: Load the LaunchServices definitions through the CoreServices
umbrella framework to avoid problems on OSX 10.11.
Issue #124: Sporadic crash at program shutdown due to a race condition between
Python interpreter shutdown and Cocoa cleanup.
This is mostly a workaround, I don't have a full solution for this yet and
I'm not sure if one is possible.
Added objc.PyObjC_BUILD_RELEASE
which contains the version of the SDK
that was used to build PyObjC in the same format as the OSX availability
macros.
Added maxTimeout parameter to PyObjCTools.AppHelper.runConsoleEventLoop
to fix issue #117. The default value is 3 seconds, which means that
the console eventloop will stop within 3 seconds of calling stopEventLoop
.
Re-enable faster method calls for simple method calls.
Support OSX 10.10 in PyObjCTools.TestSupport (version comparison was too
naive)
Add bindings for ApplicationServices, currently only the HIServices sub
framework is exposed.
Add bindings for NetFS, introduced in OSX 10.7.
Add bindings for ImageCaptureCore. Initial patch by Max Bélanger.
Add bindings for IMServicePlugIn, introduced in OSX 10.7.
Add bindings for SceneKit, introduced in OSX 10.8.
Add bindings for CoreBluetooth, MapKit, AVKit, MediaLibrary,
MediaAccessibility, GameController (all new in OSX 10.9)
Add bindings for FinderSync, CloudKit, CryptoTokenKit,
MultipeerConnectivity, NotificationCenter (all new in OSX 10.10)
Add bindings for Contacts, ContactsUI, Photos, PhotosUI (new in OSX 10.11)
Added function objc.callbackPointer
.
Updated bindings for AppKit, CoreData, CoreFoundation, CoreGraphics,
CoreLocation, CoreText, CoreVideo, CoreWLAN, EventKit, FSEvents,
ImageIO, ImageKit, JavaScriptCore, LaunchServices, OpenDirectory,
PDFKit, QuartzComposer, QuartzCore, QuartzFilters, QuickLookUI,
ServiceManagement, Social, StoreKit and WebKit with the new APIs
introduced in OSX 10.9, 10.10 and 10.11.
Unchanged framework bindings: Collaboration, DictionaryServices,
ExceptionHandling, InputMethodKit, InstallerPlugins, InstantMessage,
InterfaceBuilderKit, LatentSemanticMapping, PreferencePanes, PubSub.
.. note::
InterfaceBuilderKit will likely be removed in a future version of PyObjC
TODO: DiskArbitration, GameController, SpriteKit bindings are incomplete
Fix hard crash with invalid type strings in metadata.
Default value for struct wrappers was incorrect for fields that have
a type encoding that's custom to PyObjC.
Fix a type string validation error that could cause PyObjC to continue
processing beyond the end of a type string (which can effectively hang
the python interpreter with 100% CPU usage)
Fix edge-case in NSCoding support that causes PyObjC to use proxy objects
of the wrong type in some cases.
Fix incompatibility with Python 3.6 (where inspect.getargspec
no longer
exists)
Added (private) function objc._copyMetadataRegistry
. This function returns
a copy of the internal registry that's used to find additional information
about method signatures.
Note that the data structure returned by this function is subject to change,
that the data structure is undocumented and that modifying it does not affect
the data used by PyObjC.
Backward compatibility note: Due to a change in the way the default
method signature is calculated PyObjC is now more strict in enforcing
the Python<->Objective-C mapping for selectors and a number of code patterns
that were allowed before are no longer allowed, in particular the following
method definitions raise objc.BadPrototypeError
::
class MyObject (NSObject):
def mymethod(self, a, b): ...
def method_arg_(self, a, b, c): ...
If these methods are only used from Python and are never used from Objective-C
the error can be avoided by decorating these methods with objc.python_method
::
class MyObject (NSObject):
@objc.python_method
def mymethod(self, a, b): ...
This cannnot be used for methods used from Objective-C, for those you will
have to rename the method or you will have to provide an appropriate selector
explictly.
Fix crash when using some APIs in the LaunchServices framework.
Issue #100:Building with the Command Line Tools for Xcode installed caused build errors
on OSX 10.10
Python 3.6 made a change to the bytecode format that affected the way
PyObjC calculates the default method signature for Python methods.
Earlier versions of PyObjC will therefore not work properly with Python 3.6.
Update metadata for macOS 10.12.1
Note: Building PyObjC on macOS 10.12 requires Xcode 8.1 (or a later version)
Added bindings for the SafariServices and Intents frameworks, both introducted in macOS 10.12.
Added bindings for the MediaPlayer framework, introducted in macOS 10.12.1.
Add bindings for the ModelIO framework, introduced in OSX 10.11.
Issue #153: Add missing metadata file to ApplicationServices bindings
Issue #157: Bad reference to "_metadata" in ApplicationServices bindings
ApplicationServices framework didn't do "from ... import *" as was intended.
Don't force the installation of py2app.
Fix build failure using the OSX 10.10 SDK.
Issue #21: Tweak build procedure for PyObjC to avoid building pyobjc-core
multiple times when using pip install pyobjc
.
Issue #123: Use Twisted's cfreactor module in the examples using Twisted.
Issue #148: Fix build issue for the MapKit bindings on a case
sensitive filesystem.
Added bindings for the IOSurface framework (pyobjc-framework-IOSurface)
Added bindings for the NetworkExtension framework (pyobjc-framework-NetworkExtension)
Issue #149: Fix compile problems with Anaconda
Fix SystemError for accessing a method whose __metadata__
cannot be calculated,
found while researching issue #122.
Issue #146: Don't hang when running python setup.py build
using PyPy.
Note that PyPy still doesn't work, this just ensures that the build fails instead
of hanging indefinely.
Issue #143: Fix calculation of default type signature for selectors
Due to this change it is possible to use decorators like this::
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwds):
return func(*args, **kwds)
return decorator
Before this patch PyObjC gave an error due to the signature of wrapper
,
and if wrapper
was defined with an explicit self
argument PyObjC would
not give an error but would calculate the wrong method signature for wrapped
methods.
An unfortunate side effect of this change is that the argument count
of methods must now match the implied argument count of the selector, that is
a method with name someMethod_
must now have exactly two arguments (self
and the argument implied by the underscore at the end).
Use objc.python_method
as a decorator for python methods that don't use
this convention and do no need to be registered with the Objective-C runtime
as Objective-C selectors.
The bridge now considers the default arguments for a function when determining
if the Python signature of a function is compatible with the Objective-C
signature, that is the following method definition is valid::
class MyObject (NSObject):
def someMethod_(self, a, b=2): pass
The default selector calculated for Python methods with embedded underscores and
without a closing underscore has changed, the embedded underscores are not translated
to colons because the resulting Objective-C selector would not be valid.
That is, in earlier versions the default selector for "some_method" would be
"some:method", and from this version on the default for selector for this
method is "some_method".
(Python 3) Methods and functions with keyword-only arguments that don't have defaults
cause a objc.BadPrototypeError
exception when proxied to Objective-C
because those can never be called from Objective-C without causing an
exception.
Updates:
Small change to the shared setup.py code for framework wrappers to allow
building wheels for wrappers without a C exention on any system.
This was mostly done to make it easier to provide wheels in future releases.
Bugfixes:
Avoid build error with Python 2.7 when using the OSX 10.12 SDK, triggered
when Python was build using MacPython support.
Compatibility definitions for MAC_OS_X_VERSION_10_10, MAC_OS_X_VERSION_10_11
and MAC_OS_X_VERSION_10_12 were wrong, adjusted these.
Fix obscure crash in test suite of pyobjc-core: the definition of a class
that claims to conform to a protocol but didn't actually conform could
result in having a partial class definition in the Objective-C runtime.
Updated implementation for NSMutableArray.extend
. This both avoids an
error with the list interface tests in Python 3.6, and avoids unnecessary
memory usage with large arguments.
Removed PyObjCTools.TestSupport.filterWarnings, use warnings.catch_warnings
instead.
Building pyobjc-core using "python setup.py develop" will use 'ccache'
when available.
Building pyobjc-core will compile the source files from new to old files,
to speed up feedback while working on the source code.
Legacy BridgeSupport files on macOS 10.13 (which aren't used by default
by PyObjC) can contain junk data in typestring data. Cleanup that data
before using it.
Deal with loading bundle variables of a C string type, that used to crash
to do an oddity of locating that information.
Using wrappers for C structs as sequences is deprecated, this
feature was introduced a long while ago when the framework wrappers
were very incomplete and is no longer usefull.
Add objc.options.structs_indexable
. When this option is True
(the default) wrappers for C structs behave as before, when the
option is False these wrappers can no longer be used as writable
tuples, that is all "sequence" methods will raise TypeError
.
Add objc.options.structs_writable
. When this option is True
(the default) wrappers for C structs behave as before, when the
option is False these wrappers can no longer be modified.
Add availability macro MAC_OS_X_VERSION_10_13
to objc
.
New framework wrappers:
ColorSync </apinotes/ColorSync>
(new in macOS 10.13)CoreML </apinotes/CoreML>
(new in macOS 10.13)ExternalAccessory </apinotes/ExternalAccessory>
(new in macOS 10.13)CoreSpotlight </apinotes/CoreSpotlight>
(new in macOS 10.13)Vision </apinotes/Vision>
(new in macOS 10.13)metadata updates:
Accounts </apinotes/Accounts>
AddressBook </apinotes/AddressBook>
AppKit </apinotes/AppKit>
ApplicationServices </apinotes/ApplicationServices>
Automator </apinotes/Automator>
AVKit </apinotes/AVKit>
CalendarStore </apinotes/CalendarStore>
CFNetwork </apinotes/CFNetwork>
CloudKit </apinotes/CloudKit>
Contacts </apinotes/Contacts>
CoreBluetooth </apinotes/CoreBluetooth>
CoreData </apinotes/CoreData>
CoreFoundation </apinotes/CoreFoundation>
CoreGraphics </apinotes/CoreGraphics>
CoreImage </apinotes/CoreImage>
CoreLocation </apinotes/CoreLocation>
CoreServices </apinotes/CoreServices>
CoreText </apinotes/CoreText>
CoreVideo </apinotes/CoreVideo>
CoreWLAN </apinotes/CoreWLAN>
CryptoTokenKit </apinotes/CryptoTokenKit>
EventKit </apinotes/EventKit>
FinderSync </apinotes/FinderSync>
Foundation </apinotes/Foundation>
FSEvents </apinotes/FSEvents>
GameController </apinotes/GameController>
IMServicePlugIn </apinotes/IMServicePlugIn>
ImageCaptureCore </apinotes/ImageCaptureCore>
ImageIO </apinotes/ImageIO>
Intents </apinotes/Intents>
IOSurface </apinotes/IOSurface>
JavaScriptCore </apinotes/JavaScriptCore>
LocalAuthentication </apinotes/LocalAuthentication>
MapKit </apinotes/MapKit>
MediaLibrary </apinotes/MediaLibrary>
MediaPlayer </apinotes/MediaPlayer>
ModelIO </apinotes/ModelIO>
MultipeerConnectivity </apinotes/MultipeerConnectivity>
NetFS </apinotes/NetFS>
NetworkExtension </apinotes/NetworkExtension>
OpenDirectory </apinotes/OpenDirectory>
Photos </apinotes/Photos>
PhotosUI </apinotes/PhotosUI>
QTKit </apinotes/QTKit>
Quartz </apinotes/Quartz>
QuartzCore </apinotes/QuartzCore>
QuickLook </apinotes/QuickLook>
SafariServices </apinotes/SafariServices>
SceneKit </apinotes/SceneKit>
ScreenSaver </apinotes/ScreenSaver>
Social </apinotes/Social>
SpriteKit </apinotes/SpriteKit>
SystemConfiguration </apinotes/SystemConfiguration>
WebKit </apinotes/WebKit>
Issue #204: Metadata for CGPDFDictionaryGetObject was wrong
Reported by Nickolas Pohilets.
Updated metadata for Xcode 9 GM.
Fix #202: Add bindings for CGPDFDictionaryRef
, CGPDFScannerRef
CGPDFStreamRef
and CGPDFStringRef
to the Quartz bindings (including
some minor updates to function metadata)
Reported by Nickolas Pohilets.
Issue #205: Add ability to read bytes from objc.varlist
Instances of objc.varlist
now have a method to return a memoryview
that refers to the first section of the list::
def as_buffer(self, count : int) -> memoryview
This returns a memoryview the references the underlying memory for
the first count elements in the list.
Reported by Nickolas Pohilets.
Added bindings for the :doc:GameKit </apinotes/GameKit>
framework introduced in macOS 10.8.
Added bindings for the :doc:GameplayKit </apinotes/GameplayKit>
framework introduced in macOS 10.11.
Note that these bindings are less useful than they could be because
PyObjC currently does not support "vector" types that are used in
some APIs.
Issue #213: Fix signature for -[NSObject forwardInvocation:]
Reported by user "pyrocat"
Updated metadata for Xcode 9.1
Changes to PyObjCTools.TestSupport to be able to include/exclude tests
based on the minor release of macOS.
Some tweaks to fix test failures when running on OSX 10.5, 10.6, 10.9.
NOTE:
The stacktrace formatting of in PyObjCTools.Debugging
(from the
ExceptionHandling bindings) don't work for PPC binaries because symbol
resolution doesn't work.
This is a known issue that won't be fixed.
Protection agains buffer overflow and negative indexes in
__getitem__
and __setitem__
for objc.varlist
instances.
Fix incorrect metadata for +[NSEvent addLocalMonitorForEventsMatchingMask:handler:]
Fix incorrect and misleading error message in the exception
that is raised when return a value from a block that should not
return a value.
Issue #223: Fix hard crash when executing help(Cocoa)
Fetching the help for PyObjC framework wrappers isn't very useful due
to the sheer size of the output (4.5 million lines of output for
help(Cocoa)
at the moment), but shouldn't cause a hard crash of
the interpreter.
Reported by Dave Fuller
Issue #218: Explictly cause an ImportError when reloading objc._objc
Reloading the PyObjC core extension now raises an ImportError because
this cannot work and used to raise a rather vague error.
Updated metadata for Xcode 9.2
Added missing MAC_OS_X_VERSION_*
constants
Fix memory error in struct wrappers which resulted in
a use-after-free error in the initializer for structs.
#135: Add bindings for frameworks :doc:Security </apinotes/Security>
,
:doc:SecurityFoundation </apinotes/SecurityFoundation>
and
and :doc:SecurityInterface </apinotes/SecurityInterface>
.
The bindings for the Security framework don't expose a
number of older APIs that were deprecated in macOS 10.7.
#129: Add bindings to libdispatch.
These bindings require macOS 10.8 or later, libdispatch was
available earlier but macOS 10.8 changed the API in such a
way that wrapping became a lot easier.
Add bindings to the BusinessChat framework introduced in macOS 10.13.4
Update metadata for Xcode 9.3
Issue #233 Fix crash in Security.AuthorizationCopyRights() wrapper
Issue #234 Fix crash in AuthorizationExecuteWithPrivileges() wrapper
Reported by Vangelis Koukis
Ensure doctest can work with modules containing subclasses of NSObject
Reported by Just van Rossum
Issue #236 : Importing can sometimes fail in multi-threaded scenarios
Fix by Max Bélanger
Undeprecate treating struct wrappers as sequences. Removing this feature would
break too much existing code, hence deprecating is not really an option. Furthermore,
this would also break some nice idioms.
Pull request #17: Fix python 3 issues in PyObjCTools.AppHelper and PyObjCTools.Conversion
Fix by Max Bélanger
Update metadata for Xcode 9.4
The binary release now includes wheels for both variants for the
Python.org installer for python 3.6 and 3.7: 32- and 64-bit for
macOS 10.6 or later, and 64-bit only for macOS 10.9 or later.
Ensure the context manager for NSAnimationContext
defined in
PyObjCTools.AppCategories
actually works.
Fix convenience wrappers for Foundation.NSCache
.
Fix convenience wrappers for Foundation.NSHashTable
.
Adds support for macOS 10.14 (Mojave)
This release updates the framework wrappers with support
for new APIs in macOS 10.14 and adds bindings for the following
new frameworks:
Support for CoreAudio, CoreMedia and MediaToolbox is limited
in this release due to missing manual wrappers.
Added two features that can help with gating code on the
version of macos:
The constants "objc.MAC_OS_X_VERSION_CURRENT" can be
compared with one of the "objc.MAC_OS_X_VERSION_..." contants.
The function "objc.macos_avaiable(major, minor[, patch])"
returns true if the current macOS version is at least the
specified version, comparable with "@available" in Swift.
Bindings updated for Xcode 10 beta 6.
Add a custom binding for a number of structure types in
CoreAudio:
With this patch using APIs with these types should actually
work.
PR19: Fix deprecation warning in bridgesupport support module
Patch by: Mickaël Schoentgen
Creating objc.ObjCPointer instances now results in a
Python warning, instead of an unconditional message on
stdout.
.. note::
The creation of these objects is a sign that APIs are
not wrapped correctly, these objects are created for
pointers where the bridge doesn't know how to handle
them properly.
System bridgesupport XML files (normally not used by PyObjC)
can contain constant numbers with value "inf", PyObjC now
knows how to handle those.
Added bindings for the "Metadata" subframework of the
"CoreServices" framework.
Added bindings for the "CarbonCore" subframework of the
"CoreServices" framework.
Most APIs in this subframework are not available to Python,
only those APIs that are not deprecated and seem interesting
are exposed.
The separate framework wrappers DictionaryServices,
LaunchServices and SearchKit are deprecated, use
the CoreServices bindings instead.
These framework wrappers still exists, but are effectively
aliases for CoreServices with this release. Because of this
these bindings can expose more symbols than previously.
Fix unexpected exception when trying to call getattr
on a framework wrapped with a name that isn't a valid
identifier.
#244: Bad metadata for CGPDFOperatorTableSetCallback
#247: Fix crash in regression test case
One specific test in pyobjc-core crashed the interpreter
when run separately. Because of this I've disabled an
optimization that uses alloca instead of PyMem_Malloc to
allocate memory for now.
Xcode 10 "GM" contains one difference from the last beta: the constant MLComputeUnitsCPUAndGPU
in the CoreML bindings.
#222: Add a proxy for C's "FILE*" type on Python 3. This is not necessary on Python 2 because
the default IO stack on Python 2 already uses FILE* internally.
This proxy type is very minimal and shouldn't not be used for general I/O.
Bindings are up-to-date w.r.t. Xcode 10.1 (beta)
Updated the support code for framework wrappers to be able to emit deprecation warnings on
the first import of a deprecated constants (functions and methods will only raise a deprecation
warning when called).
This is just an infrastructure change, the actual framework bindings do not yet contain the
information used to emit deprecation warnings.
Add metadata for deprecation warnings to the "Contacts" framework
#252: Import ABCs from collections.abc
instead of collections
because the latter is deprecated.
#180, #251: Instances of most builtin value types and sequences (int, float, str, unicode, tuple,
list, set, frozenset and dict) can now be written to archives that require secureCoding.
#254: Fix compile error on macOS 10.9 or earlier
#255: Calling completion handler failed due to incomplete runtime info
PyObjC's metadata system didn't automaticly set the call signature
for blocks passed into a method implemented in Python. This causes problems
when the ObjC or Swift block does not have signature information in the
ObjC/blocks runtime.
Use MAP_JIT when allocating memory for the executable stubs for Python
methods.
With the "restricted" runtime you'll have to add the "com.apple.security.cs.allow-jit"
entitlement to use this flag, in earlier versions you'd have to use
a different entitlement: "com.apple.security.cs.allow-unsigned-executable-memory".
The MAP_JIT flag is only used on macOS 10.14 or later.
Ensure that PyObjC can be built using /usr/bin/python on macOS 10.14
This failed due the problems with header files in the SDK included with Xcode 10.
Updated metadata for Xcode 10.2
#252: objc.registerStructAlias
no longer emits a deprecation
warning because it is still used by the framework wrappers.
The function is still deprecated though, the deprecation will reappear
once the metadata has been updatd.
#75: The core bridge now uses :func:PyDict_GetItemWithError
, which
may result in exceptions being raised that were previously swallowed.
#247: Partially switch to the new buffer API instead of the older
Python 2 buffer API.
The new implementation is more correct, but may keep Python objects
alive longer than the previous implementation, and also affects
buffer related functionality of Python objects. In particular, calling
[someData bytes]
on a Python object keeps the Py_buffer
alive
until the next flush of the autoreleasepool.
#257: Fix incorrect metadata for the callback argument to
-[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:]
.
#258: Add bindings to the "PrintCore" APIs from the ApplicationServices framework.
Removed Python 2 support from the C extension in pyobjc-core
Reformatted code in pyobjc-core:
Use "black" for Python code
Use "clang-format" for Objective-C code
As a side-effect of this all usage of "NS_DURING" and "PyObjC_DURING"
has been replaced by the expansion of those macros, mostly because
"clang-format" doesn't understand these kinds of blocks.
Replacing "PyObjC_DURING" by its expansion also reduces the knowledge
needed to understand what's going on w.r.t. the Python GIL.
The macro "PyObjC_DURING", and its siblings, have been removed as well.
Updated bindings for macOS 10.15 (Xcode 11.0)
The userspace driver frameworks introduced in macOS 10.15
(DriverKit and related frameworks) will not be exposed through
PyObjC. Please let me know if you have a good
use case for using these frameworks with Python.
Add new framework wrappers for all other new frameworks
in macOS 10.15:
Add new framework wrappers for a number of older
frameworks:
Issue #271: Fix crash when creating NSData objects on macOS 10.15