From 6bcf95f2e4ce47b31e9ab7edf6502909a4f9eb39 Mon Sep 17 00:00:00 2001
From: Tianqi Chen <tqchen@users.noreply.github.com>
Date: Thu, 15 Mar 2018 19:16:45 -0700
Subject: [PATCH] [CONTRIB] windows compatiblity (#1009)

---
 python/tvm/contrib/util.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/python/tvm/contrib/util.py b/python/tvm/contrib/util.py
index 338567d6f..e2b4011c4 100644
--- a/python/tvm/contrib/util.py
+++ b/python/tvm/contrib/util.py
@@ -2,8 +2,12 @@
 from __future__ import absolute_import as _abs
 import os
 import tempfile
-import fcntl
 import shutil
+try:
+    import fcntl
+except ImportError:
+    fcntl = None
+
 
 class TempDirectory(object):
     """Helper object to manage temp directory during testing.
@@ -70,13 +74,15 @@ class FileLock(object):
     """
     def __init__(self, path):
         self.lock_file = open(path, "w")
-        fcntl.lockf(self.lock_file, fcntl.LOCK_EX)
+        if fcntl:
+            fcntl.lockf(self.lock_file, fcntl.LOCK_EX)
 
 
     def release(self):
         """Release the lock"""
         if self.lock_file:
-            fcntl.lockf(self.lock_file, fcntl.LOCK_UN)
+            if fcntl:
+                fcntl.lockf(self.lock_file, fcntl.LOCK_UN)
             self.lock_file.close()
             self.lock_file = None
 
-- 
GitLab