1#!/usr/bin/env python 2 3import io 4import re 5import sys 6 7from setuptools import setup 8from setuptools.command.test import test as TestCommand 9 10 11class PyTest(TestCommand): 12 # Code from here: https://pytest.org/latest/goodpractises.html 13 14 def finalize_options(self): 15 TestCommand.finalize_options(self) 16 # We don't run integration tests which need an actual Sonos device 17 self.test_args = ["-m", "not integration"] 18 self.test_suite = True 19 20 def run_tests(self): 21 # Import here, because outside the eggs aren't loaded 22 import pytest 23 24 errno = pytest.main(self.test_args) 25 sys.exit(errno) 26 27 28src = open("soco/__init__.py", encoding="utf-8").read() 29metadata = dict(re.findall('__([a-z]+)__ = "([^"]+)"', src)) 30docstrings = re.findall('"""(.*?)"""', src, re.MULTILINE | re.DOTALL) 31 32NAME = "soco" 33 34PACKAGES = ( 35 "soco", 36 "soco.plugins", 37 "soco.music_services", 38) 39 40TEST_REQUIREMENTS = list(open("requirements-dev.txt")) 41AUTHOR_EMAIL = metadata["author"] 42VERSION = metadata["version"] 43WEBSITE = metadata["website"] 44LICENSE = metadata["license"] 45DESCRIPTION = docstrings[0] 46 47CLASSIFIERS = [ 48 "Development Status :: 4 - Beta", 49 "Intended Audience :: Developers", 50 "License :: OSI Approved :: MIT License", 51 "Operating System :: OS Independent", 52 "Programming Language :: Python :: 3.5", 53 "Programming Language :: Python :: 3.6", 54 "Programming Language :: Python :: 3.7", 55 "Programming Language :: Python :: 3.8", 56 "Programming Language :: Python :: 3.9", 57 "Programming Language :: Python :: 3 :: Only", 58 "Programming Language :: Python :: Implementation :: CPython", 59 "Programming Language :: Python :: Implementation :: PyPy", 60 "Topic :: Home Automation", 61 "Topic :: Multimedia :: Sound/Audio", 62 "Topic :: Multimedia :: Sound/Audio :: Players", 63 "Topic :: Software Development :: Libraries :: Python Modules", 64] 65 66PYTHON_REQUIRES = ">=3.5" 67 68with open("README.rst", encoding="utf-8") as file: 69 LONG_DESCRIPTION = file.read() 70 71# Extract name and e-mail ("Firstname Lastname <mail@example.org>") 72AUTHOR, EMAIL = re.match(r"(.*) <(.*)>", AUTHOR_EMAIL).groups() 73 74REQUIREMENTS = list(open("requirements.txt")) 75 76# See https://github.com/SoCo/SoCo/issues/819 77EXTRAS_REQUIRE = {"events_asyncio": ["aiohttp"]} 78 79setup( 80 name=NAME, 81 version=VERSION, 82 description=DESCRIPTION, 83 author=AUTHOR, 84 author_email=EMAIL, 85 license=LICENSE, 86 url=WEBSITE, 87 packages=PACKAGES, 88 install_requires=REQUIREMENTS, 89 extras_require=EXTRAS_REQUIRE, 90 tests_require=TEST_REQUIREMENTS, 91 long_description=LONG_DESCRIPTION, 92 cmdclass={"test": PyTest}, 93 classifiers=CLASSIFIERS, 94 python_requires=PYTHON_REQUIRES, 95) 96