Merge remote-tracking branch 'opebeat/cffi-install-fix'
This commit is contained in:
46
setup.py
46
setup.py
@@ -31,8 +31,9 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import codecs
|
import codecs
|
||||||
from distutils.core import setup, Extension, Command
|
from setuptools import setup, Extension, Command
|
||||||
from distutils.command.build import build
|
from distutils.command.build import build
|
||||||
|
|
||||||
from distutils.command.sdist import sdist
|
from distutils.command.sdist import sdist
|
||||||
from distutils import log
|
from distutils import log
|
||||||
import os
|
import os
|
||||||
@@ -101,8 +102,20 @@ class TestCommand(Command):
|
|||||||
test_argv = test_argv0 + shlex.split(self.args)
|
test_argv = test_argv0 + shlex.split(self.args)
|
||||||
unittest.main(None, defaultTest='test.test_suite', argv=test_argv)
|
unittest.main(None, defaultTest='test.test_suite', argv=test_argv)
|
||||||
|
|
||||||
|
class CFFIBuild(build):
|
||||||
|
"""Hack to combat the chicken and egg problem that we need cffi
|
||||||
|
to add cffi as an extension.
|
||||||
|
"""
|
||||||
|
def finalize_options(self):
|
||||||
|
# This ffi is pygit2.ffi due to the path trick used in the beginning
|
||||||
|
# of the file
|
||||||
|
from ffi import ffi
|
||||||
|
|
||||||
class BuildWithDLLs(build):
|
self.distribution.ext_modules.append(ffi.verifier.get_extension())
|
||||||
|
build.finalize_options(self)
|
||||||
|
|
||||||
|
|
||||||
|
class BuildWithDLLs(CFFIBuild):
|
||||||
|
|
||||||
# On Windows, we install the git2.dll too.
|
# On Windows, we install the git2.dll too.
|
||||||
def _get_dlls(self):
|
def _get_dlls(self):
|
||||||
@@ -155,15 +168,6 @@ class sdist_files_from_git(sdist):
|
|||||||
self.filelist.remove_duplicates()
|
self.filelist.remove_duplicates()
|
||||||
self.write_manifest()
|
self.write_manifest()
|
||||||
|
|
||||||
|
|
||||||
cmdclass = {
|
|
||||||
'test': TestCommand,
|
|
||||||
'sdist': sdist_files_from_git}
|
|
||||||
|
|
||||||
if os.name == 'nt':
|
|
||||||
# BuildWithDLLs can copy external DLLs into source directory.
|
|
||||||
cmdclass['build'] = BuildWithDLLs
|
|
||||||
|
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
@@ -173,10 +177,18 @@ classifiers = [
|
|||||||
with codecs.open('README.rst', 'r', 'utf-8') as readme:
|
with codecs.open('README.rst', 'r', 'utf-8') as readme:
|
||||||
long_description = readme.read()
|
long_description = readme.read()
|
||||||
|
|
||||||
# This ffi is pygit2.ffi due to the path trick used in the beginning
|
|
||||||
# of the file
|
cmdclass = {
|
||||||
from ffi import ffi
|
'test': TestCommand,
|
||||||
ffi_ext = ffi.verifier.get_extension()
|
'sdist': sdist_files_from_git}
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
# BuildWithDLLs can copy external DLLs into source directory.
|
||||||
|
cmdclass['build'] = BuildWithDLLs
|
||||||
|
else:
|
||||||
|
# Build cffi
|
||||||
|
cmdclass['build'] = CFFIBuild
|
||||||
|
|
||||||
|
|
||||||
setup(name='pygit2',
|
setup(name='pygit2',
|
||||||
description='Python bindings for libgit2.',
|
description='Python bindings for libgit2.',
|
||||||
@@ -190,12 +202,14 @@ setup(name='pygit2',
|
|||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
packages=['pygit2'],
|
packages=['pygit2'],
|
||||||
package_data={'pygit2': ['decl.h']},
|
package_data={'pygit2': ['decl.h']},
|
||||||
|
setup_requires=['cffi'],
|
||||||
install_requires=['cffi'],
|
install_requires=['cffi'],
|
||||||
|
zip_safe=False,
|
||||||
ext_modules=[
|
ext_modules=[
|
||||||
Extension('_pygit2', pygit2_exts,
|
Extension('_pygit2', pygit2_exts,
|
||||||
include_dirs=[libgit2_include, 'include'],
|
include_dirs=[libgit2_include, 'include'],
|
||||||
library_dirs=[libgit2_lib],
|
library_dirs=[libgit2_lib],
|
||||||
libraries=['git2']),
|
libraries=['git2']),
|
||||||
ffi_ext,
|
# FFI is added in the build step
|
||||||
],
|
],
|
||||||
cmdclass=cmdclass)
|
cmdclass=cmdclass)
|
||||||
|
Reference in New Issue
Block a user