1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
From: Kovid Goyal <kovid@kovidgoyal.net>
Date: Sat, 18 Dec 2021 12:26:52 +0530
Subject: Dont use distutils for the Test class
---
setup.py | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/setup.py b/setup.py
index 4a4f9da..a67c33f 100755
--- a/setup.py
+++ b/setup.py
@@ -4,10 +4,9 @@
import os
import sys
-from distutils.command.build import build as Build
from itertools import chain
-from setuptools import Extension, setup
+from setuptools import Extension, setup, Command
self_path = os.path.abspath(__file__)
base = os.path.dirname(self_path)
@@ -25,17 +24,26 @@ if not iswindows:
cargs.extend('-std=c99 -fvisibility=hidden'.split())
-class Test(Build):
+class Test(Command):
description = "run unit tests after in-place build"
+ user_options = []
+ sub_commands = [
+ ('build', None),
+ ]
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
def run(self):
- Build.run(self)
- if self.dry_run:
- self.announce('skipping "test" (dry run)')
- return
+ for cmd_name in self.get_sub_commands():
+ self.run_command(cmd_name)
import subprocess
- env = add_python_path(os.environ.copy(), self.build_lib)
+ build = self.get_finalized_command('build')
+ env = add_python_path(os.environ.copy(), build.build_lib)
print('\nrunning tests...')
sys.stdout.flush()
ret = subprocess.Popen([sys.executable] + TEST_COMMAND, env=env).wait()
|