<br><br><div class="gmail_quote">On Thu, Oct 4, 2012 at 12:14 AM, Matthew Brett <span dir="ltr"><<a href="mailto:matthew.brett@gmail.com" target="_blank">matthew.brett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<div><div class="h5"><br>
On Wed, Oct 3, 2012 at 10:51 PM, Ralf Gommers <<a href="mailto:ralf.gommers@gmail.com">ralf.gommers@gmail.com</a>> wrote:<br>
><br>
><br>
> On Wed, Oct 3, 2012 at 11:29 PM, Matthew Brett <<a href="mailto:matthew.brett@gmail.com">matthew.brett@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> On Wed, Oct 3, 2012 at 10:17 PM, Ralf Gommers <<a href="mailto:ralf.gommers@gmail.com">ralf.gommers@gmail.com</a>><br>
>> wrote:<br>
>> ><br>
>> ><br>
>> > On Mon, Oct 1, 2012 at 10:47 PM, Matthew Brett <<a href="mailto:matthew.brett@gmail.com">matthew.brett@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Hi,<br>
>> >><br>
>> >> On Mon, Oct 1, 2012 at 9:42 PM, Matthew Brett <<a href="mailto:matthew.brett@gmail.com">matthew.brett@gmail.com</a>><br>
>> >> wrote:<br>
>> >> > Hi,<br>
>> >> ><br>
>> >> > One of our kind users pointed out an error when using easy_install to<br>
>> >> > install our package nipy.   I've reproduced it now on a bare package<br>
>> >> > using numpy distutils and having a trivial extension:<br>
>> >> ><br>
>> >> > <a href="https://github.com/matthew-brett/apkg" target="_blank">https://github.com/matthew-brett/apkg</a><br>
>> >> ><br>
>> >> > To reproduce:<br>
>> >> ><br>
>> >> > git clone git://<a href="http://github.com/mathew-brett/apkg.git" target="_blank">github.com/mathew-brett/apkg.git</a><br>
>> >> ><br>
>> >> > easy_install apkg<br>
>> >> ><br>
>> >> > You should get something like this:<br>
>> >> ><br>
>> >> > Processing apkg<br>
>> >> > Running setup.py -q bdist_egg --dist-dir<br>
>> >> > /home/mb312/tmp/apkg/egg-dist-tmp-T5yjuB<br>
>> >> > Appending apkg configuration to<br>
>> >> > Ignoring attempt to set 'name' (from '' to 'apkg')<br>
>> >> > zip_safe flag not set; analyzing archive contents...<br>
>> >> > Adding apkg 0.1 to easy-install.pth file<br>
>> >> ><br>
>> >> > Installed<br>
>> >> ><br>
>> >> > /home/mb312/.virtualenvs/np-1.6.2/lib/python2.6/site-packages/apkg-0.1-py2.6-linux-i686.egg<br>
>> >> > Processing dependencies for apkg==0.1<br>
>> >> > Finished processing dependencies for apkg==0.1<br>
>> >> ><br>
>> >> ><br>
>> >> > /home/mb312/.virtualenvs/np-1.6.2/lib/python2.6/site-packages/numpy/distutils/misc_util.py:252:<br>
>> >> > RuntimeWarning: Parent module 'numpy.distutils' not found while<br>
>> >> > handling absolute import<br>
>> >> >   from numpy.distutils import log<br>
>> >> ><br>
>> >> > Note the last error.<br>
>> >><br>
>> >> Sorry, correcting myself - it's (obviously) a Warning rather than an<br>
>> >> error, but still distracting, and it would be good to avoid it if<br>
>> >> possible...<br>
>> ><br>
>> ><br>
>> > The combination of two or all of atexit.register, easy_install and<br>
>> > virtualenv seems to be causing this. Unless someone feels like digging<br>
>> > into<br>
>> > that (I certainly don't), there are two easy solutions:<br>
>> > 1. Silence the warning.<br>
>><br>
>> Sorry - I am not sure what you mean.  The problem here is the user who<br>
>> assumes that something bad happened when running easy_install - which<br>
>> is what happened in the case of nipy.  Is there some way of silencing<br>
>> this (specific) warning from within setup.py?<br>
>><br>
>> > 2. Remove the offending import and the logging. This will only remove<br>
>> > the<br>
>> > line "removing: _configtest.c _configtest.o" from the build log (x20).<br>
>><br>
>> Which import did you mean?  I think I need all the imports I'm using<br>
>> in the example minimal package.  I'm not explicitly importing logging<br>
>> for example.<br>
><br>
><br>
> The import that's indicated in the warning, on line 252 of<br>
> numpy/distutils/misc_util.py. Relevant code:<br>
><br>
> _temporary_directory = None<br>
> def clean_up_temporary_directory():<br>
>     from numpy.distutils import log    # CAUSES RUNTIME WARNING<br>
>     global _temporary_directory<br>
>     if not _temporary_directory:<br>
>         return<br>
>     log.debug('removing %s', _temporary_directory)<br>
>     try:<br>
>         shutil.rmtree(_temporary_directory)<br>
>     except OSError:<br>
>         pass<br>
>     _temporary_directory = None<br>
><br>
> def make_temp_file(suffix='', prefix='', text=True):<br>
>     global _temporary_directory<br>
>     if not _temporary_directory:<br>
>         _temporary_directory = tempfile.mkdtemp()<br>
>         atexit.register(clean_up_temporary_directory)<br>
<br>
</div></div>Sorry - I still don't understand.  You mean I should (in my package -<br>
say nipy or 'apkg') monkey-patch numpy distutils.misc_util ?<br></blockquote><div><br>No, I was proposing to fix this in numpy.distutils.misc_util directly. Sorry for not being clear.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Another option would be to move the import outside the callback function thus:<br></blockquote><div><br>Should work too I guess, but since I don't understand why the import is where it is now I'm not 100% sure. Removing the import on line 252 and the log.debug call would be the safest fix.<br>
<br>Ralf<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py<br>
index 2e4ed27..e00d924 100644<br>
--- a/numpy/distutils/misc_util.py<br>
+++ b/numpy/distutils/misc_util.py<br>
@@ -18,6 +18,7 @@ except NameError:<br>
     from sets import Set as set<br>
<br>
 from numpy.distutils.compat import get_exception<br>
+from numpy.distutils.log import debug as log_debug<br>
<br>
 __all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',<br>
            'dict_append', 'appendpath', 'generate_config_py',<br>
@@ -249,11 +250,10 @@ def gpaths(paths, local_path='',<br>
include_non_existing=True):<br>
<div class="im"><br>
 _temporary_directory = None<br>
 def clean_up_temporary_directory():<br>
</div>-    from numpy.distutils import log<br>
<div class="im">     global _temporary_directory<br>
     if not _temporary_directory:<br>
         return<br>
</div>-    log.debug('removing %s', _temporary_directory)<br>
+    log_debug('removing %s', _temporary_directory)<br>
     try:<br>
         shutil.rmtree(_temporary_directory)<br>
     except OSError:<br>
<br>
<br>
Do you happen to know if that will break anything?  Setup install runs for me...<br>
<div class="HOEnZb"><div class="h5"><br>
Cheers,<br>
<br>
Matthew<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br>