forked from mattjj/pyhsmm
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
91 lines (82 loc) · 2.53 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
import shutil
import tarfile
from pathlib import Path
from urllib.request import urlretrieve
import numpy
import requests
from setuptools import Extension, setup
from Cython.Build import cythonize
def download_eigen(deps_dir):
deps_dir = Path(deps_dir)
deps_dir.mkdir(exist_ok=True)
# download Eigen if we don't have it in deps
# TODO: Can we cleanup this?
eigenurl = "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz"
eigenpath = deps_dir.joinpath("Eigen")
eigentarpath = deps_dir.joinpath("Eigen.tar.gz")
if not eigenpath.exists():
print("Downloading Eigen...")
r = requests.get(eigenurl)
with open(eigentarpath, 'wb') as f:
f.write(r.content)
with tarfile.open(eigentarpath, "r") as tar:
tar.extractall("deps")
thedir = next(deps_dir.glob("eigen-*"))
shutil.move(thedir.joinpath("Eigen"), eigenpath)
print("...done!")
def find_extensions(deps_dir):
extensions = []
for pyx in Path("pyhsmm").glob("**/*.pyx"):
ext_name = ".".join(pyx.with_suffix("").parts)
print(f"Extension {ext_name}: {pyx}")
extensions.append(
Extension(
ext_name,
sources=[str(pyx)],
include_dirs=[deps_dir, numpy.get_include()],
extra_compile_args=[
"-O3",
"-std=c++11",
"-DNDEBUG",
"-w",
"-DHMM_TEMPS_ON_HEAP",
],
)
)
return extensions
download_eigen("deps")
extensions = find_extensions("deps")
setup(
name="pyhsmm",
version="0.1.6",
description="Bayesian inference in HSMMs and HMMs",
author="Matthew James Johnson",
author_email="mattjj@csail.mit.edu",
url="https://github.com/mattjj/pyhsmm",
license="MIT",
packages=["pyhsmm", "pyhsmm.basic", "pyhsmm.internals", "pyhsmm.util"],
platforms="ALL",
keywords=[
"bayesian",
"inference",
"mcmc",
"time-series",
"monte-carlo",
"variational inference",
"mean field",
"vb",
],
install_requires=[
"matplotlib",
"numpy",
"scipy",
"pybasicbayes@git+https://github.com/maxmouchet/pybasicbayes.git",
],
ext_modules=cythonize(extensions),
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: C++",
],
)