summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlen <alen@dotfiles.xyz>2025-01-19 04:30:23 +0400
committerAlen <alen@dotfiles.xyz>2025-01-19 04:30:23 +0400
commit841e09dc690550c0211ee901cbb4372d3b151c8c (patch)
tree8f8acb7da532aafd4c15a5ab2db933be6393bd00
parent0038af92298eb99fbf21922c9b025e6bf228880f (diff)
Fix IPython logging on newer Python versions
-rw-r--r--dot_ipython/profile_default/startup/20_logging.py10
1 files changed, 8 insertions, 2 deletions
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