forked from mlcommons/ck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·213 lines (175 loc) · 6.85 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#
# Collective Knowledge
#
# See CK LICENSE.txt for licensing details.
# See CK Copyright.txt for copyright details.
#
import sys
import os
import re
import ck.net
############################################################
try:
from io import open
except ImportError:
pass
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
try:
from setuptools import convert_path
except ImportError:
from distutils.util import convert_path
try:
from setuptools.command.install import install
except ImportError:
from distutils.command.install import install
try:
from setuptools.command.install_scripts import install_scripts
except ImportError:
from distutils.command.install_scripts import install_scripts
try:
from setuptools.command.install_lib import install_lib
except ImportError:
from distutils.command.install_lib import install_lib
from distutils.sysconfig import get_python_lib
############################################################
# Global variables
dir_install_script=""
############################################################
# Find version
current_version=''
current_path=os.path.abspath(os.path.dirname(__file__))
kernel_file=os.path.join(current_path, 'ck', 'kernel.py')
with open(kernel_file, encoding="utf-8") as f:
search = re.search(r'__version__ = ["\']([^"\']+)', f.read())
if not search:
raise ValueError("We can't find the CK version in ck/kernel.py")
current_version = search.group(1)
############################################################
class custom_install(install):
def run(self):
global dir_install_script
install.run(self)
# Check if detected script directory
if dir_install_script!="" and os.path.isdir(dir_install_script):
# Check which python interpreter is used
python_bin=sys.executable
real_python_bin=os.path.abspath(python_bin)
if os.path.isfile(python_bin):
# Attempt to write to $SCRIPTS/ck-python.cfg
file_type='wb'
if sys.version_info[0]>2:
file_type='w'
p=os.path.join(dir_install_script, 'ck-python.cfg')
try:
with open(p, file_type) as f:
f.write(python_bin+'\n')
print ('')
print ("Writing CK python executable ("+python_bin+") to "+p)
print ('')
except Exception as e:
print ("warning: can\'t write info about CK python executable to "+p+" ("+format(e)+")")
pass
# Check default repo status before copying
r=ck.net.request({'get':{'action':'get-default-repo-status', 'version': current_version}})
d=r.get('dict',{})
if d.get('skip_copy_default_repo', False):
return
############################################################
class custom_install_scripts(install_scripts):
def run(self):
global dir_install_script
install_scripts.run(self)
dir_install_script=os.path.abspath(self.install_dir)
if dir_install_script!=None and dir_install_script!="" and os.path.isdir(dir_install_script):
print ('')
print ("Detected script installation directory: "+dir_install_script)
print ('')
return
############################################################
# Describing CK setup
r=setup(
name='ck',
version=current_version,
url='https://github.com/ctuning/ck',
license='BSD 3-clause',
author='Grigori Fursin',
author_email='[email protected]',
description='Collective Knowledge - a lightweight knowledge manager to organize, cross-link, share and reuse artifacts and workflows',
long_description=open(convert_path('./README.md'), encoding="utf-8").read(),
long_description_content_type="text/markdown",
packages=['ck'],
package_dir={'ck': 'ck'},
zip_safe=False,
package_data={'ck': ['repo/.ck*',
'repo/.cm/*',
'repo/kernel/.cm/*',
'repo/kernel/default/*',
'repo/kernel/default/.cm/*',
'repo/module/.cm/*',
'repo/module/all/*.py',
'repo/module/all/.cm/*',
'repo/module/demo/*.py',
'repo/module/demo/.cm/*',
'repo/module/index/*.py',
'repo/module/index/.cm/*',
'repo/module/kernel/*.py',
'repo/module/kernel/.cm/*',
'repo/module/kernel/test/test*.py',
'repo/module/module/*.py',
'repo/module/module/*.input',
'repo/module/module/.cm/*',
'repo/module/repo/*.py',
'repo/module/repo/.cm/*',
'repo/module/cfg/*.py',
'repo/module/cfg/.cm/*',
'repo/module/test/*.py',
'repo/module/test/.cm/*',
'repo/module/tmp/*.py',
'repo/module/tmp/.cm/*',
'repo/module/web/*.py',
'repo/module/web/.cm/*',
'repo/module/web/php/*.php',
'repo/module/web/php/server-side/*',
'repo/repo/.cm/*',
'repo/repo/default/.cm/*',
'repo/repo/local/.cm/*',
'repo/repo/remote-ck/.cm/*',
'repo/test/.cm/*',
'repo/test/unicode/c*',
'repo/test/unicode/t*',
'repo/test/unicode/.cm/*',
'repo/test/unicode/dir/*']},
scripts = ["bin/ck" ,"bin/ck.bat"],
cmdclass={
'install': custom_install,
'install_scripts': custom_install_scripts
},
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Environment :: Plugins",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering",
"Topic :: Software Development",
"Topic :: System",
"Topic :: System :: Benchmark",
"Topic :: Education",
"Topic :: Home Automation",
"Topic :: Adaptive Technologies",
"Topic :: Database",
"Topic :: Utilities"
]
)