gregneagle / relocatable-python

A tool for building standalone relocatable Python.framework bundles
Apache License 2.0
155 stars 42 forks source link

PyObjc v7.2 fails to build on macOS 12.3.1, Apple Silicon, Xcode 13.3 + Command Line Tools #25

Closed carlashley closed 2 years ago

carlashley commented 2 years ago

PyObjc v7.2 fails to build when it's specified as a package in a custom requirements file. I'm raising this here even though I've bumped into this issue building a new munki package because it's something I've reproduced with relocatable-python, and mostly as an "FYI" for anyone that also see's this happen.

Xcode 13.3 and the Command Line Tools for Xcode 13.3 are being used (macOS 12.3.1, Apple Silicon processor).

The command to create the Python.framework:

./make_relocatable_python_framework.py --os-version=11 --python-version=3.9.7 --pip-requirements=custom_requirements.txt --upgrade-pip

Contents of custom_requirements.txt (same as current munki Python 3 requirements) that fails:

asn1crypto
cffi
pyobjc==7.2
six==1.15.0
xattr==0.9.7
--no-binary :all:

Contents of custom_requirements.txt (same as current munki Python 3 requirements) that succeeds:

asn1crypto
cffi
pyobjc==8.4.1
six==1.15.0
xattr==0.9.7
--no-binary :all:

Build output when it fails:

[snip]
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DPyObjC_BUILD_RELEASE=1203
      Modules/objc/OC_PythonObject.m:241:18: error: variable 'cookie' set but not used [-Werror,-Wunused-but-set-variable]
          void*        cookie;
                       ^
      1 error generated.
      error: command '/usr/bin/gcc' failed with exit code 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.
Traceback (most recent call last):
  File "./make_relocatable_python_framework.py", line 108, in <module>
    main()
  File "./make_relocatable_python_framework.py", line 94, in main
    install_extras(
  File "/Volumes/ExternalVolume/work/git/github/relocatable-python/locallibs/install.py", line 109, in install_extras
    install_requirements(requirements_file, framework_path, version)
  File "/Volumes/ExternalVolume/work/git/github/relocatable-python/locallibs/install.py", line 74, in install_requirements
    subprocess.check_call(cmd)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['./Python.framework/Versions/3.9/bin/python3.9', '-s', '-m', 'pip', 'install', '-r', 'custom_requirements.txt']' returned non-zero exit status 1.

Build success output (after changing requirement to `pyobjc==8.4.1):

Successfully installed asn1crypto-1.5.1 cffi-1.15.0 pycparser-2.21 pyobjc-8.4.1 pyobjc-core-8.4.1 pyobjc-framework-AVFoundation-8.4.1 pyobjc-framework-AVKit-8.4.1 pyobjc-framework-Accessibility-8.4.1 pyobjc-framework-Accounts-8.4.1 pyobjc-framework-AdServices-8.4.1 pyobjc-framework-AdSupport-8.4.1 pyobjc-framework-AddressBook-8.4.1 pyobjc-framework-AppTrackingTransparency-8.4.1 pyobjc-framework-AppleScriptKit-8.4.1 pyobjc-framework-AppleScriptObjC-8.4.1 pyobjc-framework-ApplicationServices-8.4.1 pyobjc-framework-AudioVideoBridging-8.4.1 pyobjc-framework-AuthenticationServices-8.4.1 pyobjc-framework-AutomaticAssessmentConfiguration-8.4.1 pyobjc-framework-Automator-8.4.1 pyobjc-framework-BusinessChat-8.4.1 pyobjc-framework-CFNetwork-8.4.1 pyobjc-framework-CalendarStore-8.4.1 pyobjc-framework-CallKit-8.4.1 pyobjc-framework-ClassKit-8.4.1 pyobjc-framework-CloudKit-8.4.1 pyobjc-framework-Cocoa-8.4.1 pyobjc-framework-Collaboration-8.4.1 pyobjc-framework-ColorSync-8.4.1 pyobjc-framework-Contacts-8.4.1 pyobjc-framework-ContactsUI-8.4.1 pyobjc-framework-CoreAudio-8.4.1 pyobjc-framework-CoreAudioKit-8.4.1 pyobjc-framework-CoreBluetooth-8.4.1 pyobjc-framework-CoreData-8.4.1 pyobjc-framework-CoreHaptics-8.4.1 pyobjc-framework-CoreLocation-8.4.1 pyobjc-framework-CoreMIDI-8.4.1 pyobjc-framework-CoreML-8.4.1 pyobjc-framework-CoreMedia-8.4.1 pyobjc-framework-CoreMediaIO-8.4.1 pyobjc-framework-CoreMotion-8.4.1 pyobjc-framework-CoreServices-8.4.1 pyobjc-framework-CoreSpotlight-8.4.1 pyobjc-framework-CoreText-8.4.1 pyobjc-framework-CoreWLAN-8.4.1 pyobjc-framework-CryptoTokenKit-8.4.1 pyobjc-framework-DVDPlayback-8.4.1 pyobjc-framework-DataDetection-8.4.1 pyobjc-framework-DeviceCheck-8.4.1 pyobjc-framework-DictionaryServices-8.4.1 pyobjc-framework-DiscRecording-8.4.1 pyobjc-framework-DiscRecordingUI-8.4.1 pyobjc-framework-DiskArbitration-8.4.1 pyobjc-framework-EventKit-8.4.1 pyobjc-framework-ExceptionHandling-8.4.1 pyobjc-framework-ExecutionPolicy-8.4.1 pyobjc-framework-ExternalAccessory-8.4.1 pyobjc-framework-FSEvents-8.4.1 pyobjc-framework-FileProvider-8.4.1 pyobjc-framework-FileProviderUI-8.4.1 pyobjc-framework-FinderSync-8.4.1 pyobjc-framework-GameCenter-8.4.1 pyobjc-framework-GameController-8.4.1 pyobjc-framework-GameKit-8.4.1 pyobjc-framework-GameplayKit-8.4.1 pyobjc-framework-IMServicePlugIn-8.4.1 pyobjc-framework-IOSurface-8.4.1 pyobjc-framework-ImageCaptureCore-8.4.1 pyobjc-framework-InputMethodKit-8.4.1 pyobjc-framework-InstallerPlugins-8.4.1 pyobjc-framework-InstantMessage-8.4.1 pyobjc-framework-Intents-8.4.1 pyobjc-framework-IntentsUI-8.4.1 pyobjc-framework-KernelManagement-8.4.1 pyobjc-framework-LatentSemanticMapping-8.4.1 pyobjc-framework-LaunchServices-8.4.1 pyobjc-framework-LinkPresentation-8.4.1 pyobjc-framework-LocalAuthentication-8.4.1 pyobjc-framework-LocalAuthenticationEmbeddedUI-8.4.1 pyobjc-framework-MLCompute-8.4.1 pyobjc-framework-MailKit-8.4.1 pyobjc-framework-MapKit-8.4.1 pyobjc-framework-MediaAccessibility-8.4.1 pyobjc-framework-MediaLibrary-8.4.1 pyobjc-framework-MediaPlayer-8.4.1 pyobjc-framework-MediaToolbox-8.4.1 pyobjc-framework-Metal-8.4.1 pyobjc-framework-MetalKit-8.4.1 pyobjc-framework-MetalPerformanceShaders-8.4.1 pyobjc-framework-MetalPerformanceShadersGraph-8.4.1 pyobjc-framework-MetricKit-8.4.1 pyobjc-framework-ModelIO-8.4.1 pyobjc-framework-MultipeerConnectivity-8.4.1 pyobjc-framework-NaturalLanguage-8.4.1 pyobjc-framework-NetFS-8.4.1 pyobjc-framework-Network-8.4.1 pyobjc-framework-NetworkExtension-8.4.1 pyobjc-framework-NotificationCenter-8.4.1 pyobjc-framework-OSAKit-8.4.1 pyobjc-framework-OSLog-8.4.1 pyobjc-framework-OpenDirectory-8.4.1 pyobjc-framework-PassKit-8.4.1 pyobjc-framework-PencilKit-8.4.1 pyobjc-framework-Photos-8.4.1 pyobjc-framework-PhotosUI-8.4.1 pyobjc-framework-PreferencePanes-8.4.1 pyobjc-framework-PushKit-8.4.1 pyobjc-framework-Quartz-8.4.1 pyobjc-framework-QuickLookThumbnailing-8.4.1 pyobjc-framework-ReplayKit-8.4.1 pyobjc-framework-SafariServices-8.4.1 pyobjc-framework-SceneKit-8.4.1 pyobjc-framework-ScreenCaptureKit-8.4.1 pyobjc-framework-ScreenSaver-8.4.1 pyobjc-framework-ScreenTime-8.4.1 pyobjc-framework-ScriptingBridge-8.4.1 pyobjc-framework-SearchKit-8.4.1 pyobjc-framework-Security-8.4.1 pyobjc-framework-SecurityFoundation-8.4.1 pyobjc-framework-SecurityInterface-8.4.1 pyobjc-framework-ServiceManagement-8.4.1 pyobjc-framework-ShazamKit-8.4.1 pyobjc-framework-Social-8.4.1 pyobjc-framework-SoundAnalysis-8.4.1 pyobjc-framework-Speech-8.4.1 pyobjc-framework-SpriteKit-8.4.1 pyobjc-framework-StoreKit-8.4.1 pyobjc-framework-SyncServices-8.4.1 pyobjc-framework-SystemConfiguration-8.4.1 pyobjc-framework-SystemExtensions-8.4.1 pyobjc-framework-UniformTypeIdentifiers-8.4.1 pyobjc-framework-UserNotifications-8.4.1 pyobjc-framework-UserNotificationsUI-8.4.1 pyobjc-framework-VideoSubscriberAccount-8.4.1 pyobjc-framework-VideoToolbox-8.4.1 pyobjc-framework-Virtualization-8.4.1 pyobjc-framework-Vision-8.4.1 pyobjc-framework-WebKit-8.4.1 pyobjc-framework-iTunesLibrary-8.4.1 pyobjc-framework-libdispatch-8.4.1 six-1.15.0 xattr-0.9.7
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Modifying shebang for ./Python.framework/Versions/3.9/bin/pip3.9...
Modifying shebang for ./Python.framework/Versions/3.9/bin/pip3...
Modifying shebang for ./Python.framework/Versions/3.9/bin/wheel...
Modifying shebang for ./Python.framework/Versions/3.9/bin/python3.9-config...
Modifying shebang for ./Python.framework/Versions/3.9/bin/pip...
Modifying shebang for ./Python.framework/Versions/3.9/bin/pydoc3.9...
Modifying shebang for ./Python.framework/Versions/3.9/bin/idle3.9...
Modifying shebang for ./Python.framework/Versions/3.9/bin/2to3-3.9...
Modifying shebang for ./Python.framework/Versions/3.9/bin/xattr...

Done!
Customized, relocatable framework is at ./Python.framework
gregneagle commented 2 years ago

Not every combination is trivial to build. PyObjC 7.2 seems to build ok with Xcode 13.2.1 for example. Since I have no control over Xcode or PyObjC or pip we’ll all just have to deal with these quirks.

carlashley commented 2 years ago

Yeah I gather as much. The only concern I have, in relation to munki, is if using a newer version of pyobjc in the munki build will cause bigger issues. I don't like version bumping those particular packages because there's been work testing that specific python package works for munki.