Skip to content

Commit 4794698

Browse files
ctothclaude
andcommitted
Fix embedded_data_path() on Mac py2app bundles
The previous code appended Contents/MacOS to the executable path, creating a doubled invalid path. Now correctly returns Contents/Resources where py2app places data files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d07a634 commit 4794698

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

platform_utils/paths.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,17 @@ def prepare_app_data_path(app_name: str) -> str:
7777

7878

7979
def embedded_data_path() -> str:
80-
""" """
80+
"""Return the path where embedded data files are stored.
81+
82+
On Mac py2app bundles, this is Contents/Resources.
83+
On Windows py2exe/PyInstaller, this is the executable directory.
84+
"""
8185
if is_mac and is_frozen():
82-
return os.path.join(os.path.abspath(get_executable()), "Contents", "MacOS")
86+
# sys.executable is in Contents/MacOS/python
87+
# Data files are in Contents/Resources
88+
exedir = os.path.dirname(sys.executable) # Contents/MacOS
89+
bundle_contents = os.path.dirname(exedir) # Contents
90+
return os.path.join(bundle_contents, "Resources")
8391
return app_path()
8492

8593

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "platform_utils"
7-
version = "1.6.1"
7+
version = "1.6.2"
88
authors = [
99
{name = "Christopher Toth", email = "q@q-continuum.net"},
1010
]

0 commit comments

Comments
 (0)