-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
111 lines (102 loc) · 4.54 KB
/
setup.py
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
# Copyright 2017 Russell Anderson, Philip Starkey
#
# This file is part of autoscrub.
#
# autoscrub is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# autoscrub is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with autoscrub. If not, see <http://www.gnu.org/licenses/>.
import os
from setuptools import setup, find_packages
# base version
VERSION = '0.7.5'
# version information generated by our GitHub Action (see .github/workflows/release.yml)
CURRENT_TAG = os.environ.get('GHA_AUTOSCRUB_VERSION')
CURRENT_GIT_COMMIT_HASH = os.environ.get('GHA_AUTOSCRUB_GIT_COMMIT')
if CURRENT_TAG is not None:
print('GitHub Action debug: tag=', CURRENT_TAG)
if CURRENT_GIT_COMMIT_HASH is not None:
print('GitHub Action debug: git hash=', CURRENT_GIT_COMMIT_HASH)
# Modify the current version if we are building inside our GitHub action
if CURRENT_TAG is not None and CURRENT_TAG and CURRENT_TAG != 'refs/heads/master':
VERSION = CURRENT_TAG
elif CURRENT_GIT_COMMIT_HASH:
index = 0
try:
import requests
response = requests.get('https://test.pypi.org/pypi/autoscrub/json', timeout=2)
data = response.json()
if response.status_code == 200:
found = True
while found:
# PyPI converts '-' to '.' in version
if '{version}.dev{index}'.format(version=VERSION, index=index) not in data['releases']:
break
else:
index += 1
else:
print('GitHub Action debug: Error while getting JSON data from test PyPI. Status code was:', response.status_code)
except BaseException:
print('GitHub Action debug: Error while querying PyPI release information. Will guess -dev0 is the correct postfix.')
pass
# Despite PyPI converting '-' to '.', we want to use '-' in __version__.py as it matches semver specs.
VERSION += '-dev{}'.format(index)
# get directory of setup.py and the rest of the code for the library
code_dir = os.path.abspath(os.path.dirname(__file__))
# Auto generate a __version__ package for the package to import
with open(os.path.join(code_dir, 'autoscrub', '__version__.py'), 'w') as f:
f.write("__version__ = '%s'\n" % VERSION)
# Work around the fact that the readme.md file doesn't exist for users installing
# from the tar.gz format. However, in this case, they won't be uploading to PyPi
# so they don't need it!
try:
# Read in the readme file as the long description
with open(os.path.join(code_dir, 'readme.md')) as f:
long_description = f.read()
except BaseException:
long_description = ""
setup(
name='autoscrub',
version=VERSION.replace('+', '-'), # PyPI can't handle local versions, but we want something like this for TestPyPI
description='Hastens silent intervals of videos using FFmpeg',
url='https://github.com/philipstarkey/autoscrub',
project_urls={
"Documentation": "https://autoscrub.readthedocs.io",
"Source Code": "https://github.com/philipstarkey/autoscrub",
},
license='GPLv3',
long_description=long_description,
long_description_content_type='text/markdown',
author='Russell Anderson, Philip Starkey',
classifiers=['Development Status :: 4 - Beta',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Environment :: Console',
'Intended Audience :: Education',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Natural Language :: English',
],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4',
packages=find_packages(),
include_package_data=True,
install_requires=[
'click',
'six',
'requests',
'subprocess32;python_version<"3.2"',
],
entry_points='''
[console_scripts]
autoscrub=autoscrub.scripts.cli:cli
''',
)