mirror of https://github.com/streamlink/streamlink
packaging: removed the built in backports infavour of including them as dependencies when required (#355)
This commit is contained in:
parent
045b8fd20f
commit
7e93d0c8df
44
NOTICE
44
NOTICE
|
@ -48,50 +48,6 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
shutil_which License
|
||||
====================
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and
|
||||
the Individual or Organization ("Licensee") accessing and otherwise using Python
|
||||
3.5.1 software in source or binary form and its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
distribute, and otherwise use Python 3.5.1 alone or in any derivative
|
||||
version, provided, however, that PSF's License Agreement and PSF's notice of
|
||||
copyright, i.e., "Copyright © 2001-2016 Python Software Foundation; All Rights
|
||||
Reserved" are retained in Python 3.5.1 alone or in any derivative version
|
||||
prepared by Licensee.
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on or
|
||||
incorporates Python 3.5.1 or any part thereof, and wants to make the
|
||||
derivative work available to others as provided herein, then Licensee hereby
|
||||
agrees to include in any such work a brief summary of the changes made to Python
|
||||
3.5.1.
|
||||
|
||||
4. PSF is making Python 3.5.1 available to Licensee on an "AS IS" basis.
|
||||
PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF
|
||||
EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
|
||||
WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
|
||||
USE OF PYTHON 3.5.1 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.5.1
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
|
||||
MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.5.1, OR ANY DERIVATIVE
|
||||
THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material breach of
|
||||
its terms and conditions.
|
||||
|
||||
7. Nothing in this License Agreement shall be deemed to create any relationship
|
||||
of agency, partnership, or joint venture between PSF and Licensee. This License
|
||||
Agreement does not grant permission to use PSF trademarks or trade name in a
|
||||
trademark sense to endorse or promote products or services of Licensee, or any
|
||||
third party.
|
||||
|
||||
8. By copying, installing or otherwise using Python 3.5.1, Licensee agrees
|
||||
to be bound by the terms and conditions of this License Agreement.
|
||||
|
||||
doggo.ico License
|
||||
=================
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
|
25
setup.py
25
setup.py
|
@ -2,22 +2,10 @@
|
|||
|
||||
from os import environ
|
||||
from os.path import abspath, dirname, join
|
||||
from setuptools import setup
|
||||
from setuptools import setup, find_packages
|
||||
from sys import version_info, path as sys_path
|
||||
|
||||
deps = []
|
||||
packages = [
|
||||
"streamlink",
|
||||
"streamlink.stream",
|
||||
"streamlink.plugin",
|
||||
"streamlink.plugin.api",
|
||||
"streamlink.plugins",
|
||||
"streamlink.packages",
|
||||
"streamlink.packages.flashmedia",
|
||||
"streamlink_cli",
|
||||
"streamlink_cli.packages",
|
||||
"streamlink_cli.utils"
|
||||
]
|
||||
|
||||
if version_info[0] == 2:
|
||||
# Require backport of concurrent.futures on Python 2
|
||||
|
@ -37,8 +25,13 @@ if (version_info[0] == 2 and version_info[1] == 6 and version_info[2] < 3):
|
|||
else:
|
||||
deps.append("requests>=1.0,!=2.12.0,!=2.12.1,<3.0")
|
||||
|
||||
# this version of pycryptodome is known to work and has a Windows wheel for py2.7, py3.3-3.5
|
||||
deps.append("pycryptodome==3.4.3")
|
||||
# this version of pycryptodome is known to work and has a Windows wheel for py2.7, py3.3-3.6
|
||||
deps.append("pycryptodome>=3.4.3,<4")
|
||||
|
||||
# shutil.get_terminal_size and which were added in Python 3.3
|
||||
if version_info[0] == 2:
|
||||
deps.append("backports.shutil_which")
|
||||
deps.append("backports.shutil_get_terminal_size")
|
||||
|
||||
# When we build an egg for the Win32 bootstrap we don't want dependency
|
||||
# information built into it.
|
||||
|
@ -57,7 +50,7 @@ setup(name="streamlink",
|
|||
author="Streamlink",
|
||||
author_email="charlie@charliedrage.com", # temp until we have a mailing list / global email
|
||||
license="Simplified BSD",
|
||||
packages=packages,
|
||||
packages=find_packages("src"),
|
||||
package_dir={"": "src"},
|
||||
entry_points={
|
||||
"console_scripts": ["streamlink=streamlink_cli.main:main"]
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
"""Backport of shutil.which from Python 3.5
|
||||
|
||||
The function is included unmodified from Python stdlib 3.5.1,
|
||||
and is (C) Python
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
__version__ = '3.5.1'
|
||||
|
||||
def backport_which(cmd, mode=os.F_OK | os.X_OK, path=None):
|
||||
"""Given a command, mode, and a PATH string, return the path which
|
||||
conforms to the given mode on the PATH, or None if there is no such
|
||||
file.
|
||||
|
||||
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
|
||||
of os.environ.get("PATH"), or can be overridden with a custom search
|
||||
path.
|
||||
|
||||
"""
|
||||
# Check that a given file can be accessed with the correct mode.
|
||||
# Additionally check that `file` is not a directory, as on Windows
|
||||
# directories pass the os.access check.
|
||||
def _access_check(fn, mode):
|
||||
return (os.path.exists(fn) and os.access(fn, mode)
|
||||
and not os.path.isdir(fn))
|
||||
|
||||
# If we're given a path with a directory part, look it up directly rather
|
||||
# than referring to PATH directories. This includes checking relative to the
|
||||
# current directory, e.g. ./script
|
||||
if os.path.dirname(cmd):
|
||||
if _access_check(cmd, mode):
|
||||
return cmd
|
||||
return None
|
||||
|
||||
if path is None:
|
||||
path = os.environ.get("PATH", os.defpath)
|
||||
if not path:
|
||||
return None
|
||||
path = path.split(os.pathsep)
|
||||
|
||||
if sys.platform == "win32":
|
||||
# The current directory takes precedence on Windows.
|
||||
if not os.curdir in path:
|
||||
path.insert(0, os.curdir)
|
||||
|
||||
# PATHEXT is necessary to check on Windows.
|
||||
pathext = os.environ.get("PATHEXT", "").split(os.pathsep)
|
||||
# See if the given file matches any of the expected path extensions.
|
||||
# This will allow us to short circuit when given "python.exe".
|
||||
# If it does match, only test that one, otherwise we have to try
|
||||
# others.
|
||||
if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
|
||||
files = [cmd]
|
||||
else:
|
||||
files = [cmd + ext for ext in pathext]
|
||||
else:
|
||||
# On other platforms you don't have things like PATHEXT to tell you
|
||||
# what file suffixes are executable, so just pass on cmd as-is.
|
||||
files = [cmd]
|
||||
|
||||
seen = set()
|
||||
for dir in path:
|
||||
normdir = os.path.normcase(dir)
|
||||
if not normdir in seen:
|
||||
seen.add(normdir)
|
||||
for thefile in files:
|
||||
name = os.path.join(dir, thefile)
|
||||
if _access_check(name, mode):
|
||||
return name
|
||||
return None
|
||||
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
which = backport_which
|
|
@ -3,7 +3,10 @@ from .wrappers import StreamIOThreadWrapper
|
|||
from ..compat import str
|
||||
from ..exceptions import StreamError
|
||||
from ..packages import pbs as sh
|
||||
from ..packages.shutil_which import which
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from backports.shutil_which import which
|
||||
|
||||
import os
|
||||
import time
|
||||
|
|
|
@ -12,7 +12,7 @@ if is_py2:
|
|||
file = file
|
||||
_find_unsafe = re.compile(r"[^\w@%+=:,./-]").search
|
||||
|
||||
from .packages.shutil_backport import get_terminal_size
|
||||
from backports.shutil_get_terminal_size import get_terminal_size
|
||||
|
||||
elif is_py3:
|
||||
input = input
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
"""This is a backport of shutil.get_terminal_size from Python 3.
|
||||
|
||||
The original implementation is in C, but here we use the ctypes and
|
||||
fcntl modules to create a pure Python version of os.get_terminal_size.
|
||||
"""
|
||||
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
terminal_size = namedtuple("terminal_size", "columns lines")
|
||||
|
||||
|
||||
try:
|
||||
from ctypes import windll, create_string_buffer
|
||||
|
||||
_handles = {
|
||||
0: windll.kernel32.GetStdHandle(-10),
|
||||
1: windll.kernel32.GetStdHandle(-11),
|
||||
2: windll.kernel32.GetStdHandle(-12),
|
||||
}
|
||||
|
||||
def _get_terminal_size(fd):
|
||||
columns = lines = 0
|
||||
|
||||
try:
|
||||
handle = _handles[fd]
|
||||
csbi = create_string_buffer(22)
|
||||
res = windll.kernel32.GetConsoleScreenBufferInfo(handle, csbi)
|
||||
if res:
|
||||
res = struct.unpack("hhhhHhhhhhh", csbi.raw)
|
||||
left, top, right, bottom = res[5:9]
|
||||
columns = right - left + 1
|
||||
lines = bottom - top + 1
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return columns, lines
|
||||
|
||||
except ImportError:
|
||||
import fcntl
|
||||
import termios
|
||||
|
||||
def _get_terminal_size(fd):
|
||||
try:
|
||||
res = fcntl.ioctl(fd, termios.TIOCGWINSZ, b"\x00" * 4)
|
||||
lines, columns = struct.unpack("hh", res)
|
||||
except Exception:
|
||||
columns = lines = 0
|
||||
|
||||
return columns, lines
|
||||
|
||||
|
||||
def get_terminal_size(fallback=(80, 24)):
|
||||
"""Get the size of the terminal window.
|
||||
|
||||
For each of the two dimensions, the environment variable, COLUMNS
|
||||
and LINES respectively, is checked. If the variable is defined and
|
||||
the value is a positive integer, it is used.
|
||||
|
||||
When COLUMNS or LINES is not defined, which is the common case,
|
||||
the terminal connected to sys.__stdout__ is queried
|
||||
by invoking os.get_terminal_size.
|
||||
|
||||
If the terminal size cannot be successfully queried, either because
|
||||
the system doesn't support querying, or because we are not
|
||||
connected to a terminal, the value given in fallback parameter
|
||||
is used. Fallback defaults to (80, 24) which is the default
|
||||
size used by many terminal emulators.
|
||||
|
||||
The value returned is a named tuple of type os.terminal_size.
|
||||
"""
|
||||
# Attempt to use the environment first
|
||||
try:
|
||||
columns = int(os.environ["COLUMNS"])
|
||||
except (KeyError, ValueError):
|
||||
columns = 0
|
||||
|
||||
try:
|
||||
lines = int(os.environ["LINES"])
|
||||
except (KeyError, ValueError):
|
||||
lines = 0
|
||||
|
||||
# Only query if necessary
|
||||
if columns <= 0 or lines <= 0:
|
||||
try:
|
||||
columns, lines = _get_terminal_size(sys.__stdout__.fileno())
|
||||
except (NameError, OSError):
|
||||
pass
|
||||
|
||||
# Use fallback as last resort
|
||||
if columns <= 0 and lines <= 0:
|
||||
columns, lines = fallback
|
||||
|
||||
return terminal_size(columns, lines)
|
||||
|
Loading…
Reference in New Issue