-
Notifications
You must be signed in to change notification settings - Fork 63
/
setup.py
126 lines (98 loc) · 3.41 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import io
import os
import re
import sys
from shutil import rmtree
from setuptools import find_packages, setup, Command
# Package arguments
PACKAGE_NAME = "keras_efficientnets"
SHORT_DESCRIPION = "Keras implementation of EfficientNets of any configuration."
URL = "https://github.com/titu1994/keras-efficientnets"
LICENCE = 'MIT'
# Extra requirements and configs
EXTRA_REQUIREMENTS = {
'test': ['pytest', 'pillow'],
}
REQUIRED_PYTHON = ">=3.0.0" # Can be None, or a string value
# Signature arguments
AUTHOR = "Somshubra Majumdar"
EMAIL = "titu1994@gmail.com"
###############################################################
base_path = os.path.abspath(os.path.dirname(__file__))
if LICENCE is None or LICENCE == '':
raise RuntimeError("Licence must be provided !")
if os.path.exists(os.path.join(base_path, 'LICENCE')):
raise RuntimeError("Licence must be provided !")
def get_version():
"""Return package version as listed in `__version__` in `init.py`."""
init_py = open(os.path.join(PACKAGE_NAME, '__init__.py')).read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
try:
with open(os.path.join(base_path, 'requirements.txt'), encoding='utf-8') as f:
REQUIREMENTS = f.read().split('\n')
except Exception:
REQUIREMENTS = []
try:
with io.open(os.path.join(base_path, 'README.md'), encoding='utf-8') as f:
LONG_DESCRIPTION = '\n' + f.read()
except FileNotFoundError:
LONG_DESCRIPTION = SHORT_DESCRIPION
class UploadCommand(Command):
description = 'Build, install and upload tag to git with cleanup.'
user_options = []
def run(self):
try:
self.status('Removing previous builds...')
rmtree(os.path.join(base_path, 'dist'))
except OSError:
pass
self.status('Building Source and Wheel (universal) distribution...')
os.system('{0} setup.py sdist bdist_wheel'.format(sys.executable))
self.status('Pushing git tags...')
os.system('git tag v{0}'.format(get_version()))
os.system('git push --tags')
try:
self.status('Removing build artifacts...')
rmtree(os.path.join(base_path, 'build'))
rmtree(os.path.join(base_path, 'keras_efficientnets.egg-info'))
except OSError:
pass
sys.exit()
def initialize_options(self):
pass
def finalize_options(self):
pass
@staticmethod
def status(s):
print(s)
setup(
name=PACKAGE_NAME,
version=get_version(),
packages=find_packages(exclude=['tests']),
url=URL,
download_url=URL,
python_requires=REQUIRED_PYTHON,
license=LICENCE,
author=AUTHOR,
author_email=EMAIL,
description=SHORT_DESCRIPION,
long_description=LONG_DESCRIPTION,
long_description_content_type='text/markdown',
install_requires=REQUIREMENTS,
extras_require=EXTRA_REQUIREMENTS,
classifiers=(
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
),
test_suite="tests",
# python setup.py upload
cmdclass={
'upload': UploadCommand,
},
)