Skip to content

Commit c1f0385

Browse files
committed
Do not fail if curtsies is not available (fixes bpython#978)
Also delay imports of dependencies only used to log the version.
1 parent e1ca452 commit c1f0385

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

bpython/args.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,13 @@
3030
"""
3131

3232
import argparse
33-
from typing import Tuple, List, Optional, NoReturn, Callable
3433
import code
35-
import curtsies
36-
import cwcwidth
37-
import greenlet
3834
import importlib.util
3935
import logging
4036
import os
41-
import pygments
42-
import requests
4337
import sys
44-
import xdg
4538
from pathlib import Path
39+
from typing import Tuple, List, Optional, NoReturn, Callable
4640

4741
from . import __version__, __copyright__
4842
from .config import default_config_path, Config
@@ -205,10 +199,22 @@ def callback(group):
205199
bpython_logger.addHandler(logging.NullHandler())
206200
curtsies_logger.addHandler(logging.NullHandler())
207201

202+
import cwcwidth
203+
import greenlet
204+
import pygments
205+
import requests
206+
import xdg
207+
208208
logger.info("Starting bpython %s", __version__)
209209
logger.info("Python %s: %s", sys.executable, sys.version_info)
210210
# versions of required dependencies
211-
logger.info("curtsies: %s", curtsies.__version__)
211+
try:
212+
import curtsies
213+
214+
logger.info("curtsies: %s", curtsies.__version__)
215+
except ImportError:
216+
# may happen on Windows
217+
logger.info("curtsies: not available")
212218
logger.info("cwcwidth: %s", cwcwidth.__version__)
213219
logger.info("greenlet: %s", greenlet.__version__)
214220
logger.info("pygments: %s", pygments.__version__) # type: ignore

0 commit comments

Comments
 (0)