Skip to content

Commit

Permalink
debugging pygit2 setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Dec 4, 2017
1 parent 14bd54e commit 7689801
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions setup.py
Expand Up @@ -20,29 +20,33 @@
md = pkg_utils.get_package_metadata(dirname, name)

# set needed pygit2 version
import re
libgit2_path = os.getenv("LIBGIT2")
if not libgit2_path:
if os.name == 'nt':
libgit2_path = os.path.join(os.getenv("ProgramFiles"), 'libgit2')
try:
import pygit2
except:
import re
import warnings
libgit2_path = os.getenv("LIBGIT2")
if not libgit2_path:
if os.name == 'nt':
libgit2_path = os.path.join(os.getenv("ProgramFiles"), 'libgit2')
else:
libgit2_path = '/usr/local'
version_filename = os.path.join(libgit2_path, 'include', 'git2', 'version.h')

libgit2_version = None
if os.path.isfile(version_filename):
with open(version_filename, 'r') as file:
for line in file:
match = re.findall('define *LIBGIT2_VERSION *"(.*?)"', line.strip())
if match:
libgit2_version = match[0]
break

if libgit2_version:
md.extras_require['git'] = 'pygit2 == {}'.format(libgit2_version)
else:
libgit2_path = '/usr/local'
version_filename = os.path.join(libgit2_path, 'include', 'git2', 'version.h')

libgit2_version = None
if os.path.isfile(version_filename):
with open(version_filename, 'r') as file:
for line in file:
match = re.findall('define *LIBGIT2_VERSION *"(.*?)"', line.strip())
if match:
libgit2_version = match[0]
break

if libgit2_version:
md.extras_require['git'] = 'pygit2 == {}'.format(libgit2_version)
else:
warnings.warn(('wc_utils requires libgit2. Please install libgit2 and then retry installing '
'wc_utils. Please see https://libgit2.github.com for installation instructions.'))
warnings.warn(('wc_utils requires libgit2. Please install libgit2 and then retry installing '
'wc_utils. Please see https://libgit2.github.com for installation instructions.'))

# install package
setuptools.setup(
Expand Down

0 comments on commit 7689801

Please sign in to comment.