/
setup.py
96 lines (80 loc) · 2.65 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
"""
Create pii-extract-base as a Python package
"""
import io
import sys
import re
from setuptools import setup, find_packages
from src.pii_extract import VERSION
PKGNAME = "pii-extract-base"
GITHUB_URL = "https://github.com/piisa/" + PKGNAME
# --------------------------------------------------------------------
PYTHON_VERSION = (3, 8)
if sys.version_info < PYTHON_VERSION:
sys.exit(
"**** Sorry, {} {} needs at least Python {}".format(
PKGNAME, VERSION, ".".join(map(str, PYTHON_VERSION))
)
)
def requirements(filename="requirements.txt"):
"""Read the requirements file"""
with io.open(filename, "r") as f:
return [line.strip() for line in f if line and line[0] != "#"]
def long_description():
"""
Take the README and remove markdown hyperlinks
"""
with open("README.md", "rt", encoding="utf-8") as f:
desc = f.read()
desc = re.sub(r"^\[ ! \[ [\w\s]+ \] .+ \n", "", desc, flags=re.X | re.M)
desc = re.sub(r"^\[ ([^\]]+) \]: \s+ \S.*\n", r"", desc, flags=re.X | re.M)
return re.sub(r"\[ ([^\]]+) \]", r"\1", desc, flags=re.X)
# --------------------------------------------------------------------
setup_args = dict(
# Metadata
name=PKGNAME,
version=VERSION,
author="Paulo Villegas",
author_email="paulo.vllgs@gmail.com",
description="Extraction of PII from text chunks",
long_description_content_type="text/markdown",
long_description=long_description(),
license="Apache",
url=GITHUB_URL,
download_url=GITHUB_URL + "/tarball/v" + VERSION,
# Locate packages
packages=find_packages("src"), # [ PKGNAME ],
package_dir={"": "src"},
# Requirements
python_requires=">=" + ".".join(map(str, PYTHON_VERSION)),
# Optional requirements
extras_require={
"test": ["pytest", "nose", "coverage"],
},
setup_requires=["pytest-runner"],
tests_require=["pytest"],
entry_points={
"console_scripts": [
"pii-detect = pii_extract.app.detect:main",
"pii-task-info = pii_extract.app.task_info:main",
]
},
include_package_data=False,
package_data={
'pii_extract': ['resources/*.json'],
},
# Post-install hooks
cmdclass={},
keywords=["PIISA, PII"],
classifiers=[
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: Apache Software License",
"Development Status :: 4 - Beta",
"Topic :: Software Development :: Libraries :: Application Frameworks",
],
)
if __name__ == "__main__":
# Add requirements
setup_args["install_requires"] = requirements()
# Setup
setup(**setup_args)