Skip to content

Commit cbd2b31

Browse files
committed
Add error message in case setuptools is not installed.
1 parent 37ba0ef commit cbd2b31

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

setup.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,28 @@
3434
import os
3535
import sys
3636
import time
37+
import textwrap
3738
import warnings
3839
import subprocess
3940

40-
from setuptools import setup
41+
def normalizeWhitespace(s):
42+
return ' '.join(s.split())
43+
44+
try:
45+
from setuptools import setup
46+
except ImportError:
47+
s = normalizeWhitespace("""Limnoria requires the setuptools package to
48+
install. This package is pretty standard, and often installed alongside
49+
Python, but it is missing on your system.
50+
Try installing it with your package manager, it is usually called
51+
'python3-setuptools'. If that does not work, try installing python3-pip
52+
instead, either with your package manager or by following these
53+
instructions: https://pip.pypa.io/en/stable/installation/ (replace
54+
'python' with 'python3' in all the commands)""")
55+
sys.stderr.write(os.linesep*2)
56+
sys.stderr.write(textwrap.fill(s))
57+
sys.stderr.write(os.linesep*2)
58+
sys.exit(-1)
4159

4260
warnings.filterwarnings('always', category=DeprecationWarning)
4361

@@ -100,9 +118,6 @@
100118
plugins = [s for s in os.listdir('plugins') if
101119
os.path.exists(os.path.join('plugins', s, 'plugin.py'))]
102120

103-
def normalizeWhitespace(s):
104-
return ' '.join(s.split())
105-
106121
packages = ['supybot',
107122
'supybot.locales',
108123
'supybot.utils',

0 commit comments

Comments
 (0)