Skip to content

Commit c442f69

Browse files
ishevchejoaopfonseca
authored andcommitted
Updated the setup.py script to include dependencies
1 parent 5eaf14a commit c442f69

File tree

9 files changed

+130
-59
lines changed

9 files changed

+130
-59
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ lib64/
1919
parts/
2020
sdist/
2121
var/
22+
.venv/
2223
*.egg-info/
2324
.installed.cfg
2425
*.egg

references/.gitkeep

Whitespace-only changes.

reports/.gitkeep

Whitespace-only changes.

reports/figures/.gitkeep

Whitespace-only changes.

requirements.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

setup.py

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
1+
import os
2+
from pathlib import Path
13
from setuptools import find_packages, setup
24

5+
6+
def get_long_description() -> str:
7+
CURRENT_DIR = Path(__file__).parent
8+
return (CURRENT_DIR / "README.md").read_text(encoding="utf8")
9+
10+
11+
import xai_ranking._min_dependencies as min_deps # noqa
12+
13+
ver_file = os.path.join("xai_ranking", "_version.py")
14+
with open(ver_file) as f:
15+
exec(f.read())
16+
17+
VERSION = __version__ # noqa
18+
SHORT_DESCRIPTION = "Ranking Explainability Benchmark"
19+
LICENSE = "MIT"
20+
CLASSIFIERS = [
21+
"Intended Audience :: Science/Research",
22+
# "Intended Audience :: Developers",
23+
# "License :: OSI Approved",
24+
"Programming Language :: Python",
25+
"Topic :: Software Development",
26+
"Topic :: Scientific/Engineering",
27+
# "Operating System :: Microsoft :: Windows",
28+
# "Operating System :: POSIX",
29+
# "Operating System :: Unix",
30+
# "Operating System :: MacOS",
31+
# "Programming Language :: Python :: 3.9",
32+
# "Programming Language :: Python :: 3.10",
33+
# "Programming Language :: Python :: 3.11",
34+
# "Programming Language :: Python :: 3.12",
35+
]
36+
INSTALL_REQUIRES = (min_deps.tag_to_packages["metrics"],)
37+
EXTRAS_REQUIRE = {
38+
key: value for key, value in min_deps.tag_to_packages.items() if key != "metrics"
39+
}
40+
341
setup(
4-
name="xai_ranking",
5-
packages=find_packages(),
6-
version="0.1.0",
7-
description="Ranking Explainability Benchmark",
42+
name="xai-ranking",
43+
version=VERSION,
44+
description=SHORT_DESCRIPTION,
845
author="dataresponsibly",
9-
license="MIT",
46+
long_description=get_long_description(),
47+
long_description_content_type="text/markdown",
48+
license=LICENSE,
49+
classifiers=CLASSIFIERS,
50+
packages=find_packages(),
51+
install_requires=INSTALL_REQUIRES,
52+
extras_require=EXTRAS_REQUIRE,
1053
)

test_environment.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

xai_ranking/_min_dependencies.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""All minimum dependencies."""
2+
3+
import argparse
4+
5+
# The values are (version_spec, comma separated tags)
6+
dependent_packages = {
7+
"numpy": ("1.20.0", "metrics, datasets, scores"),
8+
"pandas": ("1.3.5", "metrics, datasets"),
9+
"scipy": ("1.14.1", "metrics"),
10+
"scikit-learn": ("1.2.0", "metrics"),
11+
12+
"pytest-cov": ("3.0.0", "tests"),
13+
"flake8": ("3.8.2", "tests"),
14+
"black": ("22.3", "tests"),
15+
"pylint": ("2.12.2", "tests"),
16+
"mypy": ("1.6.1", "tests"),
17+
"sphinx": ("4.2.0", "docs"),
18+
19+
# dev
20+
# "coverage": ("", "tests"),
21+
# "click": ("", "tests"),
22+
23+
# nutrition labels
24+
# "matplotlib" : ("", "install"),
25+
# "seaborn" : ("", "install"),
26+
27+
# L2R
28+
# "lightgbm" : ("", "install"),
29+
30+
# general?
31+
# "xai-sharp": ("0.1.a1", "install"),
32+
# "shap" : ("", "install"),
33+
# "lime" : ("", "install"),
34+
# "statsmodels" : ("", "install"),
35+
# "ml-research" : ("", "install"),
36+
37+
# dataset module
38+
# "openpyxl" : ("", "install"),
39+
# "" : ("", "install"),
40+
}
41+
42+
# create inverse mapping for setuptools
43+
tag_to_packages: dict = {
44+
extra: [] for extra in ["install", "optional", "docs", "examples", "tests", "all", "metrics", "datasets", "scores"]
45+
}
46+
for package, (min_version, extras) in dependent_packages.items():
47+
for extra in extras.split(", "):
48+
tag_to_packages[extra].append("{}>={}".format(package, min_version))
49+
tag_to_packages["all"].append("{}>={}".format(package, min_version))
50+
51+
# Used by CI to get the min dependencies
52+
if __name__ == "__main__":
53+
parser = argparse.ArgumentParser(description="Get min dependencies for a package")
54+
55+
parser.add_argument("package", choices=dependent_packages)
56+
args = parser.parse_args()
57+
min_version = dependent_packages[args.package][0]
58+
print(min_version)

xai_ranking/_version.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
``ShaRP`` is an open source library with the implementation of the ShaRP
3+
algorithm (Shapley for Rankings and Preferences).
4+
"""
5+
6+
# PEP0440 compatible formatted version, see:
7+
# https://www.python.org/dev/peps/pep-0440/
8+
#
9+
# Generic release markers:
10+
# X.Y
11+
# X.Y.Z # For bugfix releases
12+
#
13+
# Admissible pre-release markers:
14+
# X.YaN # Alpha release
15+
# X.YbN # Beta release
16+
# X.YrcN # Release Candidate
17+
# X.Y # Final release
18+
#
19+
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
20+
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
21+
#
22+
23+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)