From 694727a513f5598705903bc8556143b6b94dd8fc Mon Sep 17 00:00:00 2001 From: David Ketcheson Date: Thu, 2 Nov 2023 11:59:46 +0300 Subject: [PATCH] Properly manage import directories for editable and non-editable installs. --- src/pyclaw/__init__.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/pyclaw/__init__.py b/src/pyclaw/__init__.py index 6c9a62ea..ec472353 100644 --- a/src/pyclaw/__init__.py +++ b/src/pyclaw/__init__.py @@ -4,19 +4,14 @@ import os import logging, logging.config - -CLAW_dir = os.environ.get('CLAW') -if CLAW_dir == None: - raise Exception('You must set the CLAW environment to use an editable install.') -# To get pyclaw.examples -_path = os.path.dirname(os.path.join(CLAW_dir, 'clawpack')) -if os.path.isdir(_path): - __path__.append(_path) -del _path +_init = os.path.abspath(__file__) +_root = os.path.dirname(os.path.dirname(os.path.dirname(_init))) +if os.path.isdir(_root): + __path__.append(_root) # Default logging configuration file _DEFAULT_LOG_CONFIG_PATH = os.path.join(os.path.dirname(__file__),'log.config') -del os +del os, _init, _root # Setup loggers logging.config.fileConfig(_DEFAULT_LOG_CONFIG_PATH, disable_existing_loggers=False)