aboutsummaryrefslogtreecommitdiff
path: root/setup.py
blob: 2e7653278eeee6357c7f1615b0fe9deb23495d7c (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python

import os
import shutil
import subprocess
from distutils import log
from distutils.core import Command
from setuptools.command.test import test
from setuptools import setup, find_packages


class TestsWithCoverage(test):

    description = "run unit tests with coverage"

    def run(self):
        from coverage import Coverage

        cov = Coverage(source=self.distribution.packages)
        cov.start()

        super().run()

        cov.stop()
        cov.xml_report()
        cov.html_report()


class PyPiReleaseCommand(Command):

    user_options = []
    description = "build and release artifacts to pypi"

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def venv_run(self, cmd, *args):
        subprocess.check_call((os.path.join(".release/py3/bin", cmd),) + args)

    def make_release_tree(self):
        if not os.path.exists(".release"):
            log.info("Creating temp release tree")
            os.mkdir(".release")

    def configure_environment(self):
        log.info("Configuring release environment")
        subprocess.check_call(["python3", "-m", "venv", ".release/py3"])
        self.venv_run("pip", "install", "-U",
                      "pip", "setuptools", "virtualenv", "twine")

    def build_py3_artifact(self):
        log.info("Building Python 3 Artifact")
        self.venv_run("python", "setup.py",
                      "release", "bdist_wheel", "--python-tag", "py3")

    def build_sdist_artifact(self):
        log.info("Building Source Dist Artifact")
        self.venv_run("python", "setup.py", "sdist")

    def upload_artifacts(self):
        log.info("Uploading artifacts to PyPi")
        self.venv_run("twine", "upload", "dist/*")

    def cleanup(self):
        log.info("Cleaning up temp release tree")
        shutil.rmtree(".release")

    def run(self):
        try:
            self.make_release_tree()
            self.configure_environment()
            self.build_py3_artifact()
            self.build_sdist_artifact()
            self.upload_artifacts()
        finally:
            self.cleanup()


setup(
    name="pydora",
    version="2.0.0",
    description="Python wrapper for Pandora API",
    long_description=open("README.rst", "r").read(),
    author="Mike Crute",
    author_email="mike@crute.us",
    url="https://github.com/mcrute/pydora",
    test_suite="tests.discover_suite",
    packages=find_packages(exclude=["tests", "tests.*"]),
    cmdclass={
        "test": TestsWithCoverage,
        "pypi_release": PyPiReleaseCommand,
    },
    entry_points={
        "console_scripts": [
            "pydora = pydora.player:main",
            "pydora-configure = pydora.configure:main",
        ],
    },
    setup_requires=[
        "wheel",
        "flake8>=3.3",
        "setuptools>=36.0.1",
        "coverage>=4.1,<5",
    ],
    install_requires=[
        "requests>=2,<3",
        "blowfish>=0.6.1,<1.0",
    ],
    python_requires=">=3.5",
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Environment :: Console",
        "Intended Audience :: Developers",
        "Intended Audience :: End Users/Desktop",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3 :: Only",
        "Topic :: Internet :: WWW/HTTP",
        "Topic :: Multimedia :: Sound/Audio :: Players",
    ]
)