File size: 4,630 Bytes
550665c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python3
import subprocess

from setuptools import setup, find_packages, Command
from shutil import rmtree
import os
import sys

here = os.path.abspath(os.path.dirname(__file__))

VERSION = '2.3.0'


class UploadCommand(Command):
    """Support setup.py upload."""

    description = 'Build and publish the package.'
    user_options = []

    @staticmethod
    def status(s):
        """Prints things in bold."""
        print('\033[1m{0}\033[0m'.format(s))

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        try:
            self.status('Removing previous builds...')
            rmtree(os.path.join(here, 'dist'))
        except OSError:
            pass

        self.status('Building Source and Wheel (universal) distribution...')
        error = os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
        if error:
            sys.exit()

        self.status('Uploading the package to PyPi via Twine...')
        error = os.system('twine upload dist/*')
        if error:
            sys.exit()

        self.status('Pushing git tags...')
        os.system('git tag v{0}'.format(VERSION))
        os.system('git push --tags')

        sys.exit()


class BuildDoc(Command):
    user_options = []

    def initialize_options(self) -> None:
        pass

    def finalize_options(self) -> None:
        pass

    def run(self):
        output_path = 'docs/html'
        changed_files = []
        cmd = [
            'sphinx-build',
            'docs/source', output_path,
            '--builder', 'html',
            '--define', f'version={VERSION}',
            '--verbose'
        ]
        with subprocess.Popen(
                cmd,
                stdout=subprocess.PIPE,
                bufsize=1,
                universal_newlines=True
        ) as p:
            for line in p.stdout:
                print(line, end='')
                if line.startswith('reading sources... ['):
                    file_name = line.rsplit(maxsplit=1)[1]
                    if file_name:
                        changed_files.append(file_name + '.html')

        index_path = os.path.join(os.getcwd(), output_path, 'index.html')
        print('\nIndex:')
        print(f'file://{index_path}')

        if changed_files:
            print('Update pages:')
            for cf in changed_files:
                f_path = os.path.join(os.getcwd(), output_path, cf)
                print(cf, f'file://{f_path}')


with open('README.rst') as f:
    long_description = ''.join(f.readlines())

DOCS_REQUIRES = [
    'sphinx',
    'sphinx-rtd-theme',
]

TEST_REQUIRES = [
    'setuptools',
    'pytest',
    'pytest-pep8',
    'pytest-cov',
    'pyfakefs',
    'flake8',
    'pep8-naming',
    'twine',
    'tox'
]

setup(
    name='gcsa',
    version=VERSION,
    keywords='python conference calendar hangouts python-library event conferences google-calendar pip recurrence '
             'google-calendar-api attendee gcsa',
    description='Simple API for Google Calendar management',
    long_description=long_description,
    author='Yevhen Kuzmovych',
    author_email='[email protected]',
    license='MIT',
    url='https://github.com/kuzmoyev/google-calendar-simple-api',
    zip_safe=False,
    packages=find_packages(exclude=("tests", "tests.*")),
    install_requires=[
        "tzlocal>=4,<5",
        "google-api-python-client>=1.8",
        "google-auth-httplib2>=0.0.4",
        "google-auth-oauthlib>=0.5,<2.0",
        "python-dateutil>=2.7",
        "beautiful_date>=2.0.0",
    ],
    extras_require={
        'dev': [
            *TEST_REQUIRES,
            *DOCS_REQUIRES
        ],
        'tests': TEST_REQUIRES,
        'docs': DOCS_REQUIRES
    },
    classifiers=[
        'License :: OSI Approved :: MIT License',
        'Natural Language :: English',
        'Programming Language :: Python',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
        'Programming Language :: Python :: 3.10',
        'Programming Language :: Python :: 3.11',
        'Programming Language :: Python :: 3.12',
    ],
    cmdclass={
        'upload': UploadCommand,
        'docs': BuildDoc,
    }
)