forked from massquantity/LibRecommender
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
155 lines (135 loc) · 4.23 KB
/
setup.py
File metadata and controls
155 lines (135 loc) · 4.23 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
from codecs import open
import glob
import logging
import os
import platform
import sys
import numpy as np
from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
NAME = "LibRecommender"
VERSION = "0.10.2"
here = os.path.abspath(os.path.dirname(__file__))
# Get the long description from README.md
with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()
# get the dependencies and installs
with open(os.path.join(here, "requirements.txt"), encoding="utf-8") as f:
all_reqs = f.read().split("\n")
install_requires = [x.strip() for x in all_reqs]
def extract_gcc_binaries():
"""Try to find GCC on OSX for OpenMP support."""
patterns = [
"/opt/local/bin/g++-mp-[0-9]*.[0-9]*",
"/opt/local/bin/g++-mp-[0-9]*",
"/usr/local/bin/g++-[0-9]*.[0-9]*",
"/usr/local/bin/g++-[0-9]*",
]
if platform.system() == "Darwin":
gcc_binaries = []
for pattern in patterns:
gcc_binaries += glob.glob(pattern)
gcc_binaries.sort()
if gcc_binaries:
_, gcc = os.path.split(gcc_binaries[-1])
return gcc
else:
return
else:
return
if sys.platform.startswith("win"):
compile_args = ["/O2", "/openmp"]
link_args = []
else:
use_openmp = True
compile_args = [
"-Wno-unused-function",
"-Wno-maybe-uninitialized",
"-O3",
"-ffast-math",
]
link_args = []
if sys.platform.startswith("darwin"):
gcc = extract_gcc_binaries()
if gcc is not None:
logging.info(f"gcc on macOS: {gcc}")
os.environ["CC"] = gcc
os.environ["CXX"] = gcc
else:
use_openmp = False
logging.warning(
"No GCC available. Install gcc from Homebrew: brew install gcc."
)
if use_openmp:
compile_args.append("-fopenmp")
link_args.append("-fopenmp")
compile_args.append("-std=c++11")
link_args.append("-std=c++11")
extensions = [
Extension(
"libreco.algorithms._bpr",
[os.path.join("libreco", "algorithms", "_bpr.pyx")],
include_dirs=[np.get_include()],
language="c++",
extra_compile_args=compile_args,
extra_link_args=link_args,
),
Extension(
"libreco.algorithms._als",
[os.path.join("libreco", "algorithms", "_als.pyx")],
include_dirs=[np.get_include()],
language="c++",
extra_compile_args=compile_args,
extra_link_args=link_args,
),
Extension(
"libreco.utils._similarities",
[os.path.join("libreco", "utils", "_similarities.pyx")],
include_dirs=[np.get_include()],
language="c++",
extra_compile_args=compile_args,
extra_link_args=link_args,
),
]
setup(
name=NAME,
author="massquantity",
author_email="jinxin_madie@163.com",
description=(
"A collaborative-filtering and content-based recommender system "
"for both explicit and implicit datasets."
),
long_description=long_description,
long_description_content_type="text/markdown",
version=VERSION,
url="https://github.com/massquantity/LibRecommender",
license="MIT",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Cython",
],
keywords=[
"Matrix Factorization",
"Collaborative Filtering",
"Content-Based",
"Recommender System",
"Deep Learning",
"Data Mining",
],
packages=find_packages(exclude=["test*", "examples"]),
setup_requires=["Cython>=0.29"],
include_package_data=True,
ext_modules=cythonize(extensions),
cmdclass={"build_ext": build_ext},
install_requires=install_requires,
)