forked from 10XDev/tsne
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
72 lines (61 loc) · 2.35 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
# encoding: utf-8
"""
To upload a new version:
1. make clean
2. git tag a new version: git tag v1.x.x
3. python setup.py sdist
4. python setup.py sdist register upload
"""
import sys
import platform
from distutils.core import setup
from setuptools import find_packages
from distutils.extension import Extension
import versioneer
import numpy
from Cython.Distutils import build_ext
from Cython.Build import cythonize
if sys.platform == 'darwin':
# OS X
version, _, _ = platform.mac_ver()
parts = version.split('.')
v1 = int(parts[0])
v2 = int(parts[1])
v3 = int(parts[2]) if len(parts) == 3 else None
if v2 >= 10:
# More than 10.10
extra_compile_args=['-I/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers']
else:
extra_compile_args=['-I/System/Library/Frameworks/vecLib.framework/Headers']
ext_modules = [Extension(name='bh_sne',
sources=['tsne/bh_sne_src/quadtree.cpp', 'tsne/bh_sne_src/tsne.cpp', 'tsne/bh_sne.pyx'],
include_dirs=[numpy.get_include(), 'tsne/bh_sne_src/'],
extra_compile_args=extra_compile_args,
extra_link_args=['-Wl,-framework', '-Wl,Accelerate', '-lcblas'],
language='c++')]
else:
# LINUX
ext_modules = [Extension(name='bh_sne',
sources=['tsne/bh_sne_src/quadtree.cpp', 'tsne/bh_sne_src/tsne.cpp', 'tsne/bh_sne.pyx'],
include_dirs=[numpy.get_include(), '/usr/local/include', 'tsne/bh_sne_src/'],
library_dirs=['/usr/local/lib'],
extra_compile_args=['-msse2', '-O3', '-fPIC', '-w'],
extra_link_args=['-lcblas'],
language='c++')]
ext_modules = cythonize(ext_modules)
with open('requirements.txt') as f:
required = f.read().splitlines()
cmdclass = versioneer.get_cmdclass()
cmdclass['build_ext'] = build_ext
setup(name='tsne',
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
author='Daniel Rodriguez',
author_email='[email protected]',
url='https://github.com/danielfrg/py_tsne',
description='TSNE implementations for python',
license='Apache License Version 2.0, January 2004',
packages=find_packages(),
ext_modules=ext_modules,
install_requires=required
)