From 52d92404e82187f28070af7c21c3520c2f254868 2015-01-22 20:49:51 From: Jason Grout Date: 2015-01-22 20:49:51 Subject: [PATCH] Work around a bug in setting and getting the mtime in python 2 See http://bugs.python.org/issue12904. Basically, we can get the mtime in nanosecond precision, but only set it in microsecond precision. This means that the shutil.copy2 will not set the destination's mtime to exactly the same mtime as our source. The end result is that we can *always* end up copying the extension because the source always appears newer. We add a microsecond of fudge time when checking to see if the source is newer than the destination to get around this. This bug is fixed in Python 3.3+, I believe. --- diff --git a/IPython/html/nbextensions.py b/IPython/html/nbextensions.py index 0b51b56..d045c06 100644 --- a/IPython/html/nbextensions.py +++ b/IPython/html/nbextensions.py @@ -61,7 +61,9 @@ def _should_copy(src, dest, verbose=1): """should a file be copied?""" if not os.path.exists(dest): return True - if os.stat(dest).st_mtime < os.stat(src).st_mtime: + if os.stat(src).st_mtime - os.stat(dest).st_mtime > 1e-6: + # we add a fudge factor to work around a bug in python 2.x + # that was fixed in python 3.x: http://bugs.python.org/issue12904 if verbose >= 2: print("%s is out of date" % dest) return True