forked from lisa-lab/pylearn2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
87 lines (80 loc) · 3.88 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
from __future__ import print_function
import warnings
from setuptools import setup, find_packages, Extension
from setuptools.command.install import install
import numpy
from theano.compat.six.moves import input
# Because many people neglected to run the pylearn2/utils/setup.py script
# separately, we compile the necessary Cython extensions here but because
# Cython is not a strict dependency, we issue a warning when it is not
# available.
try:
from Cython.Distutils import build_ext
cython_available = True
except ImportError:
warnings.warn("Cython was not found and hence pylearn2.utils._window_flip "
"and pylearn2.utils._video and classes that depend on them "
"(e.g. pylearn2.train_extensions.window_flip) will not be "
"available")
cython_available = False
if cython_available:
cmdclass = {'build_ext': build_ext}
ext_modules = [Extension("pylearn2.utils._window_flip",
["pylearn2/utils/_window_flip.pyx"],
include_dirs=[numpy.get_include()]),
Extension("pylearn2.utils._video",
["pylearn2/utils/_video.pyx"],
include_dirs=[numpy.get_include()])]
else:
cmdclass = {}
ext_modules = []
# Inform user of setup.py develop preference
class pylearn2_install(install):
def run(self):
print("Because Pylearn2 is under heavy development, we generally do "
"not advice using the `setup.py install` command. Please "
"consider using the `setup.py develop` command instead for the "
"following reasons:\n\n1. Using `setup.py install` creates a "
"copy of the Pylearn2 source code in your Python installation "
"path. In order to update Pylearn2 afterwards you will need to "
"rerun `setup.py install` (!). Simply using `git pull` to "
"update your local copy of Pylearn2 code will not suffice. \n\n"
"2. When using `sudo` to install Pylearn2, all files, "
"including the tutorials, will be copied to a directory owned "
"by root. Not only is running tutorials as root unsafe, it "
"also means that all Pylearn2-related environment variables "
"which were defined for the user will be unavailable.\n\n"
"Pressing enter will continue the installation of Pylearn2 in "
"`develop` mode instead. Note that this means that you need to "
"keep this folder with the Pylearn2 code in its current "
"location. If you know what you are doing, and are very sure "
"that you want to install Pylearn2 using the `install` "
"command instead, please type `install`.\n")
mode = None
while mode not in ['', 'install', 'develop', 'cancel']:
if mode is not None:
print("Please try again")
mode = input("Installation mode: [develop]/install/cancel: ")
if mode in ['', 'develop']:
self.distribution.run_command('develop')
if mode == 'install':
return install.run(self)
cmdclass.update({'install': pylearn2_install})
setup(
cmdclass=cmdclass,
ext_modules=ext_modules,
name='pylearn2',
version='0.1dev',
packages=find_packages(),
description='A machine learning library built on top of Theano.',
license='BSD 3-clause license',
long_description=open('README.rst', 'rb').read().decode('utf8'),
dependency_links=['git+http://github.com/Theano/Theano.git#egg=Theano'],
install_requires=['numpy>=1.5', 'pyyaml', 'argparse', "Theano"],
scripts=['bin/pylearn2-plot-monitor', 'bin/pylearn2-print-monitor',
'bin/pylearn2-show-examples', 'bin/pylearn2-show-weights',
'bin/pylearn2-train'],
package_data={
'': ['*.cu', '*.cuh', '*.h'],
},
)