-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·126 lines (108 loc) · 4.16 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import sys
import warnings
from setuptools import setup, find_packages
classifiers = [
"Intended Audience :: Developers",
"Operating System :: POSIX",
"Natural Language :: English",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
]
def getPackageInfo():
info_dict = {}
info_keys = ["version", "name", "author", "author_email", "url", "license",
"description", "release_name", "github_url"]
key_remap = {"name": "project_name"}
with open(os.path.join(os.path.abspath(os.path.dirname(__file__)),
".",
"clique",
"__about__.py")) as infof:
for line in infof:
for what in info_keys:
rex = re.compile(r"__{what}__\s*=\s*['\"](.*?)['\"]"
.format(what=what if what not in key_remap
else key_remap[what]))
m = rex.match(line.strip())
if not m:
continue
if what == "name":
# Clique is taken on PyPi, change
name = "{}-blockchain".format(m.groups()[0])
else:
name = m.groups()[0]
info_dict[what] = name
if sys.version_info[:2] >= (3, 4):
vparts = info_dict["version"].split("-", maxsplit=1)
else:
vparts = info_dict["version"].split("-", 1)
info_dict["release"] = vparts[1] if len(vparts) > 1 else "final"
return info_dict
readme = ""
if os.path.exists("README.rst"):
with open("README.rst") as readme_file:
readme = readme_file.read()
history = ""
if os.path.exists("HISTORY.rst"):
with open("HISTORY.rst") as history_file:
history = history_file.read().replace(".. :changelog:", "")
def requirements(filename):
reqfile = os.path.join("requirements", filename)
if os.path.exists(reqfile):
return open(reqfile).read().splitlines()
else:
return ""
pkg_info = getPackageInfo()
if pkg_info["release"].startswith("a"):
#classifiers.append("Development Status :: 1 - Planning")
#classifiers.append("Development Status :: 2 - Pre-Alpha")
classifiers.append("Development Status :: 3 - Alpha")
elif pkg_info["release"].startswith("b"):
classifiers.append("Development Status :: 4 - Beta")
else:
classifiers.append("Development Status :: 5 - Production/Stable")
#classifiers.append("Development Status :: 6 - Mature")
#classifiers.append("Development Status :: 7 - Inactive")
gz = "{name}-{version}.tar.gz".format(**pkg_info)
pkg_info["download_url"] = (
"{github_url}/releases/downloads/v{version}/{gz}"
.format(gz=gz, **pkg_info)
)
def package_files(directory):
paths = []
for (path, _, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join("..", path, filename))
return paths
if sys.argv[1:] and sys.argv[1] == "--release-name":
print(pkg_info["release_name"])
sys.exit(0)
else:
# The extra command line options we added cause warnings, quell that.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message="Unknown distribution option")
setup(classifiers=classifiers,
package_dir={"": "."},
packages=find_packages(".",
exclude=["tests", "tests.*"]),
zip_safe=False,
platforms=["Any"],
keywords=["clique"],
install_requires=requirements("default.txt"),
tests_require=requirements("test.txt"),
test_suite="./tests",
long_description=readme + "\n\n" + history,
include_package_data=True,
package_data={},
entry_points={
"console_scripts": [
"clique = clique.app.__main__:app.run",
]
},
**pkg_info
)