Skip to content

Commit

Permalink
Move macOS bundle setup logic to conf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiw committed Jan 19, 2025
1 parent abf00be commit 5c0f123
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
20 changes: 2 additions & 18 deletions bin/meld
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ if uninstalled:
meld.conf.uninstalled()
elif frozen:
meld.conf.frozen()
elif "Contents/MacOS" in sys.executable:
meld.conf.setup_macos_application_bundle()

# TODO: Possibly move to elib.intl
import gettext # noqa: E402, I100
Expand Down Expand Up @@ -410,23 +412,6 @@ def setup_glib_logging():
pass


def setup_macos_application_bundle():
# When running from inside an application bundle, adjust paths relative
# to the location of the main binary.
if "Contents/MacOS" in sys.executable:
meld.conf.DATADIR = os.path.abspath(
os.path.join(
os.path.dirname(os.path.realpath(sys.executable)),
"../Resources/share/meld"
)
)
meld.conf.LOCALEDIR = os.path.abspath(
os.path.join(
os.path.dirname(meld.conf.DATADIR), "locale"
)
)


def environment_hacks():
# MSYSTEM is set by git, and confuses our
# msys-packaged version's library search path -
Expand Down Expand Up @@ -466,7 +451,6 @@ def run_application():


def main():
setup_macos_application_bundle()
environment_hacks()
setup_logging()
disable_stdout_buffering()
Expand Down
12 changes: 12 additions & 0 deletions meld/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ def uninstalled():

resource_path = melddir / "meld" / "resources"
os.environ['G_RESOURCE_OVERLAYS'] = f'{RESOURCE_BASE}={resource_path}'


def setup_macos_application_bundle():
global DATADIR, LOCALEDIR, DATADIR_IS_UNINSTALLED

# When running from inside an application bundle, adjust paths relative
# to the location of the main binary.
base_dir = Path(sys.executable).resolve().parent.parent
share_dir = base_dir / "Resources" / "share"
DATADIR = share_dir / "meld"
LOCALEDIR = share_dir / "locale"
DATADIR_IS_UNINSTALLED = True

0 comments on commit 5c0f123

Please sign in to comment.