setup.py: switch import to setuptools

Switch to standard setuptools import, add suggested entries to
pyproject.toml.

Remove the --clean argument.  As the comment suggests I'm sure there
is history here, but having setup.py remove parts of the package does
not seem like something required at this point.

Also clean up the imports to remove unused and group them together at
the top.
This commit is contained in:
Ian Wienand 2021-05-31 10:24:06 +10:00 committed by Val Lorentz
parent 49b9a9ab74
commit 37ba0ef7be
2 changed files with 6 additions and 45 deletions

View File

@ -1,3 +1,7 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.black]
line-length = 79

View File

@ -35,10 +35,10 @@ import os
import sys
import time
import warnings
import datetime
import tempfile
import subprocess
from setuptools import setup
warnings.filterwarnings('always', category=DeprecationWarning)
debug = '--debug' in sys.argv
@ -97,55 +97,12 @@ if sys.version_info < (3, 6, 0) \
sys.stderr.write('====================================================\n')
time.sleep(60)
import textwrap
clean = False
while '--clean' in sys.argv:
clean = True
sys.argv.remove('--clean')
import glob
import shutil
import os
plugins = [s for s in os.listdir('plugins') if
os.path.exists(os.path.join('plugins', s, 'plugin.py'))]
def normalizeWhitespace(s):
return ' '.join(s.split())
try:
from distutils.core import setup
from distutils.sysconfig import get_python_lib
except ImportError as e:
s = normalizeWhitespace("""Supybot requires the distutils package to
install. This package is normally included with Python, but for some
unfathomable reason, many distributions to take it out of standard Python
and put it in another package, usually caled 'python-dev' or python-devel'
or something similar. This is one of the dumbest things a distribution can
do, because it means that developers cannot rely on *STANDARD* Python
modules to be present on systems of that distribution. Complain to your
distribution, and loudly. If you how much of our time we've wasted telling
people to install what should be included by default with Python you'd
understand why we're unhappy about this. Anyway, to reiterate, install the
development package for Python that your distribution supplies.""")
sys.stderr.write(os.linesep*2)
sys.stderr.write(textwrap.fill(s))
sys.stderr.write(os.linesep*2)
sys.exit(-1)
if clean:
previousInstall = os.path.join(get_python_lib(), 'supybot')
if os.path.exists(previousInstall):
try:
print('Removing current installation.')
shutil.rmtree(previousInstall)
except Exception as e:
print('Couldn\'t remove former installation: %s' % e)
sys.exit(-1)
packages = ['supybot',
'supybot.locales',
'supybot.utils',