-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
136 lines (117 loc) · 3.83 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
import os
import re
import shlex
from setuptools import setup, find_packages, Command
base_package = "bonked"
EXTRAS_REQUIRE = {
"tests": ["pytest", "mock", "scripttest==1.3", "ipython", "bpython"],
"lint": [
"mypy==0.710",
"flake8==3.7.7",
"flake8-bugbear==19.3.0",
"pre-commit==1.17.0",
],
}
EXTRAS_REQUIRE["dev"] = (
EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["lint"] + ["ptpython", "tox"]
)
PYTHON_REQUIRES = ">=3.6"
class Shell(Command):
user_options = [
("name=", "n", "Named config to use."),
("shell=", "s", "Shell to use."),
("file=", "f", "File path of konch config file to execute."),
]
def initialize_options(self):
self.name = None
self.shell = None
self.file = None
def finalize_options(self):
pass
def run(self):
import konch
argv = []
for each in ("name", "shell", "file"):
opt = getattr(self, each)
if opt:
argv.append(f"--{each}={opt}")
konch.main(argv)
def read(fname):
try:
with open(fname) as fp:
content = fp.read()
return content
except:
return ""
def find_version(fname):
"""Attempts to find the version number in the file names fname.
"""
# Get the version (borrowed from SQLAlchemy)
version = ""
module_content = read(fname)
reg = re.compile(r".*__version__ = \'(.*?)\'", re.S)
m = reg.match(module_content)
if m:
version = m.group(1)
return version
def find_license(fname):
"""Attempts to find the license in the file names fname.
"""
LICENSE = ""
module_content = read(fname)
reg = re.compile(r".*__license__ = \'(.*?)\'", re.S)
m = reg.match(module_content)
if m:
LICENSE = m.group(1)
return LICENSE
base_path = os.path.dirname(__file__)
fname = os.path.join(base_path, "bonked", "__init__.py")
VERSION = find_version(fname)
LICENSE = find_license(fname)
readme = read("README.rst")
changes = read("CHANGELOG.rst")
requirements = [
line for line in read("requirements.txt").split("\n") if len(line.strip())
]
packages = [
base_package + "." + x for x in find_packages(os.path.join(base_path, base_package))
]
if base_package not in packages:
packages.append(base_package)
if __name__ == "__main__":
setup(
name="bonked",
description="Konch shell wrapper",
long_description="\n\n".join([readme, changes]),
license=LICENSE,
url="https://github.com/brl0/bonked",
version=VERSION,
author="Brian Larsen",
author_email="[email protected]",
maintainer="Brian Larsen",
maintainer_email="[email protected]",
py_modules=["bonked"],
entry_points={"console_scripts": ["bonked = bonked.cli:main"]},
install_requires=requirements,
cmdclass={"shell": Shell},
extras_require=EXTRAS_REQUIRE,
python_requires=PYTHON_REQUIRES,
keywords=["bonked"],
packages=packages,
zip_safe=False,
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: System :: Shells",
],
project_urls={
"Changelog": "https://konch.readthedocs.io/en/latest/changelog.html",
"Issues": "https://github.com/sloria/konch/issues",
"Source": "https://github.com/sloria/konch/",
},
)