ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
563 stars 47 forks source link

building wheel for pyobjc-core 2 errors generated clang 、replacementObjectForArchiver #443

Closed keeepman closed 2 years ago

keeepman commented 2 years ago

I failed during building wheel for pyobjc-core, relevant part from error log:

+ (id)replacementObjectForArchiver:(NSArchiver*)archiver of:(NSObject*)object
                                          ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArchiver.h:15:12: note: 'NSArchiver' has been explicitly marked deprecated here
      @interface NSArchiver : NSCoder {
                 ^
      Modules/objc/test/objectint.m:125:20: error: 'replacementObjectForArchiver:' is deprecated: first deprecated in macOS 10.13 [-Werror,-Wdeprecated-declarations]
          return [object replacementObjectForArchiver:archiver];
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         replacementObjectForCoder
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArchiver.h:95:1: note: 'replacementObjectForArchiver:' has been explicitly marked deprecated here
      - (nullable id)replacementObjectForArchiver:(NSArchiver *)archiver API_DEPRECATED_WITH_REPLACEMENT("replacementObjectForCoder:", macos(10.0,10.13), ios(2.0,11.0), watchos(2.0,4.0), tvos(9.0,11.0));
      ^
      2 errors generated.
      error: command 'clang' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyobjc-core

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

python version 3.8.9

(venv) ➜  ~ xcodebuild -version
objc[22079]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1dd24f678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10a80c2c8). One of the two will be used. Which one is undefined.
objc[22079]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1dd24f6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10a80c318). One of the two will be used. Which one is undefined.
Xcode 13.2.1
Build version 13C100
ronaldoussoren commented 2 years ago

Which version of PyObjC do you use? I'm pretty sure this was fixed in 8.3.

Do you have more information about the python build you are using? "pip install pyobjc" should use binary wheels for Python 3.8, and I just checked that this works for the Python 3.8 on python.org.

keeepman commented 2 years ago
(venv) ➜  ~ source /Users/keeep/Downloads/py-project/githubLogin/venv/bin/activate
(venv) ➜  ~ python -V
Python 3.8.9
(venv) ➜  ~ xcodebuild -version
objc[23583]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1dd24f678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108de82c8). One of the two will be used. Which one is undefined.
objc[23583]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1dd24f6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108de8318). One of the two will be used. Which one is undefined.
Xcode 13.2.1
Build version 13C100
(venv) ➜  ~ pip install pyobjc

Then it throws an error when executing Whether it is pip install pyobjc or pip install pyobjc-core is the above error

dan-tull commented 2 years ago

I get the same error. I'm on macOS 12.0.1 with Xcode 13.1 and python 3.8.9. The pip command says it is using pyobjc_framework_Cocoa-8.3-cp38-cp38-macosx_11_0_universal2.whl, but fails with the error due to using -Werror and hitting a deprecation warning for NSArchiver and replacementObjectForArchiver.

I was able to force it to install using binary wheels with pip install --only-binary=:all: pyobjc-framework-Quartz so I have a workaround for now.

ronaldoussoren commented 2 years ago

I still wonder why pip doesn't pick the wheel by default. What's the result of sysconfig.get_platform()?

How did you install Python?

dan-tull commented 2 years ago
>>> sysconfig .get_platform()
'macosx-10.14-arm64'

I'm using a venv created from the system copy of Python 3 (which I try not use directly):

$ which python3
/usr/bin/python3
$ python3 -m venv .venv
$ ls -l .venv/bin/python
lrwxr-xr-x  1 dtull  staff  7 Feb 28 10:23 .venv/bin/python -> python3
$ . .venv/bin/activate
$ pip install --upgrade pip # the only-binary command produces an error and warning about pip being old, so I updated it
...
dan-tull commented 2 years ago

One other thing: I tried installing the 'wheel' package first due to this message I saw in the output from the pip command before I tried the only-binary directive: Using legacy 'setup.py install' for pyobjc-core, since package 'wheel' is not installed.

However, even with that installed, it still tries to build from source and hits the deprecation warning and errors out.

keeepman commented 2 years ago

Could this be related to arm? My last Apple computer that is not an arm architecture installed very smoothly

Kr1s77 commented 2 years ago

same error

      @interface NSArchiver : NSCoder {
                 ^
      Modules/objc/test/objectint.m:125:20: error: 'replacementObjectForArchiver:' is deprecated: first deprecated in macOS 10.13 [-Werror,-Wdeprecated-declarations]
          return [object replacementObjectForArchiver:archiver];
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         replacementObjectForCoder
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArchiver.h:95:1: note: 'replacementObjectForArchiver:' has been explicitly marked deprecated here
      - (nullable id)replacementObjectForArchiver:(NSArchiver *)archiver API_DEPRECATED_WITH_REPLACEMENT("replacementObjectForCoder:", macos(10.0,10.13), ios(2.0,11.0), watchos(2.0,4.0), tvos(9.0,11.0));
      ^
      2 errors generated.
      error: command 'gcc' failed with exit status 1
Kr1s77 commented 2 years ago

Could this be related to arm? My last Apple computer that is not an arm architecture installed very smoothly

import sysconfig sysconfig .get_platform() 'macosx-11-universal2' APPLE M1 pro

Kr1s77 commented 2 years ago

I failed during building wheel for pyobjc-core, relevant part from error log:

+ (id)replacementObjectForArchiver:(NSArchiver*)archiver of:(NSObject*)object
                                          ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArchiver.h:15:12: note: 'NSArchiver' has been explicitly marked deprecated here
      @interface NSArchiver : NSCoder {
                 ^
      Modules/objc/test/objectint.m:125:20: error: 'replacementObjectForArchiver:' is deprecated: first deprecated in macOS 10.13 [-Werror,-Wdeprecated-declarations]
          return [object replacementObjectForArchiver:archiver];
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         replacementObjectForCoder
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArchiver.h:95:1: note: 'replacementObjectForArchiver:' has been explicitly marked deprecated here
      - (nullable id)replacementObjectForArchiver:(NSArchiver *)archiver API_DEPRECATED_WITH_REPLACEMENT("replacementObjectForCoder:", macos(10.0,10.13), ios(2.0,11.0), watchos(2.0,4.0), tvos(9.0,11.0));
      ^
      2 errors generated.
      error: command 'clang' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyobjc-core

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

python version 3.8.9

(venv) ➜  ~ xcodebuild -version
objc[22079]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1dd24f678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10a80c2c8). One of the two will be used. Which one is undefined.
objc[22079]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1dd24f6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10a80c318). One of the two will be used. Which one is undefined.
Xcode 13.2.1
Build version 13C100

Use Python 3.9.10 (main, Jan 15 2022, 11:40:53) install successfully


python3.9 -m pip list
Package                                           Version
------------------------------------------------- -------
cobble                                            0.1.3
Deprecated                                        1.2.13
hiredis                                           2.0.0
mammoth                                           1.4.18
numpy                                             1.21.5
pip                                               22.0.3
protobuf                                          3.19.4
pycparser                                         2.21
pyobjc                                            8.3
pyobjc-core                                       8.3```

but Python 3.8.10 (v3.8.10:3d8993a744, May 3 2021, 09:09:08) same error platform: Mac arm

ronaldoussoren commented 2 years ago

I'll have to dig into pip to understand why it won't default to using the available and compatible wheel. I should now have enough information to both reproduce the issue and create a smaller reproducer for the pip project.

I may push out a 8.4 release sooner than planned, although I'd prefer to wait for the release of Xcode 13.3 to make sure the next release contains the correct updates for SDK changes in the next release of macOS.

ronaldoussoren commented 2 years ago

I now understand why a binary wheel wasn't used: there is no 3.8-universal2 wheel. I'll have to check why this wasn't build and uploaded even though all other variants were.

I also get the compile error when building from source, and the the error goes away when building the trunk of the repository.

karthikeyan-mac commented 2 years ago

I have the same error with macOS 12.0.1 and Python installed with Xcode Developer tools. I ended up installing the older version. I am waiting for this fix. Thanks.

vishaljangid1729 commented 2 years ago

I have the same error with macOS 12.2.1 and Python 3.8.9.

abstert commented 2 years ago

Looks like it's working for me now. @ronaldoussoren were you able to address the issue?

ronaldoussoren commented 2 years ago

This was fixed in PyObjC 8.4, released last night.

I'm still thinking about a more structural fix where I can use -Werror during development but disable it for releases.