-
Notifications
You must be signed in to change notification settings - Fork 169
/
setup.py
133 lines (108 loc) · 4.15 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""Setup script."""
import codecs
import os
import re
from pathlib import Path
from pprint import pprint
from setuptools import find_packages, setup
HERE = os.path.abspath(os.path.dirname(__file__))
def read(*parts):
# intentionally *not* adding an encoding option to open
return codecs.open(os.path.join(HERE, *parts), "r").read()
def read_requirements(*parts):
"""Return requirements from parts.
Given a requirements.txt (or similar style file),
returns a list of requirements.
Assumes anything after a single '#' on a line is a comment, and ignores
empty lines.
Args:
parts: List of filenames which contain the installation "parts",
i.e. submodule-specific installation requirements
Returns:
A compiled list of requirements.
"""
requirements = []
for line in read(*parts).splitlines():
new_line = re.sub( # noqa: PD005
r"(\s*)?#.*$", # the space immediately before the
# hash mark, the hash mark, and
# anything that follows it
"", # replace with a blank string
line,
)
new_line = re.sub( # noqa: PD005
r"-r.*$", # link to another requirement file
"", # replace with a blank string
new_line,
)
new_line = re.sub( # noqa: PD005
r"-e \..*$", # link to editable install
"", # replace with a blank string
new_line,
)
# print(line, "-->", new_line)
if new_line: # i.e. we have a non-zero-length string
requirements.append(new_line)
return requirements
# pull from requirements.IN, requirements.TXT is generated from this
INSTALL_REQUIRES = read_requirements(".requirements/base.in")
EXTRA_REQUIRES = {
"dev": read_requirements(".requirements/dev.in"),
"docs": read_requirements(".requirements/docs.in"),
"test": read_requirements(".requirements/testing.in"),
"biology": read_requirements(".requirements/biology.in"),
"chemistry": read_requirements(".requirements/chemistry.in"),
"engineering": read_requirements(".requirements/engineering.in"),
"spark": read_requirements(".requirements/spark.in"),
}
# add 'all' key to EXTRA_REQUIRES
all_requires = []
for _, v in EXTRA_REQUIRES.items():
all_requires.extend(v)
EXTRA_REQUIRES["all"] = set(all_requires)
for k1 in ["biology", "chemistry", "engineering", "spark"]:
for v2 in EXTRA_REQUIRES[k1]:
EXTRA_REQUIRES["docs"].append(v2)
pprint(EXTRA_REQUIRES)
def generate_long_description() -> str:
"""Extra chunks from README for PyPI description.
Target chunks must be contained within `<!-- pypi-doc -->` pair comments,
so there must be an even number of comments in README.
Raises:
Exception: If odd number of `<!-- pypi-doc -->` comments
in README.
Returns:
Extracted description from README.
"""
# Read the contents of README file
this_directory = Path(__file__).parent
with open(this_directory / "mkdocs" / "index.md", encoding="utf-8") as f:
readme = f.read()
# Find pypi-doc comments in README
boundary = r"<!-- pypi-doc -->"
indices = [m.start() for m in re.finditer(boundary, readme)]
if len(indices) % 2 != 0:
raise Exception(f"Odd number of `{boundary}` comments in README")
# Loop through pairs of comments and save text between pairs
long_description = ""
for i in range(0, len(indices), 2):
start_index = indices[i] + len(boundary)
end_index = indices[i + 1]
long_description += readme[start_index:end_index]
return long_description
setup(
name="pyjanitor",
version="0.29.2",
description="Tools for cleaning pandas DataFrames",
author="pyjanitor devs",
author_email="[email protected]",
url="https://github.com/pyjanitor-devs/pyjanitor",
license="MIT",
# packages=["janitor", "janitor.xarray", "janitor.spark"],
packages=find_packages(),
install_requires=INSTALL_REQUIRES,
extras_require=EXTRA_REQUIRES,
python_requires=">=3.6",
long_description=generate_long_description(),
long_description_content_type="text/markdown",
)