-
Notifications
You must be signed in to change notification settings - Fork 25
/
setup.py
executable file
·109 lines (84 loc) · 2.79 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
# pylint: disable=E0602
import sys
import os.path as osp
import glob
import io
from setuptools import setup, find_packages
import pip
try:
from pip._internal.req import parse_requirements # pip 10
except ImportError:
from pip.req import parse_requirements # pip 9
# globals
PACKAGE = "candis"
SRCDIR = "src"
def isdef(var):
return var in globals()
def read(path, encoding=None):
content = None
with io.open(path, encoding=encoding) as f:
content = f.read()
return content
def get_package_info():
attr = osp.abspath(osp.join(SRCDIR, PACKAGE, "__attr__.py"))
info = dict(__file__=attr) # HACK
with open(attr) as f:
content = f.read()
exec(content, info)
return info
def get_dependencies(type_=None):
path = osp.realpath("requirements.txt")
requirements = [str(ir.req)
for ir in parse_requirements(path, session="hack")]
if type_ == "development":
path = osp.realpath("requirements-dev.txt")
requirements = [
str(ir.req) for ir in parse_requirements(path, session="hack")
if str(ir.req) not in requirements
]
return requirements
PKGINFO = get_package_info()
setup(
name=PKGINFO["__name__"],
version=PKGINFO["__version__"],
url=PKGINFO["__url__"],
author=PKGINFO["__author__"],
author_email=PKGINFO["__email__"],
description=PKGINFO["__description__"],
long_description=read("README.md", encoding="utf8"),
long_description_content_type="text/markdown",
license=PKGINFO["__license__"],
keywords=" ".join(PKGINFO["__keywords__"]),
packages=find_packages(where=SRCDIR),
package_dir={"": SRCDIR},
zip_safe=False,
entry_points={
"console_scripts": [
"%s = %s.__main__:main" % (
PKGINFO["__command__"] if hasattr(
PKGINFO, "__command__") else PKGINFO["__name__"],
PACKAGE
)
]
},
install_requires=get_dependencies(type_="production"),
extras_require=dict(
dev=get_dependencies(type_="development")
),
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy"
]
)