From c1cba75d757f10ca97bd96428f540f2858606281 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 3 Nov 2023 14:19:55 +0800 Subject: [PATCH 1/8] Switch to a dynamic framework. --- {{ cookiecutter.format }}/briefcase.toml | 16 +++++- .../{{ cookiecutter.class_name }}/main.m | 23 +++----- .../project.pbxproj | 53 +++++++++++++------ 3 files changed, 60 insertions(+), 32 deletions(-) diff --git a/{{ cookiecutter.format }}/briefcase.toml b/{{ cookiecutter.format }}/briefcase.toml index 8c18562..cd77ac6 100644 --- a/{{ cookiecutter.format }}/briefcase.toml +++ b/{{ cookiecutter.format }}/briefcase.toml @@ -13,7 +13,21 @@ support_path = "Support" "3.11": "support_revision = 3", "3.12": "support_revision = 2", }.get(cookiecutter.python_version|py_tag, "") }} - +cleanup_paths = [ + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/itcl*", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/__phello__", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/**/test", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/idlelib", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/tkinter", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/turtledemo", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/tcl*", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/tk*", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/tdbc*", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/._lib*", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/libtcl*", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/libtk*", + "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/Tk.*", +] icon.16 = "{{ cookiecutter.class_name }}/Assets.xcassets/{{ cookiecutter.formal_name }}.appiconset/icon-16.png" icon.32 = "{{ cookiecutter.class_name }}/Assets.xcassets/{{ cookiecutter.formal_name }}.appiconset/icon-32.png" icon.64 = "{{ cookiecutter.class_name }}/Assets.xcassets/{{ cookiecutter.formal_name }}.appiconset/icon-64.png" diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m b/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m index b15f3ed..0a693b7 100644 --- a/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m +++ b/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m @@ -5,7 +5,7 @@ #import #import #import -#include +#import #include @@ -36,6 +36,7 @@ int main(int argc, char *argv[]) { @autoreleasepool { NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; + NSString * frameworksPath = [[NSBundle mainBundle] privateFrameworksPath]; // Generate an isolated Python configuration. NSLog(@"Configuring isolated Python..."); @@ -53,6 +54,8 @@ int main(int argc, char *argv[]) { config.write_bytecode = 0; // Isolated apps need to set the full PYTHONPATH manually. config.module_search_paths_set = 1; + // Enable verbose logging for debug purposes + // config.verbose = 1; NSLog(@"Pre-initializing Python runtime..."); status = Py_PreInitialize(&preconfig); @@ -63,7 +66,7 @@ int main(int argc, char *argv[]) { } // Set the home for the Python interpreter - python_home = [NSString stringWithFormat:@"%@/support/python-stdlib", resourcePath, nil]; + python_home = [NSString stringWithFormat:@"%@/Python.framework/Versions/{{ cookiecutter.python_version|py_tag }}", frameworksPath, nil]; NSLog(@"PythonHome: %@", python_home); wtmp_str = Py_DecodeLocale([python_home UTF8String], NULL); status = PyConfig_SetString(&config, &config.home, wtmp_str); @@ -106,20 +109,8 @@ int main(int argc, char *argv[]) { // Set the full module path. This includes the stdlib, site-packages, and app code. NSLog(@"PYTHONPATH:"); - // The .zip form of the stdlib - path = [NSString stringWithFormat:@"%@/support/python{{ cookiecutter.python_version|py_libtag }}.zip", resourcePath, nil]; - NSLog(@"- %@", path); - wtmp_str = Py_DecodeLocale([path UTF8String], NULL); - status = PyWideStringList_Append(&config.module_search_paths, wtmp_str); - if (PyStatus_Exception(status)) { - crash_dialog([NSString stringWithFormat:@"Unable to set .zip form of stdlib path: %s", status.err_msg, nil]); - PyConfig_Clear(&config); - Py_ExitStatusException(status); - } - PyMem_RawFree(wtmp_str); - // The unpacked form of the stdlib - path = [NSString stringWithFormat:@"%@/support/python-stdlib", resourcePath, nil]; + path = [NSString stringWithFormat:@"%@/Python.framework/Versions/{{ cookiecutter.python_version|py_tag }}/lib/python{{ cookiecutter.python_version|py_tag }}", frameworksPath, nil]; NSLog(@"- %@", path); wtmp_str = Py_DecodeLocale([path UTF8String], NULL); status = PyWideStringList_Append(&config.module_search_paths, wtmp_str); @@ -131,7 +122,7 @@ int main(int argc, char *argv[]) { PyMem_RawFree(wtmp_str); // Add the stdlib binary modules path - path = [NSString stringWithFormat:@"%@/support/python-stdlib/lib-dynload", resourcePath, nil]; + path = [NSString stringWithFormat:@"%@/Python.framework/Versions/{{ cookiecutter.python_version|py_tag }}/lib/python{{ cookiecutter.python_version|py_tag }}/lib-dynload", frameworksPath, nil]; NSLog(@"- %@", path); wtmp_str = Py_DecodeLocale([path UTF8String], NULL); status = PyWideStringList_Append(&config.module_search_paths, wtmp_str); diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj index c27b914..5342c67 100644 --- a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj +++ b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj @@ -14,19 +14,30 @@ 0D354FEF2551C249009178D1 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D354FEE2551C249009178D1 /* Cocoa.framework */; }; 0D7B44A82555E01500CBC44B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D7B44A72555E01500CBC44B /* Foundation.framework */; }; 0D7B44DA2556C84100CBC44B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D354FD72551BFBD009178D1 /* main.m */; }; - 60A04BBF28AF5E7400DAA9E5 /* python-stdlib in Copy Python standard library */ = {isa = PBXBuildFile; fileRef = 60A04BBE28AF5E7400DAA9E5 /* python-stdlib */; }; - 60A04BC028AF5EC000DAA9E5 /* Python.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60A04BBC28AF5E6900DAA9E5 /* Python.xcframework */; }; + 6060E7722AF0B40500C04AE0 /* Python.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6060E76F2AF0B14D00C04AE0 /* Python.xcframework */; }; + 6060E7732AF0B40500C04AE0 /* Python.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6060E76F2AF0B14D00C04AE0 /* Python.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ - 0D7B44EB2556C8B800CBC44B /* Embed App Extensions */ = { + 0D7B44EB2556C8B800CBC44B /* Embed Foundation Extensions */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 13; files = ( ); - name = "Embed App Extensions"; + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; + 6060E7742AF0B40500C04AE0 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 6060E7732AF0B40500C04AE0 /* Python.xcframework in Embed Frameworks */, + ); + name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; 609384A728C873E2005B2A5D /* Copy Python standard library */ = { @@ -35,7 +46,6 @@ dstPath = support; dstSubfolderSpec = 7; files = ( - 60A04BBF28AF5E7400DAA9E5 /* python-stdlib in Copy Python standard library */, ); name = "Copy Python standard library"; runOnlyForDeploymentPostprocessing = 0; @@ -53,8 +63,7 @@ 0D354FE52551C1E1009178D1 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 0D354FEE2551C249009178D1 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 0D7B44A72555E01500CBC44B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 60A04BBC28AF5E6900DAA9E5 /* Python.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python.xcframework; sourceTree = ""; }; - 60A04BBE28AF5E7400DAA9E5 /* python-stdlib */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "python-stdlib"; sourceTree = ""; }; + 6060E76F2AF0B14D00C04AE0 /* Python.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python.xcframework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -64,8 +73,8 @@ files = ( 0D354FE62551C1E1009178D1 /* AppKit.framework in Frameworks */, 0D354FEF2551C249009178D1 /* Cocoa.framework in Frameworks */, - 60A04BC028AF5EC000DAA9E5 /* Python.xcframework in Frameworks */, 0D7B44A82555E01500CBC44B /* Foundation.framework in Frameworks */, + 6060E7722AF0B40500C04AE0 /* Python.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -116,8 +125,7 @@ 60A04BBB28AF5E1000DAA9E5 /* Support */ = { isa = PBXGroup; children = ( - 60A04BBE28AF5E7400DAA9E5 /* python-stdlib */, - 60A04BBC28AF5E6900DAA9E5 /* Python.xcframework */, + 6060E76F2AF0B14D00C04AE0 /* Python.xcframework */, ); path = Support; sourceTree = ""; @@ -133,8 +141,9 @@ 0D354FC52551BFBA009178D1 /* Frameworks */, 0D354FC62551BFBA009178D1 /* Resources */, 609384A728C873E2005B2A5D /* Copy Python standard library */, - 0D7B44EB2556C8B800CBC44B /* Embed App Extensions */, + 0D7B44EB2556C8B800CBC44B /* Embed Foundation Extensions */, 60A04BC128AF640400DAA9E5 /* Sign Python Binary Modules */, + 6060E7742AF0B40500C04AE0 /* Embed Frameworks */, ); buildRules = ( ); @@ -152,7 +161,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1330; + LastUpgradeCheck = 1500; ORGANIZATIONNAME = "{{ cookiecutter.author }}"; TargetAttributes = { 0D354FC72551BFBA009178D1 = { @@ -209,7 +218,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\necho \"Signed as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)\"\nfind \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/support/python-stdlib/lib-dynload\" -name \"*.so\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\; \nfind \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/app_packages\" -name \"*.so\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\; \nfind \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/app\" -name \"*.so\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\; \n"; + shellScript = "set -e\necho \"Signed as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)\"\nfind \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/app_packages\" -name \"*.so\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\; \nfind \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/app\" -name \"*.so\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\; \n"; }; /* End PBXShellScriptBuildPhase section */ @@ -259,6 +268,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -323,6 +333,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -354,12 +365,19 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CODE_SIGN_ENTITLEMENTS = "{{ cookiecutter.class_name }}/{{ cookiecutter.app_name }}.entitlements"; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; ENABLE_HARDENED_RUNTIME = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(PROJECT_DIR)/Support\"", + ); GCC_C_LANGUAGE_STANDARD = gnu99; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\""; INFOPLIST_FILE = "{{ cookiecutter.class_name }}/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -368,7 +386,6 @@ MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}"; PROVISIONING_PROFILE_SPECIFIER = ""; - STRIP_INSTALLED_PRODUCT = NO; }; name = Debug; }; @@ -380,13 +397,20 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CODE_SIGN_ENTITLEMENTS = "{{ cookiecutter.class_name }}/{{ cookiecutter.app_name }}.entitlements"; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; ENABLE_HARDENED_RUNTIME = YES; ENABLE_TESTABILITY = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(PROJECT_DIR)/Support\"", + ); GCC_C_LANGUAGE_STANDARD = gnu99; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\""; INFOPLIST_FILE = "{{ cookiecutter.class_name }}/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -394,7 +418,6 @@ ); MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}"; - STRIP_INSTALLED_PRODUCT = NO; }; name = Release; }; From 2206917cd45d860b03034058005dcff08a7d5045 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 26 Jul 2024 11:03:57 +0800 Subject: [PATCH 2/8] Correct stub and build steps to support macOS frameworks. --- .../{{ cookiecutter.class_name }}/main.m | 7 +++++++ .../project.pbxproj | 17 ++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m b/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m index 97728a2..0c3ec25 100644 --- a/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m +++ b/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m @@ -393,6 +393,13 @@ void setup_stdout(NSBundle *mainBundle) { int ret = 0; const char *nslog_script; + // If the app is running under Xcode 15 or later, we don't need to do anything, + // as stdout and stderr are automatically captured by the in-IDE console. + // See https://developer.apple.com/forums/thread/705868 for details. + if (getenv("IDE_DISABLED_OS_ACTIVITY_DT_MODE")) { + return; + } + // Install the nslog script to redirect stdout/stderr if available. // Set the name of the python NSLog bootstrap script nslog_script = [ diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj index 5342c67..8612c16 100644 --- a/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj +++ b/{{ cookiecutter.format }}/{{ cookiecutter.formal_name }}.xcodeproj/project.pbxproj @@ -40,16 +40,6 @@ name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; - 609384A728C873E2005B2A5D /* Copy Python standard library */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = support; - dstSubfolderSpec = 7; - files = ( - ); - name = "Copy Python standard library"; - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -140,10 +130,9 @@ 0D354FC42551BFBA009178D1 /* Sources */, 0D354FC52551BFBA009178D1 /* Frameworks */, 0D354FC62551BFBA009178D1 /* Resources */, - 609384A728C873E2005B2A5D /* Copy Python standard library */, 0D7B44EB2556C8B800CBC44B /* Embed Foundation Extensions */, - 60A04BC128AF640400DAA9E5 /* Sign Python Binary Modules */, 6060E7742AF0B40500C04AE0 /* Embed Frameworks */, + 60A04BC128AF640400DAA9E5 /* Sign Python Binary Modules */, ); buildRules = ( ); @@ -161,7 +150,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1500; + LastUpgradeCheck = 1540; ORGANIZATIONNAME = "{{ cookiecutter.author }}"; TargetAttributes = { 0D354FC72551BFBA009178D1 = { @@ -272,6 +261,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(PROJECT_DIR)\"", @@ -337,6 +327,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(PROJECT_DIR)\"", From 26c12750295c68306594f748fcb941f890aa8174 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 30 Jul 2024 07:44:43 +0800 Subject: [PATCH 3/8] Tweaks to support final form of framework-based packages. --- {{ cookiecutter.format }}/briefcase.toml | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/{{ cookiecutter.format }}/briefcase.toml b/{{ cookiecutter.format }}/briefcase.toml index cd77ac6..277abb8 100644 --- a/{{ cookiecutter.format }}/briefcase.toml +++ b/{{ cookiecutter.format }}/briefcase.toml @@ -7,26 +7,13 @@ entitlements_path = "{{ cookiecutter.class_name }}/{{ cookiecutter.app_name }}.e support_path = "Support" {{ { - "3.8": "support_revision = 14", - "3.9": "support_revision = 12", - "3.10": "support_revision = 8", - "3.11": "support_revision = 3", - "3.12": "support_revision = 2", + "3.9": "support_revision = 13", + "3.10": "support_revision = 9", + "3.11": "support_revision = 4", + "3.12": "support_revision = 3", + "3.13": "support_revision = 0", }.get(cookiecutter.python_version|py_tag, "") }} cleanup_paths = [ - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/itcl*", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/__phello__", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/**/test", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/idlelib", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/tkinter", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/python*/turtledemo", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/tcl*", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/tk*", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/tdbc*", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/._lib*", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/libtcl*", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/libtk*", - "Support/Python.xcframework/macos-arm64_x86_64/Python.framework/Versions/*/lib/Tk.*", ] icon.16 = "{{ cookiecutter.class_name }}/Assets.xcassets/{{ cookiecutter.formal_name }}.appiconset/icon-16.png" icon.32 = "{{ cookiecutter.class_name }}/Assets.xcassets/{{ cookiecutter.formal_name }}.appiconset/icon-32.png" From 7e47a8120a5841a2edf727a927542254e63d3a7a Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 30 Jul 2024 07:47:14 +0800 Subject: [PATCH 4/8] Drop Python 3.8, add Python 3.13 support. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30a6be2..397f596 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,5 +38,5 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13-dev" ] framework: [ "toga", "pyside6", "pygame", "console" ] From 7f4d6b1a93448997cf79c0da7810c57c065a1902 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 30 Jul 2024 08:06:36 +0800 Subject: [PATCH 5/8] Add Briefcase target version. --- {{ cookiecutter.format }}/briefcase.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/{{ cookiecutter.format }}/briefcase.toml b/{{ cookiecutter.format }}/briefcase.toml index 277abb8..d058152 100644 --- a/{{ cookiecutter.format }}/briefcase.toml +++ b/{{ cookiecutter.format }}/briefcase.toml @@ -1,4 +1,8 @@ # Generated using Python {{ cookiecutter.python_version }} +[briefcase] +# This is the start of the framework-based support package era. +target_version = "0.3.20" + [paths] app_path = "{{ cookiecutter.class_name }}/app" app_packages_path = "{{ cookiecutter.class_name }}/app_packages" From 5c55be867ce24ed89bbc4e413161dec475183222 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 7 Aug 2024 12:06:54 +0800 Subject: [PATCH 6/8] Exclude Python 3.13 testing for GUI frameworks that don't support it. --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 397f596..eab98e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,3 +40,12 @@ jobs: matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13-dev" ] framework: [ "toga", "pyside6", "pygame", "console" ] + + exclude: + # PySide6 hasn't published 3.13 wheels. + - python-version: "3.13-dev" + framework: "pyside6" + + # Pygame hasn't published 3.13 wheels. + - python-version: "3.13-dev" + framework: "pygame" From d4786ce3ef524114ac7945fa912bebb59a7bfd22 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 7 Aug 2024 12:28:03 +0800 Subject: [PATCH 7/8] Temporarily fix the Briefcase branch when tagging binaries. --- .github/workflows/update-binary.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-binary.yml b/.github/workflows/update-binary.yml index feb51fb..41e6691 100644 --- a/.github/workflows/update-binary.yml +++ b/.github/workflows/update-binary.yml @@ -33,7 +33,10 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - python -m pip install git+https://github.com/beeware/briefcase.git + # TODO - Revert to the development version of Briefcase + # Use the development version of Briefcase + # python -m pip install git+https://github.com/beeware/briefcase.git + python -m pip install git+https://github.com/freakboy3742/briefcase.git@version-bumps - name: Generate Xcode App Template run: | From 1abe32035009be727f3f822e29db3bfcfa0fea48 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 9 Aug 2024 11:13:30 +0800 Subject: [PATCH 8/8] Factor out some common strings. --- .../{{ cookiecutter.class_name }}/main.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m b/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m index 0c3ec25..ad55e05 100644 --- a/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m +++ b/{{ cookiecutter.format }}/{{ cookiecutter.class_name }}/main.m @@ -33,6 +33,7 @@ int main(int argc, char *argv[]) { NSBundle *mainBundle; NSString *resourcePath; NSString *frameworksPath; + NSString *python_tag; NSString *python_home; NSString *app_module_name; NSString *path; @@ -86,7 +87,8 @@ int main(int argc, char *argv[]) { } // Set the home for the Python interpreter - python_home = [NSString stringWithFormat:@"%@/Python.framework/Versions/{{ cookiecutter.python_version|py_tag }}", frameworksPath, nil]; + python_tag = @"{{ cookiecutter.python_version|py_tag }}"; + python_home = [NSString stringWithFormat:@"%@/Python.framework/Versions/%@", frameworksPath, python_tag, nil]; debug_log(@"PythonHome: %@", python_home); wtmp_str = Py_DecodeLocale([python_home UTF8String], NULL); status = PyConfig_SetString(&config, &config.home, wtmp_str); @@ -130,7 +132,7 @@ int main(int argc, char *argv[]) { debug_log(@"PYTHONPATH:"); // The unpacked form of the stdlib - path = [NSString stringWithFormat:@"%@/Python.framework/Versions/{{ cookiecutter.python_version|py_tag }}/lib/python{{ cookiecutter.python_version|py_tag }}", frameworksPath, nil]; + path = [NSString stringWithFormat:@"%@/lib/python%@", python_home, python_tag, nil]; debug_log(@"- %@", path); wtmp_str = Py_DecodeLocale([path UTF8String], NULL); status = PyWideStringList_Append(&config.module_search_paths, wtmp_str); @@ -142,7 +144,7 @@ int main(int argc, char *argv[]) { PyMem_RawFree(wtmp_str); // Add the stdlib binary modules path - path = [NSString stringWithFormat:@"%@/Python.framework/Versions/{{ cookiecutter.python_version|py_tag }}/lib/python{{ cookiecutter.python_version|py_tag }}/lib-dynload", frameworksPath, nil]; + path = [NSString stringWithFormat:@"%@/lib/python%@/lib-dynload", python_home, python_tag, nil]; debug_log(@"- %@", path); wtmp_str = Py_DecodeLocale([path UTF8String], NULL); status = PyWideStringList_Append(&config.module_search_paths, wtmp_str);