forked from numenta/nupic-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
120 lines (101 loc) · 3.79 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
import sys
import os
import subprocess
from setuptools import setup
"""
This file only will call CMake process to generate scripts, build, and then install the NuPIC binaries.
ANY EXTRA code related to build process MUST be put into CMake file.
"""
repositoryDir = os.getcwd()
# Read command line options looking for extra options for CMake and Make
# For example, an user could type:
# python setup.py install make_options='-j3'
# which will add '-j3' option to Make commandline
cmakeOptions = ""
makeOptions = ""
setupOptions = ""
mustBuildExtensions = False
for arg in sys.argv:
if ("cmake_options" in arg) or ("make_options" in arg):
(option, _, rhs) = arg.partition("=")
if option[0] == "--cmake_options":
cmakeOptions = rhs
if option[0] == "--make_options":
makeOptions = rhs
elif (not "setup.py" in arg):
if ("build" in arg) or ("install" in arg):
mustBuildExtensions = True
setupOptions += arg + " "
# Get properties of the project like version, notes, etc
properties = {}
execfile(os.path.join(repositoryDir, "nupic", "__init__.py"), {}, properties)
def findPackages(repositoryDir):
"""
Traverse nupic directory and create packages for each subdir containing a
__init__.py file
"""
packages = []
for root, dirs, files in os.walk(repositoryDir + '/nupic'):
if '__init__.py' in files:
subdir = root.replace(repositoryDir + '/', '')
packages.append(subdir.replace('/', '.'))
return packages
def build_extensions_nupic():
"""
CMake-specific build operations
"""
# Prepare directories to the CMake process
sourceDir = repositoryDir
buildScriptsDir = repositoryDir + '/build/scripts'
if not os.path.exists(buildScriptsDir):
os.makedirs(buildScriptsDir)
os.chdir(buildScriptsDir)
# Generate build files with CMake
return_code = subprocess.call("cmake " + sourceDir + ' ' + cmakeOptions, shell=True)
if (return_code != 0):
sys.exit("Unable to generate build scripts!")
# Build library with Make
return_code = subprocess.call("make " + makeOptions, shell=True)
if (return_code != 0):
sys.exit("Unable to build the library!")
def setup_nupic():
"""
Package setup operations
"""
# Setup library
os.chdir(repositoryDir)
setup(
name = 'nupic',
version = properties["__version__"],
packages = findPackages(repositoryDir),
package_data = {
'nupic': ['README.md', 'LICENSE.txt', '*.so', '*.dll', '*.dylib'],
'nupic.bindings': ['_*.so', '_*.dll'],
'nupic.data': ['*.json'],
'nupic.frameworks.opf.exp_generator': ['*.json', '*.tpl'],
'nupic.frameworks.opf.jsonschema': ['*.json'],
'nupic.support.resources.images': ['*.png', '*.gif', '*.ico', '*.graffle'],
'nupic.swarming.jsonschema': ['*.json']},
description = 'Numenta Platform for Intelligent Computing',
author='Numenta',
author_email='[email protected]',
url='https://github.com/numenta/nupic',
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: OS Independent',
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Artificial Intelligence'
],
long_description = """\
NuPIC is a library that provides the building blocks for online prediction systems. The library contains the Cortical Learning Algorithm (CLA), but also the Online Prediction Framework (OPF) that allows clients to build prediction systems out of encoders, models, and metrics.
For more information, see numenta.org or the NuPIC wiki (https://github.com/numenta/nupic/wiki).
"""
)
# Build and setup NuPIC
if mustBuildExtensions:
build_extensions_nupic()
setup_nupic()