-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
84 lines (69 loc) · 2.6 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
import os
from setuptools import find_packages as _find_packages
from setuptools import setup as _setup
from colorteller.version import __version__
# read the contents of your README file
__CWD__ = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(__CWD__, "README.md"), encoding="utf-8") as fp:
PACKAGE_LONG_DESCRIPTION = fp.read()
PACKAGE_NAME = "colorteller"
PACKAGE_VERSION = __version__
PACKAGE_DESCRIPTION = "colorteller, benchmarking color palattes."
PACKAGE_LONG_DESCRIPTION = PACKAGE_LONG_DESCRIPTION
PACKAGE_URL = "https://github.com/kausalflow/colorteller-package"
def _requirements():
return [r for r in open("requirements.txt")]
def get_extra_requires(path, add_all=True):
"""
get_extra_requires retrieves the extras requirements.
Reference:
https://hanxiao.io/2019/11/07/A-Better-Practice-for-Managing-extras-require-Dependencies-in-Python/
:param path: path to the extras require specification
:type path: str
:param add_all: whether to include the keyword all, defaults to True
:type add_all: bool, optional
:return: The mapping of all the dependencies by extras keyword
:rtype: dict
"""
import re
from collections import defaultdict
with open(path) as fp:
extra_deps = defaultdict(set)
for k in fp:
if k.strip() and not k.startswith("#"):
tags = set()
if ":" in k:
k, v = k.split(":")
tags.update(vv.strip() for vv in v.split(","))
tags.add(re.split("[<=>]", k)[0])
for t in tags:
extra_deps[t].add(k)
# add tag `all` at the end
if add_all:
extra_deps["all"] = set(vv for v in extra_deps.values() for vv in v)
return extra_deps
def setup():
_setup(
name=PACKAGE_NAME,
version=PACKAGE_VERSION,
description=PACKAGE_DESCRIPTION,
long_description=PACKAGE_LONG_DESCRIPTION,
long_description_content_type="text/markdown",
url=PACKAGE_URL,
author="L Ma",
author_email="[email protected]",
license="MIT",
packages=_find_packages(exclude=("tests",)),
install_requires=_requirements(),
include_package_data=True,
test_suite="nose.collector",
tests_require=["nose"],
extras_require=get_extra_requires("requirements.extras.txt"),
entry_points={
"console_scripts": ["colorteller=colorteller.command:colorteller"]
},
zip_safe=False,
)
if __name__ == "__main__":
setup()
print(_find_packages(exclude=("tests",)))