2012-07-01 02:48:52 +02:00
|
|
|
#!/usr/bin/env python
|
2024-01-23 17:32:29 +01:00
|
|
|
import sys
|
2021-11-14 14:23:26 +01:00
|
|
|
from os import path
|
2021-10-21 08:33:44 +02:00
|
|
|
from sys import argv, exit, version_info
|
2021-10-19 22:11:44 +02:00
|
|
|
from textwrap import dedent
|
2018-06-08 03:01:16 +02:00
|
|
|
|
2020-10-07 07:25:36 +02:00
|
|
|
|
2021-10-19 22:11:44 +02:00
|
|
|
def format_msg(text, *args, **kwargs):
|
|
|
|
return dedent(text).strip(" \n").format(*args, **kwargs)
|
|
|
|
|
|
|
|
|
2021-10-21 08:33:44 +02:00
|
|
|
CURRENT_PYTHON = version_info[:2]
|
2023-04-20 13:33:09 +02:00
|
|
|
REQUIRED_PYTHON = (3, 8)
|
2021-10-09 18:58:56 +02:00
|
|
|
|
|
|
|
# This check and everything above must remain compatible with older Python versions
|
|
|
|
if CURRENT_PYTHON < REQUIRED_PYTHON:
|
2021-10-21 08:33:44 +02:00
|
|
|
exit(format_msg("""
|
2021-10-19 22:11:44 +02:00
|
|
|
========================================================
|
|
|
|
Unsupported Python version
|
|
|
|
========================================================
|
|
|
|
This version of Streamlink requires at least Python {}.{},
|
|
|
|
but you're trying to install it on Python {}.{}.
|
|
|
|
|
|
|
|
This may be because you are using a version of pip that
|
|
|
|
doesn't understand the python_requires classifier.
|
|
|
|
Make sure you have pip >= 9.0 and setuptools >= 24.2
|
|
|
|
""", *(REQUIRED_PYTHON + CURRENT_PYTHON)))
|
|
|
|
|
|
|
|
# Explicitly disable running tests via setuptools
|
2021-10-21 08:33:44 +02:00
|
|
|
if "test" in argv:
|
|
|
|
exit(format_msg("""
|
2021-10-19 22:11:44 +02:00
|
|
|
Running `python setup.py test` has been deprecated since setuptools 41.5.0.
|
|
|
|
Streamlink requires pytest for collecting and running tests, via one of these commands:
|
|
|
|
`pytest` or `python -m pytest` (see the pytest docs for more infos about this)
|
|
|
|
"""))
|
2021-10-09 18:58:56 +02:00
|
|
|
|
|
|
|
|
2019-03-07 02:34:16 +01:00
|
|
|
def is_wheel_for_windows():
|
|
|
|
if "bdist_wheel" in argv:
|
|
|
|
names = ["win32", "win-amd64", "cygwin"]
|
|
|
|
length = len(argv)
|
|
|
|
for pos in range(argv.index("bdist_wheel") + 1, length):
|
|
|
|
if argv[pos] == "--plat-name" and pos + 1 < length:
|
|
|
|
return argv[pos + 1] in names
|
|
|
|
elif argv[pos][:12] == "--plat-name=":
|
|
|
|
return argv[pos][12:] in names
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
entry_points = {
|
|
|
|
"console_scripts": ["streamlink=streamlink_cli.main:main"],
|
|
|
|
}
|
|
|
|
|
|
|
|
if is_wheel_for_windows():
|
|
|
|
entry_points["gui_scripts"] = ["streamlinkw=streamlink_cli.main:main"]
|
|
|
|
|
|
|
|
|
2021-09-25 12:35:43 +02:00
|
|
|
# optional data files
|
2021-10-21 08:33:44 +02:00
|
|
|
data_files = [
|
2021-09-25 12:35:43 +02:00
|
|
|
# shell completions
|
|
|
|
# requires pre-built completion files via shtab (dev-requirements.txt)
|
|
|
|
# `./script/build-shell-completions.sh`
|
2021-11-15 17:53:55 +01:00
|
|
|
("share/bash-completion/completions", ["completions/bash/streamlink"]),
|
|
|
|
("share/zsh/site-functions", ["completions/zsh/_streamlink"]),
|
2021-09-25 12:35:43 +02:00
|
|
|
# man page
|
|
|
|
# requires pre-built man page file via sphinx (docs-requirements.txt)
|
|
|
|
# `make --directory=docs clean man`
|
2020-12-28 12:35:51 +01:00
|
|
|
("share/man/man1", ["docs/_build/man/streamlink.1"]),
|
|
|
|
]
|
2021-10-21 08:33:44 +02:00
|
|
|
data_files = [
|
|
|
|
(destdir, [file for file in srcfiles if path.exists(file)])
|
|
|
|
for destdir, srcfiles in data_files
|
|
|
|
]
|
|
|
|
|
2020-12-28 12:35:51 +01:00
|
|
|
|
2022-04-11 01:44:49 +02:00
|
|
|
if __name__ == "__main__":
|
2024-01-23 17:32:29 +01:00
|
|
|
sys.path.insert(0, path.dirname(__file__))
|
|
|
|
|
|
|
|
from build_backend.commands import cmdclass
|
|
|
|
from setuptools import setup
|
2023-10-22 17:17:55 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
# versioningit is only required when building from git (see pyproject.toml)
|
|
|
|
from versioningit import get_cmdclasses
|
|
|
|
except ImportError: # pragma: no cover
|
2024-01-23 17:32:29 +01:00
|
|
|
def get_cmdclasses(_): # type: ignore[misc]
|
|
|
|
return _
|
2022-04-11 01:44:49 +02:00
|
|
|
|
|
|
|
setup(
|
2024-01-23 17:32:29 +01:00
|
|
|
cmdclass=get_cmdclasses(cmdclass),
|
2022-04-11 01:44:49 +02:00
|
|
|
entry_points=entry_points,
|
|
|
|
data_files=data_files,
|
2023-10-22 17:17:55 +02:00
|
|
|
# version="", # static version string template, uncommented and substituted by versioningit's onbuild hook
|
2022-04-11 01:44:49 +02:00
|
|
|
)
|