This repository has been archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
119 lines (100 loc) · 3.32 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
from setuptools import setup
import os
from setuptools.command.install import install
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Framework :: Twisted",
"Programming Language :: Python",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: Implementation :: CPython",
]
def package_files(directory):
paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join('..', path, filename))
return paths
ms_extra_files = package_files('minerstat/clients')
tw_extra_files = package_files('twisted')
try:
import twisted # noqa
except ImportError:
raise SystemExit("twisted not found. Make sure you "
"have installed the Twisted core package.")
class InstallTwistedPlugin(install, object):
def run(self):
super(InstallTwistedPlugin, self).run()
# Make Twisted regenerate the dropin.cache, if possible. This is necessary
# because in a site-wide install, dropin.cache cannot be rewritten by
# normal users.
print("Attempting to update Twisted plugin cache.")
try:
from twisted.plugin import IPlugin, getPlugins
list(getPlugins(IPlugin))
print("Twisted plugin cache updated successfully.")
except Exception as e:
print("*** Failed to update Twisted plugin cache. ***")
print(str(e))
try:
from setuptools.command import egg_info
egg_info.write_toplevel_names
except (ImportError, AttributeError):
pass
else:
def _top_level_package(name):
return name.split('.', 1)[0]
def _hacked_write_toplevel_names(cmd, basename, filename):
pkgs = dict.fromkeys(
[
_top_level_package(k)
for k in cmd.distribution.iter_distribution_names()
if _top_level_package(k) != "twisted"
]
)
cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n')
egg_info.write_toplevel_names = _hacked_write_toplevel_names
if __name__ == "__main__":
with open('README.md') as f:
readme = f.read()
setup(
name="minerstat",
packages=[
"minerstat",
"minerstat.miners",
"twisted.plugins"
],
package_data={
'minerstat': ms_extra_files,
'twisted': tw_extra_files
},
setup_requires=[],
install_requires=[
"six",
"Twisted[tls] >= 16.4.0",
"attrs",
],
extras_require={
"dev": [
"mock",
"pep8",
"sphinx",
"flake8",
"flake8-mypy"
],
},
author="David Novakovic",
author_email="[email protected]",
classifiers=classifiers,
description="A fully featured client for minerstat.com",
license="Apache 2.0",
url="https://github.com/dpnova/pynerstat",
long_description=readme,
scripts=['bin/minerstat'],
cmdclass={
'install': InstallTwistedPlugin,
}
)