|
3 | 3 | import sys
|
4 | 4 | from os import environ, path
|
5 | 5 | from sys import argv, path as sys_path
|
| 6 | +from textwrap import dedent |
6 | 7 |
|
7 | 8 | from setuptools import find_packages, setup
|
8 | 9 |
|
9 | 10 | import versioneer
|
10 | 11 |
|
11 | 12 |
|
| 13 | +def format_msg(text, *args, **kwargs): |
| 14 | + return dedent(text).strip(" \n").format(*args, **kwargs) |
| 15 | + |
| 16 | + |
12 | 17 | CURRENT_PYTHON = sys.version_info[:2]
|
13 | 18 | REQUIRED_PYTHON = (3, 6)
|
14 | 19 |
|
15 | 20 | # This check and everything above must remain compatible with older Python versions
|
16 | 21 | if CURRENT_PYTHON < REQUIRED_PYTHON:
|
17 |
| - # noinspection PyStringFormat |
18 |
| - sys.exit( |
19 |
| - """ |
20 |
| -======================================================== |
21 |
| - Unsupported Python version |
22 |
| -======================================================== |
23 |
| -This version of Streamlink requires at least Python {}.{}, |
24 |
| -but you're trying to install it on Python {}.{}. |
25 |
| -
|
26 |
| -This may be because you are using a version of pip that |
27 |
| -doesn't understand the python_requires classifier. |
28 |
| -Make sure you have pip >= 9.0 and setuptools >= 24.2 |
29 |
| - """ |
30 |
| - .strip(" \n") |
31 |
| - .format(*(REQUIRED_PYTHON + CURRENT_PYTHON)) |
32 |
| - ) |
| 22 | + sys.exit(format_msg(""" |
| 23 | + ======================================================== |
| 24 | + Unsupported Python version |
| 25 | + ======================================================== |
| 26 | + This version of Streamlink requires at least Python {}.{}, |
| 27 | + but you're trying to install it on Python {}.{}. |
| 28 | +
|
| 29 | + This may be because you are using a version of pip that |
| 30 | + doesn't understand the python_requires classifier. |
| 31 | + Make sure you have pip >= 9.0 and setuptools >= 24.2 |
| 32 | + """, *(REQUIRED_PYTHON + CURRENT_PYTHON))) |
| 33 | + |
| 34 | +# Explicitly disable running tests via setuptools |
| 35 | +if "test" in sys.argv: |
| 36 | + sys.exit(format_msg(""" |
| 37 | + Running `python setup.py test` has been deprecated since setuptools 41.5.0. |
| 38 | + Streamlink requires pytest for collecting and running tests, via one of these commands: |
| 39 | + `pytest` or `python -m pytest` (see the pytest docs for more infos about this) |
| 40 | + """)) |
33 | 41 |
|
34 | 42 |
|
35 | 43 | data_files = []
|
|
0 commit comments