From df0e11726e7c0cad461244c111b1e803c94ca416 Mon Sep 17 00:00:00 2001 From: Michael Sondergaard Date: Wed, 26 Nov 2014 06:04:40 +0100 Subject: [PATCH] Make pygit work in a frozen environment --- .gitattributes | 1 + pygit2/_utils.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..6e4f5d261 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.h text eol=lf diff --git a/pygit2/_utils.py b/pygit2/_utils.py index 9ecb35bb1..2ce828585 100644 --- a/pygit2/_utils.py +++ b/pygit2/_utils.py @@ -79,7 +79,11 @@ def get_ffi(): ffi = cffi.FFI() # Load C definitions - dir_path = dirname(abspath(inspect.getfile(inspect.currentframe()))) + if getattr(sys, 'frozen', False): + dir_path = dirname(abspath(sys.executable)) + else: + dir_path = dirname(abspath(__file__)) + decl_path = os.path.join(dir_path, 'decl.h') with codecs.open(decl_path, 'r', 'utf-8') as header: ffi.cdef(header.read())