forked from sloria/konch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
103 lines (89 loc) · 2.78 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
import re
from setuptools import setup, Command
EXTRAS_REQUIRE = {
"tests": ["pytest", "mock", "scripttest==1.3", "ipython", "bpython"],
"lint": [
"mypy==0.701",
"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 find_version(fname):
"""Attempts to find the version number in the file names fname.
Raises RuntimeError if not found.
"""
version = ""
with open(fname, "r") as fp:
reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
for line in fp:
m = reg.match(line)
if m:
version = m.group(1)
break
if not version:
raise RuntimeError("Cannot find version information")
return version
def read(fname):
with open(fname) as fp:
content = fp.read()
return content
setup(
name="konch",
version=find_version("konch.py"),
description=(
"CLI and configuration utility for the Python shell, optimized "
"for simplicity and productivity."
),
long_description=read("README.rst"),
author="Steven Loria",
author_email="sloria1@gmail.com",
url="https://github.com/sloria/konch",
install_requires=[],
cmdclass={"shell": Shell},
extras_require=EXTRAS_REQUIRE,
python_requires=PYTHON_REQUIRES,
license="MIT",
zip_safe=False,
keywords="konch shell custom ipython bpython repl ptpython ptipython",
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: System :: Shells",
],
py_modules=["konch", "docopt"],
entry_points={"console_scripts": ["konch = konch:main"]},
project_urls={
"Changelog": "https://konch.readthedocs.io/en/latest/changelog.html",
"Issues": "https://github.com/sloria/konch/issues",
"Source": "https://github.com/sloria/konch/",
},
)