-
Notifications
You must be signed in to change notification settings - Fork 27
/
setup-pip.py
74 lines (64 loc) · 2.96 KB
/
setup-pip.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
# pylint: disable=invalid-name, exec-used
"""Setup picasso package."""
from __future__ import absolute_import
import sys
import os
import shutil
from setuptools import setup, find_packages
# import subprocess
sys.path.insert(0, '.')
CURRENT_DIR = os.path.dirname(__file__)
# complie c code
if os.name != 'nt':
os.system('cd pycasso/src/; make clean; make dylib; cd ../../;')
else:
raise RuntimeError('Windows users please install from source')
#try to copy the complied lib files
libdir_candidate = [os.path.join(CURRENT_DIR, './pycasso/src/lib/')]
if sys.platform == 'win32':
libcand_path = [os.path.join(p, 'picasso.dll') for p in libdir_candidate]
libcand_path = libcand_path + [os.path.join(p, 'libpicasso.so') for p in libdir_candidate]
elif sys.platform.startswith('linux'):
libcand_path = [os.path.join(p, 'libpicasso.so') for p in libdir_candidate]
elif sys.platform == 'darwin':
libcand_path = [os.path.join(p, 'libpicasso.so') for p in libdir_candidate]
libcand_path = libcand_path + [os.path.join(p, 'libpicasso.dylib') for p in libdir_candidate]
lib_path = [p for p in libcand_path if os.path.exists(p) and os.path.isfile(p)]
for lib_file in lib_path:
shutil.copy(lib_file,os.path.join(CURRENT_DIR, './pycasso/lib/'))
# We can not import `picasso.libpath` in setup.py directly, since it will automatically import other package
# and case conflict to `install_requires`
libpath_py = os.path.join(CURRENT_DIR, 'pycasso/libpath.py')
libpath = {'__file__': libpath_py}
exec(compile(open(libpath_py, "rb").read(), libpath_py, 'exec'), libpath, libpath)
LIB_PATH = [os.path.relpath(libfile, CURRENT_DIR) for libfile in libpath['find_lib_path']()]
if not LIB_PATH:
raise RuntimeError("libpicasso does not exists")
else:
print("libpicasso already exists: %s" % LIB_PATH)
VERSION_PATH = os.path.join(CURRENT_DIR, 'pycasso/VERSION')
setup(name='pycasso',
version=open(VERSION_PATH).read().strip(),
description="Picasso Python Package",
long_description=open(os.path.join(CURRENT_DIR, 'README.rst')).read(),
install_requires=[
'numpy',
'scipy',
],
maintainer='Haoming Jiang',
maintainer_email='[email protected]',
zip_safe=False,
packages=find_packages(),
# this will use MANIFEST.in during install where we specify additional files,
# this is the golden line
include_package_data=True,
# data_files=[('pycasso',LIB_PATH)],
license='GPL-3.0',
classifiers=['Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Mathematics',
'Programming Language :: Python :: 3 :: Only',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)'],
url='https://hmjianggatech.github.io/picasso/')