From 2b4e5504af235b2c3d4f8a23f1b7a909a0e4b449 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 16 Feb 2012 01:00:49 +0800 Subject: [PATCH] Get pygit2 can be build under Windows. --- setup.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 3d72293..287da93 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ """Setup file for pygit2.""" +import os try: from setuptools import setup, Extension, Command SETUPTOOLS = True @@ -35,12 +36,23 @@ except ImportError: from distutils.core import setup, Extension, Command SETUPTOOLS = False - -# Replace with your libgit2 configuration. -include_dirs = ['/usr/local/include'] -library_dirs = ['/usr/local/lib'] +# Use environment variable LIBGIT2 to set your own libgit2 configuration. libraries = ['git2', 'z', 'crypto'] +if os.name == 'nt': + libraries = ['git2'] +libgit2_path = os.getenv("LIBGIT2") +if libgit2_path is None: + if os.name == 'nt': + program_files = os.getenv("ProgramFiles") + print(program_files) + libgit2_path = '%s\libgit2' % program_files + else: + libgit2_path = '/usr/local' + +libgit2_bin = os.path.join(libgit2_path, 'bin') +libgit2_include = os.path.join(libgit2_path, 'include') +libgit2_lib = os.path.join(libgit2_path, 'lib') class TestCommand(Command): """Command for running pygit2 tests.""" @@ -87,8 +99,8 @@ setup(name='pygit2', long_description=long_description, ext_modules = [ Extension('pygit2', ['pygit2.c'], - include_dirs=include_dirs, - library_dirs=library_dirs, + include_dirs=[libgit2_include], + library_dirs=[libgit2_lib], libraries=libraries), ], **kwargs)