-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.py
92 lines (72 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
import os
from pathlib import Path
from typing import Any, List, Tuple
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import find_packages, setup
SETUP_DIRECTORY = Path(__file__).resolve().parent
with (SETUP_DIRECTORY / "Readme.md").open() as ifs:
LONG_DESCRIPTION = ifs.read()
install_requires = (
[
"numpy>=1.12.0",
"fastprogress>=0.2",
"optuna>=2.5.0",
"pandas>=1.0.0",
"scipy>=1.0",
"colorlog>=4",
"pydantic>=1.8.2",
"typing_extensions>=3.10",
],
)
class get_eigen_include(object):
EIGEN3_URL = "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip"
EIGEN3_DIRNAME = "eigen-3.3.7"
def __str__(self) -> str:
eigen_include_dir = os.environ.get("EIGEN3_INCLUDE_DIR", None)
if eigen_include_dir is not None:
return eigen_include_dir
target_dir = SETUP_DIRECTORY / self.EIGEN3_DIRNAME
if target_dir.exists():
return target_dir.name
download_target_dir = SETUP_DIRECTORY / "eigen3.zip"
import zipfile
import requests
response = requests.get(self.EIGEN3_URL, stream=True)
with download_target_dir.open("wb") as ofs:
for chunk in response.iter_content(chunk_size=1024):
ofs.write(chunk)
with zipfile.ZipFile(download_target_dir) as ifs:
ifs.extractall()
return target_dir.name
module_name_and_sources: List[Tuple[str, List[str]]] = [
("irspack.evaluation._core", ["cpp_source/evaluator.cpp"]),
("irspack.recommenders._ials", ["cpp_source/als/wrapper.cpp"]),
("irspack.recommenders._knn", ["cpp_source/knn/wrapper.cpp"]),
("irspack.utils._util_cpp", ["cpp_source/util.cpp"]),
]
ext_modules = [
Pybind11Extension(module_name, sources, include_dirs=[get_eigen_include()])
for module_name, sources in module_name_and_sources
]
def local_scheme(version: Any) -> str:
return ""
setup(
name="irspack",
# version=get_version(),
url="https://irspack.readthedocs.io/",
use_scm_version={
"local_scheme": local_scheme
}, # https://github.com/pypa/setuptools_scm/issues/342
author="Tomoki Ohtsuki",
author_email="[email protected]",
description="Implicit feedback-based recommender systems, packed for practitioners.",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
ext_modules=ext_modules,
install_requires=install_requires,
include_package_data=True,
cmdclass={"build_ext": build_ext},
packages=find_packages("src"),
python_requires=">=3.7",
package_dir={"": "src"},
)