Skip to content

Commit

Permalink
Make “setup.py egg_info” work when run by pip.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilk committed Jul 30, 2016
1 parent c97574e commit b5bc99f
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,7 @@

import distutils.core
import distutils.version

try:
import Cython
except ImportError:
raise RuntimeError('Cython >= 0.19 is required')

try:
cython_version = Cython.__version__
except AttributeError:
# Cython prior to 0.14 didn't have __version__.
# Oh well. We don't support such old versions anyway.
cython_version = '0'
cython_version = distutils.version.LooseVersion(cython_version)
if cython_version < '0.19':
raise RuntimeError('Cython >= 0.19 is required')

import Cython.Build
import sys

def uopen(path):
if str != bytes:
Expand All @@ -66,7 +50,7 @@ def get_version():
Topic :: Software Development :: Testing
'''.strip().splitlines()

distutils.core.setup(
meta = dict(
name='python-afl',
version=get_version(),
license='MIT',
Expand All @@ -76,8 +60,41 @@ def get_version():
url='http://jwilk.net/software/python-afl',
author='Jakub Wilk',
author_email='[email protected]',
)

if 'setuptools' in sys.modules and sys.argv[1] == 'egg_info':
# We wouldn't normally want setuptools; but pip forces it upon us anyway,
# so let's abuse it to instruct pip to install Cython if it's missing.
distutils.core.setup(
install_requires=['Cython>=0.19'],
# Conceptually, “setup_requires” would make more sense than
# “install_requires”, but the former is not supported by pip:
# https://github.com/pypa/pip/issues/1820
**meta
)
sys.exit(0)

try:
import Cython
except ImportError:
raise RuntimeError('Cython >= 0.19 is required')

try:
cython_version = Cython.__version__
except AttributeError:
# Cython prior to 0.14 didn't have __version__.
# Oh well. We don't support such old versions anyway.
cython_version = '0'
cython_version = distutils.version.LooseVersion(cython_version)
if cython_version < '0.19':
raise RuntimeError('Cython >= 0.19 is required')

import Cython.Build

distutils.core.setup(
ext_modules=Cython.Build.cythonize('afl.pyx'),
scripts=['py-afl-fuzz'],
**meta
)

# vim:ts=4 sts=4 sw=4 et

0 comments on commit b5bc99f

Please sign in to comment.