forked from tatsy/lime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
82 lines (72 loc) · 2.15 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
from __future__ import print_function
import os
import re
import sys
import site
import shutil
from six import add_metaclass
from distutils.sysconfig import get_python_lib
from setuptools import setup, find_packages, Extension
from setuptools.command.install import install as install_default
lime_shared_lib = ''
def get_version():
v = ''
with open('VERSION', 'r') as lines:
v = list(lines)[0]
return v
def prebuild():
global lime_shared_lib
prefix = ''
suffix = ''
py_suffix = ''
if sys.platform == 'linux' or sys.platform == 'linux2':
prefix = 'lib'
suffix = '.so'
py_suffix = '.so'
elif sys.platform == 'darwin':
prefix = 'lib'
suffix = '.dylib'
py_suffix = '.so'
elif sys.platform == 'win32':
prefix = ''
suffix = '.dll'
py_suffix = '.pyd'
else:
print('Sorry, unsupported OS: {}'.format(sys.platform))
return
out_dir = 'build/lib'
outfile = '%spylime%s' % (prefix, suffix)
if not os.path.exists(os.path.join(out_dir, outfile)):
print('Please build the library with CMake first.')
print('If you did it, please make sure the path of the shared library.')
print('The path should be: {}'.format(
os.path.join(out_dir, outfile)))
raise Exception('Installation failed!!')
lime_shared_lib = os.path.join(out_dir, 'lime%s' % py_suffix)
shutil.copyfile(os.path.join(out_dir, outfile),
os.path.join(lime_shared_lib))
# Install
class install(install_default):
def run(self):
install_default.run(self)
# Check build.
prebuild()
print(lime_shared_lib)
# Setup
setup(
cmdclass={ 'install' : install },
name='lime',
version=get_version(),
author='tatsy',
author_email='[email protected]',
url='https://github.com/tatsy/lime.git',
description='Library for IMage Editing.',
license='MIT',
classifiers={
'Development Status :: 4 - Beta',
'Programming Language :: C++',
'Programming Language :: Python 2',
'Programming Language :: Python 3'
},
data_files=[ (get_python_lib(), [ lime_shared_lib ]) ]
)