23
23
24
24
PY_LIB_SDIR = 'pylib'
25
25
26
- def sys_print_info (mod_name , pkg_path ):
27
- ''' Run info print in own process in anonymous path
26
+ def run_mod_cmd (mod_name , pkg_path , cmd ):
27
+ ''' Run command in own process in anonymous path
28
+
29
+ Parameters
30
+ ----------
31
+ mod_name : str
32
+ Name of module to import - e.g. 'nibabel'
33
+ pkg_path : str
34
+ directory containing `mod_name` package. Typically that will be the
35
+ directory containing the e.g. 'nibabel' directory.
28
36
'''
29
37
cwd = os .getcwd ()
30
38
tmpdir = tempfile .mkdtemp ()
@@ -33,10 +41,10 @@ def sys_print_info(mod_name, pkg_path):
33
41
my_call ('python -c "import sys; sys.path.insert(1,\' %s\' ); '
34
42
'import %s;'
35
43
'print %s.__file__;'
36
- 'print %s.get_info() "' % (pkg_path ,
37
- mod_name ,
38
- mod_name ,
39
- mod_name ))
44
+ '%s "' % (pkg_path ,
45
+ mod_name ,
46
+ mod_name ,
47
+ cmd ))
40
48
finally :
41
49
os .chdir (cwd )
42
50
shutil .rmtree (tmpdir )
@@ -131,8 +139,6 @@ def contexts_print_info(mod_name, repo_path, install_path):
131
139
path into which to install temporary installations
132
140
'''
133
141
site_pkgs_path = os .path .join (install_path , PY_LIB_SDIR )
134
- py_lib_locs = ' --install-purelib=%s --install-platlib=%s' % (
135
- site_pkgs_path , site_pkgs_path )
136
142
# first test archive
137
143
pwd = os .path .abspath (os .getcwd ())
138
144
out_fname = pjoin (install_path , 'test.zip' )
@@ -146,19 +152,20 @@ def contexts_print_info(mod_name, repo_path, install_path):
146
152
site_pkgs_path = install_from_to (install_from ,
147
153
install_path ,
148
154
PY_LIB_SDIR )
149
- sys_print_info (mod_name , site_pkgs_path )
155
+ cmd_str = 'print %s.get_info()' % mod_name
156
+ run_mod_cmd (mod_name , site_pkgs_path , cmd_str )
150
157
# now test install into a directory from the repository
151
158
site_pkgs_path = install_from_to (repo_path ,
152
159
install_path ,
153
160
PY_LIB_SDIR )
154
- sys_print_info (mod_name , site_pkgs_path )
161
+ run_mod_cmd (mod_name , site_pkgs_path , cmd_str )
155
162
# Take the opportunity to audit the py files
156
163
repo_mod_path = os .path .join (repo_path , mod_name )
157
164
install_mod_path = os .path .join (site_pkgs_path , mod_name )
158
165
print 'Files not taken across by the installation:'
159
166
print check_installed_files (repo_mod_path , install_mod_path )
160
167
# test from development tree
161
- sys_print_info (mod_name , repo_path )
168
+ run_mod_cmd (mod_name , repo_path , cmd_str )
162
169
return
163
170
164
171
@@ -181,3 +188,25 @@ def info_from_here(mod_name):
181
188
shutil .rmtree (install_path )
182
189
183
190
191
+ def tests_installed (mod_name , repo_path = None ):
192
+ """ Install from `repo_path` into temporary directory; run tests
193
+
194
+ Parameters
195
+ ----------
196
+ mod_name : str
197
+ name of module - e.g. 'nibabel'
198
+ repo_path : None or str
199
+ Path from which to install. If None, defaults to working directory
200
+ """
201
+ if repo_path is None :
202
+ repo_path = os .path .abspath (os .getcwd ())
203
+ install_path = tempfile .mkdtemp ()
204
+ try :
205
+ site_pkgs_path = install_from_to (repo_path ,
206
+ install_path ,
207
+ PY_LIB_SDIR )
208
+ run_mod_cmd (mod_name , site_pkgs_path , mod_name + '.test()' )
209
+ finally :
210
+ shutil .rmtree (install_path )
211
+
212
+
0 commit comments