forked from tensorlayer/TensorLayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·170 lines (132 loc) · 5.67 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
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
167
168
169
170
#!/usr/bin/env python
import codecs
import os
import sys
os.environ['TENSORLAYER_PACKAGE_BUILDING'] = 'True'
try:
from setuptools import find_packages, setup, Extension
from setuptools.command.build_ext import build_ext
except ImportError:
from distutils.core import (setup, find_packages)
from tensorlayer import (
__contact_emails__, __contact_names__, __description__, __download_url__, __homepage__, __keywords__, __license__,
__package_name__, __repository_url__, __version__
)
# =================== Reading Readme file as TXT files ===================
if os.path.exists('README.rst'):
# codec is used for consistent encoding
long_description = codecs.open(
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.rst'), 'r', 'utf-8'
).read()
else:
long_description = 'See ' + __homepage__
# ======================= Reading Requirements files as TXT files =======================
def req_file(filename, folder="requirements"):
with open(os.path.join(folder, filename)) as f:
content = f.readlines()
# you may also want to remove whitespace characters
# Example: `\n` at the end of each line
return [x.strip() for x in content]
# ======================= Defining the requirements var =======================
install_requires = req_file("requirements.txt")
extras_require = {
# User packages
'tf_cpu': req_file("requirements_tf_cpu.txt"),
'tf_gpu': req_file("requirements_tf_gpu.txt"),
'extra': req_file("requirements_extra.txt"),
# Contrib Packages
'contrib_loggers': req_file("requirements_contrib_loggers.txt"),
# Dev Packages
'test': req_file("requirements_test.txt"),
'dev': req_file("requirements_dev.txt"),
'doc': req_file("requirements_doc.txt"),
'db': req_file("requirements_db.txt"),
}
extras_require['all'] = sum([extras_require.get(key) for key in ['extra', 'contrib_loggers']], list())
extras_require['all_cpu'] = sum([extras_require.get(key) for key in ['all', 'tf_cpu']], list())
extras_require['all_gpu'] = sum([extras_require.get(key) for key in ['all', 'tf_gpu']], list())
extras_require['all_dev'] = sum([extras_require.get(key) for key in ['all', 'db', 'dev', 'doc', 'test']], list())
extras_require['all_cpu_dev'] = sum([extras_require.get(key) for key in ['all_dev', 'tf_cpu']], list())
extras_require['all_gpu_dev'] = sum([extras_require.get(key) for key in ['all_dev', 'tf_gpu']], list())
cmdclass = dict()
ext_modules = []
# Readthedocs requires TF 1.5.0 to build properly
if 'READTHEDOCS' in os.environ:
ext_modules = [
Extension('install_requirements_for_rtd', []),
]
class custom_build_ext(build_ext):
def build_extensions(self):
os.system('./scripts/install-requirements-for-rtd.sh %s' % os.path.dirname(sys.executable))
cmdclass = {'build_ext': custom_build_ext}
# ======================= Define the package setup =======================
setup(
name=__package_name__,
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version=__version__,
description=__description__,
long_description=long_description,
# The project's main homepage.
url=__repository_url__,
download_url=__download_url__,
# Author details
author=__contact_names__,
author_email=__contact_emails__,
# maintainer Details
maintainer=__contact_names__,
maintainer_email=__contact_emails__,
# The licence under which the project is released
license=__license__,
classifiers=[
# How mature is this project? Common values are
# 1 - Planning
# 2 - Pre-Alpha
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
# 6 - Mature
# 7 - Inactive
'Development Status :: 5 - Production/Stable',
# Indicate who your project is intended for
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Intended Audience :: Information Technology',
# Indicate what your project relates to
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Image Recognition',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: Apache Software License',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
# Additionnal Settings
'Environment :: Console',
'Natural Language :: English',
'Operating System :: OS Independent',
],
keywords=__keywords__,
packages=find_packages(),
# List run-time dependencies here. These will be installed by pip when
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=install_requires,
cmdclass=cmdclass,
# List additional groups of dependencies here (e.g. development
# dependencies). You can install these using the following syntax,
# $ pip install -e .[test]
extras_require=extras_require,
ext_modules=ext_modules,
scripts=[
'tl',
],
)