From 841e09dc690550c0211ee901cbb4372d3b151c8c Mon Sep 17 00:00:00 2001 From: Alen Date: Sun, 19 Jan 2025 04:30:23 +0400 Subject: Fix IPython logging on newer Python versions --- dot_ipython/profile_default/startup/20_logging.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'dot_ipython/profile_default/startup') diff --git a/dot_ipython/profile_default/startup/20_logging.py b/dot_ipython/profile_default/startup/20_logging.py index 86ef226..75a89b1 100644 --- a/dot_ipython/profile_default/startup/20_logging.py +++ b/dot_ipython/profile_default/startup/20_logging.py @@ -6,9 +6,15 @@ import logging def _setup() -> logging.Logger: import logging import os - import setuptools import glob + try: + import setuptools + except ModuleNotFoundError: + found_packages = [] + else: + found_packages = setuptools.find_packages() + # Determine log levels project_level = getattr(logging, os.environ.get("LOG_LEVEL", "INFO")) root_level = getattr(logging, os.environ.get("ROOT_LOG_LEVEL", "WARNING")) @@ -18,7 +24,7 @@ def _setup() -> logging.Logger: project_names = ( ["__main__", "repl"] + [x[:-3] for x in glob.glob("*.py")] - + setuptools.find_packages() + + found_packages ) # Set logging levels -- cgit 1.4.1-2-gfad0