-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
89 lines (71 loc) · 2.53 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
import os
import re
from setuptools import find_packages, setup
def get_extra_requires(path, add_all=True):
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.rsplit(":", 1)
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
regexp = re.compile(r".*__version__ = [\'\"](.*?)[\'\"]", re.S)
base_package = "ocrtoolkit"
base_path = os.path.dirname(__file__)
init_file = os.path.join(base_path, "src", "ocrtoolkit", "__init__.py")
with open(init_file, "r") as f:
module_content = f.read()
match = regexp.match(module_content)
if match:
version = match.group(1)
else:
raise RuntimeError("Cannot find __version__ in {}".format(init_file))
with open("README.rst", "r") as f:
readme = f.read()
with open("CHANGELOG.rst", "r") as f:
changes = f.read()
def parse_requirements(filename):
"""Load requirements from a pip requirements file"""
with open(filename, "r") as fd:
lines = []
for line in fd:
line.strip()
if line and not line.startswith("#"):
lines.append(line)
return lines
requirements = parse_requirements("requirements.txt")
print(get_extra_requires("extra-requirements.txt"))
if __name__ == "__main__":
setup(
name="ocrtoolkit",
description="Parse bank cheques",
long_description="\n\n".join([readme, changes]),
license="Apache Software License 2.0",
url="https://github.com/ajkdrag/ocrtoolkit",
version=version,
author="ajkdrag",
author_email="",
maintainer="ajkdrag",
maintainer_email="",
install_requires=requirements,
extras_require=get_extra_requires("extra-requirements.txt"),
keywords=["ocrtoolkit"],
package_dir={"": "src"},
packages=find_packages("src"),
zip_safe=False,
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
)