From e1f246741521be46d72bd48b7471b100bbc38b3f Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 12 Aug 2025 02:26:47 -0400 Subject: [PATCH] Fix launcher path logic for proper system/local separation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add runtime detection of installation type based on launcher location - Local installations (~/.local/bin) now correctly load from ~/.local/lib/python*/site-packages - System installations (/usr/bin) load from /usr/lib/python*/site-packages - Source directory execution continues to work from development tree - Restores clear separation between system and local installations like autotools had 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/cthulhu.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/cthulhu.py b/src/cthulhu.py index 7943f31..07eb7af 100644 --- a/src/cthulhu.py +++ b/src/cthulhu.py @@ -42,19 +42,25 @@ def setup_paths(): # Running from source directory sys.path.insert(0, os.path.dirname(currentDir)) pythondir = currentDir + datadir = currentDir else: - # Running installed - sys.prefix = '/usr' - pythondir = os.path.join(sys.prefix, 'lib', f'python{sys.version_info.major}.{sys.version_info.minor}', 'site-packages') + # Running installed - determine if local or system based on actual path + if currentDir.startswith(os.path.expanduser('~/.local')): + # Local installation (~/.local/bin/cthulhu) + prefix = os.path.expanduser('~/.local') + pythondir = os.path.join(prefix, 'lib', f'python{sys.version_info.major}.{sys.version_info.minor}', 'site-packages') + datadir = os.path.join(prefix, 'share', 'cthulhu') + else: + # System installation (/usr/bin/cthulhu) + prefix = '/usr' + pythondir = os.path.join(prefix, 'lib', f'python{sys.version_info.major}.{sys.version_info.minor}', 'site-packages') + datadir = os.path.join(prefix, 'share', 'cthulhu') sys.path.insert(1, pythondir) # Set environment variables for resource paths if 'CTHULHU_DATA_DIR' not in os.environ: - if os.path.exists(os.path.join(currentDir, 'plugins')): - os.environ['CTHULHU_DATA_DIR'] = currentDir - else: - os.environ['CTHULHU_DATA_DIR'] = os.path.join(sys.prefix, 'share', 'cthulhu') + os.environ['CTHULHU_DATA_DIR'] = datadir # Set up paths before importing Cthulhu modules setup_paths()