Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 163 lines (121 sloc) 4.996 kb
dc5153e @fperez Make a separate fff2 setup, so that only users who actually need fff2 ge...
fperez authored
1 #!/usr/bin/env python
a9cf398 consolidate package listing and version info into neuroimaging package
brian.hawthorne authored
2 import sys
cb12cff @GaelVaroquaux ENH: Add functions for downloading core data files, as well as examples.
GaelVaroquaux authored
3 import os
4 import tarfile
a56370f @matthew-brett Fleshed out separate template and example data archives
matthew-brett authored
5 import tempfile
cb12cff @GaelVaroquaux ENH: Add functions for downloading core data files, as well as examples.
GaelVaroquaux authored
6 from distutils import log
a56370f @matthew-brett Fleshed out separate template and example data archives
matthew-brett authored
7 from distutils.cmd import Command
85c3399 added numpy-aware version of traits to repository -- a la matplotlib
jonathan.taylor authored
8
e3bff88 move more stuff over to use numpy.distutils including the main setup.py
tim.leslie authored
9 def configuration(parent_package='',top_path=None):
10 from numpy.distutils.misc_util import Configuration
11
12 config = Configuration(None, parent_package, top_path)
13 config.set_options(ignore_setup_xxx_py=True,
14 assume_default_configuration=True,
371cb7b Silence 'Ignoring attempt to set name...' warnings on build.
Christopher Burns authored
15 delegate_options_to_subpackages=True,
16 quiet=True)
17 # The quiet=True option will silence all of the name setting warnings:
03acb09 More replacing of neuroimaging with nipy
Christopher Burns authored
18 # Ignoring attempt to set 'name' (from 'nipy.core' to
19 # 'nipy.core.image')
371cb7b Silence 'Ignoring attempt to set name...' warnings on build.
Christopher Burns authored
20 # Robert Kern recommends setting quiet=True on the numpy list, stating
21 # these messages are probably only used in debugging numpy distutils.
fd84499 make .__version__ work from the source tree as well as an installed setu...
tim.leslie authored
22
03acb09 More replacing of neuroimaging with nipy
Christopher Burns authored
23 config.get_version('nipy/version.py') # sets config.version
fd84499 make .__version__ work from the source tree as well as an installed setu...
tim.leslie authored
24
03acb09 More replacing of neuroimaging with nipy
Christopher Burns authored
25 config.add_subpackage('nipy', 'nipy')
371cb7b Silence 'Ignoring attempt to set name...' warnings on build.
Christopher Burns authored
26
0960f64 more distutils stuff
tim.leslie authored
27 return config
e3bff88 move more stuff over to use numpy.distutils including the main setup.py
tim.leslie authored
28
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
29 ################################################################################
30 # For some commands, use setuptools
e3bff88 move more stuff over to use numpy.distutils including the main setup.py
tim.leslie authored
31
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
32 if len(set(('develop', 'bdist_egg', 'bdist_rpm', 'bdist', 'bdist_dumb',
33 'bdist_wininst', 'install_egg_info', 'egg_info', 'easy_install',
34 )).intersection(sys.argv)) > 0:
35 from setup_egg import extra_setuptools_args
36
33afd43 @matthew-brett Removed coverage requirement, small docstring, message string changes
matthew-brett authored
37 # extra_setuptools_args can be defined from the line above, but it can
38 # also be defined here because setup.py has been exec'ed from
39 # setup_egg.py.
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
40 if not 'extra_setuptools_args' in globals():
41 extra_setuptools_args = dict()
42
43
44 ################################################################################
0a14439 @GaelVaroquaux ENH: Make the doc building robust by installing to a temp directory
GaelVaroquaux authored
45 # Import the documentation building classes.
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
46
0a14439 @GaelVaroquaux ENH: Make the doc building robust by installing to a temp directory
GaelVaroquaux authored
47 try:
48 from build_docs import cmdclass
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
49 except ImportError:
33afd43 @matthew-brett Removed coverage requirement, small docstring, message string changes
matthew-brett authored
50 """ Pass by the doc build gracefully if sphinx is not installed """
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
51 print "Sphinx is not installed, docs cannot be built"
52 cmdclass = {}
53
54
55 ################################################################################
cb12cff @GaelVaroquaux ENH: Add functions for downloading core data files, as well as examples.
GaelVaroquaux authored
56 # commands for installing the data
57 from distutils.command.install import install
58 from numpy.distutils.command.build_ext import build_ext
59
a56370f @matthew-brett Fleshed out separate template and example data archives
matthew-brett authored
60
61 def get_nipy_info():
62 ''' Fetch NIPY info from NIPY setup file
63
64 Get from nipy.setup without importing (as the package is not yet
65 installed
66 '''
cb12cff @GaelVaroquaux ENH: Add functions for downloading core data files, as well as examples.
GaelVaroquaux authored
67 ns = dict(__name__='')
68 execfile(os.path.join('nipy', 'setup.py'), ns)
a56370f @matthew-brett Fleshed out separate template and example data archives
matthew-brett authored
69 return ns['get_nipy_info']()
70
71
72 def install_data_tgz():
73 """ Check if the data is there, install from tarball if not
74 """
75 for dkey, tarname, descrip in (('template_dir',
76 'nipy_templates.tar.gz',
77 'templates'),
78 ('example_data_dir',
79 'nipy_example_data.tar.gz',
80 'example data')):
81 data_dir = get_nipy_info()[dkey]
82 if not os.path.exists(os.path.expanduser(data_dir)):
83 if os.path.exists(tarname):
84 log.info('extracting data tarball to %s' % data_dir)
85 tar = tarfile.open(tarname)
86 tar.extractall(data_dir)
87 tar.close()
88 continue
89 msg = """
90 We did not find the nipy data directory '%(data_dir)s'.
91 Neither could we find the archive '%(tarname)s' in the current directory.
92 If you want the NIPY %(descrip)s please download
93
94 https://cirl.berkeley.edu/nipy/%(tarname)s
95
96 and run
97
98 python setup.py data_install
99
100 in this directory
101 """ % locals()
102 log.warn(80*"_" + msg + 80*"_")
cb12cff @GaelVaroquaux ENH: Add functions for downloading core data files, as well as examples.
GaelVaroquaux authored
103
104
105 class MyInstall(install):
106 """ Subclass the install to install also the data, if present.
107 """
108 def run(self):
109 install.run(self)
110 install_data_tgz()
111
112
113 class MyBuildExt(build_ext):
114 """ Subclass the 'build_ext --inplace' to install the data, if present.
115 """
116 def run(self):
117 build_ext.run(self)
118 if self.inplace:
119 install_data_tgz()
120
121
a56370f @matthew-brett Fleshed out separate template and example data archives
matthew-brett authored
122 class DataInstall(Command):
123 description = 'unpack templates and example data'
124 user_options = [('None', None, 'this command has no options')]
125
126 def run(self):
127 install_data_tgz()
128
129 def initialize_options(self):
130 pass
131
132 def finalize_options(self):
133 pass
134
135
136
137 cmdclass['data_install'] = DataInstall
cb12cff @GaelVaroquaux ENH: Add functions for downloading core data files, as well as examples.
GaelVaroquaux authored
138 cmdclass['install'] = MyInstall
139 cmdclass['build_ext'] = MyBuildExt
140
141
142 ################################################################################
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
143
0a14439 @GaelVaroquaux ENH: Make the doc building robust by installing to a temp directory
GaelVaroquaux authored
144 # We need to import nipy as late as possible,
145 from nipy import __doc__
146
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
147 def main(**extra_args):
e3bff88 move more stuff over to use numpy.distutils including the main setup.py
tim.leslie authored
148 from numpy.distutils.core import setup
fd84499 make .__version__ work from the source tree as well as an installed setu...
tim.leslie authored
149
03acb09 More replacing of neuroimaging with nipy
Christopher Burns authored
150 setup( name = 'nipy',
525d16a latest commit -- now setup.py builds a module "neuroimaging", see "tests...
jonathan.taylor authored
151 description = 'This is a neuroimaging python package',
85c3399 added numpy-aware version of traits to repository -- a la matplotlib
jonathan.taylor authored
152 author = 'Various',
153 author_email = 'nipy-devel@neuroimaging.scipy.org',
525d16a latest commit -- now setup.py builds a module "neuroimaging", see "tests...
jonathan.taylor authored
154 url = 'http://neuroimaging.scipy.org',
e3bff88 move more stuff over to use numpy.distutils including the main setup.py
tim.leslie authored
155 long_description = __doc__,
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
156 configuration = configuration,
157 cmdclass = cmdclass,
158 **extra_args)
525d16a latest commit -- now setup.py builds a module "neuroimaging", see "tests...
jonathan.taylor authored
159
160
566863d clean up
jarrod.millman authored
161 if __name__ == "__main__":
a37e6a8 @GaelVaroquaux ENH: Add commands to the setup.py to enable documentation building and s...
GaelVaroquaux authored
162 main(**extra_setuptools_args)
Something went wrong with that request. Please try again.