From 37ba0ef7be4edbc6419d054be6a8d457316b1c79 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 31 May 2021 10:24:06 +1000 Subject: [PATCH] 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. --- pyproject.toml | 4 ++++ setup.py | 47 ++--------------------------------------------- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aefe4ade9..99248acc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + [tool.black] line-length = 79 diff --git a/setup.py b/setup.py index f32713426..1099e981d 100644 --- a/setup.py +++ b/setup.py @@ -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',