From 25ed414a66d5c6d71871c80148bbe6c5bbf49570 Mon Sep 17 00:00:00 2001 From: Joe Jevnik Date: Mon, 20 Jun 2016 14:17:09 -0400 Subject: [PATCH] MAINT: use new tempdir for windows --- zipline/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/zipline/__init__.py b/zipline/__init__.py index 5dfe287b..a314ec72 100644 --- a/zipline/__init__.py +++ b/zipline/__init__.py @@ -12,6 +12,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import os + + +if os.name == 'nt': + # we need to be able to write to our temp directoy on windows so we + # create a subdir in %TMP% that has write access and use that as %TMP% + def _(): + import atexit + import tempfile + + tempfile.tempdir = tempdir = tempfile.mkdtemp() + + @atexit.register + def cleanup_tempdir(): + import shutil + shutil.rmtree(tempdir) + _() + del _ # This is *not* a place to dump arbitrary classes/modules for convenience,