From e7aca568653e94351ab80ee113961c8c18c50b38 Mon Sep 17 00:00:00 2001 From: lnyan Date: Sun, 2 Oct 2022 22:59:42 +0800 Subject: [PATCH] Update patch_match.py for win --- patch_match.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/patch_match.py b/patch_match.py index fea475c..583d5ec 100644 --- a/patch_match.py +++ b/patch_match.py @@ -14,15 +14,14 @@ import numpy as np from PIL import Image -try: - # If the Jacinle library (https://github.com/vacancy/Jacinle) is present, use its auto_travis feature. - from jacinle.jit.cext import auto_travis - auto_travis(__file__, required_files=['*.so']) -except ImportError as e: + +import os +if os.name!="nt": # Otherwise, fall back to the subprocess. import subprocess print('Compiling and loading c extensions from "{}".'.format(osp.realpath(osp.dirname(__file__)))) - subprocess.check_call(['./travis.sh'], cwd=osp.dirname(__file__)) + # subprocess.check_call(['./travis.sh'], cwd=osp.dirname(__file__)) + subprocess.check_call("make clean && make", cwd=osp.dirname(__file__), shell=True) __all__ = ['set_random_seed', 'set_verbose', 'inpaint', 'inpaint_regularity'] @@ -43,8 +42,12 @@ class CMatT(ctypes.Structure): ('dtype', ctypes.c_int) ] - -PMLIB = ctypes.CDLL(osp.join(osp.dirname(__file__), 'libpatchmatch.so')) +if os.name!="nt": + PMLIB = ctypes.CDLL(osp.join(osp.dirname(__file__), 'libpatchmatch.so')) +else: + if not os.path.exists(osp.join(osp.dirname(__file__), 'libpatchmatch.dll')): + pass + PMLIB = ctypes.CDLL(osp.join(osp.dirname(__file__), 'libpatchmatch.dll')) PMLIB.PM_set_random_seed.argtypes = [ctypes.c_uint] PMLIB.PM_set_verbose.argtypes = [ctypes.c_int]