Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no need to use setuptools_cython anymore #45

Merged
merged 1 commit into from
Nov 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
from __future__ import print_function
import os
import re
import sys
import pkg_resources
from glob import glob
from setuptools import setup, Extension
from setuptools.command.test import test as TestCommand


if sys.version[0] == '2':
# setuptools DWIM monkey-patch madness: http://dou.bz/37m3XL
if 'setuptools.extension' in sys.modules:
m = sys.modules['setuptools.extension']
m.Extension.__dict__ = m._Extension.__dict__


sources = (glob("src/*.cpp") +
["libmc/_client.pyx"])
include_dirs = ["include"]
Expand All @@ -21,6 +16,31 @@
"-Wall", "-DMC_USE_SMALL_VECTOR", "-O3", "-DNDEBUG"]


def is_installed(requirement):
try:
pkg_resources.require(requirement)
except pkg_resources.ResolutionError:
return False
else:
return True

# Resolving Cython dependency via 'setup_requires' requires setuptools >= 18.0:
# https://github.com/pypa/setuptools/commit/a811c089a4362c0dc6c4a84b708953dde9ebdbf8
setuptools_req = "setuptools >= 18.0"
if not is_installed(setuptools_req):
import textwrap
print(textwrap.dedent("""
setuptools >= 18.0 is required, and the dependency cannot be
automatically resolved with the version of setuptools that is
currently installed (%s).

you can upgrade setuptools:
$ pip install -U setuptools
""" % pkg_resources.get_distribution("setuptools").version),
file=sys.stderr)
exit(1)


def find_version(*file_paths):
with open(os.path.join(*file_paths)) as fhandler:
version_file = fhandler.read()
Expand Down Expand Up @@ -71,7 +91,7 @@ def run_tests(self):
"Topic :: Software Development :: Libraries"
],
# Support for the basestring type is new in Cython 0.20.
setup_requires=["setuptools_cython", "Cython >= 0.20"],
setup_requires=["Cython >= 0.20"],
cmdclass={"test": PyTest},
ext_modules=[
Extension("libmc._client", sources, include_dirs=include_dirs,
Expand Down