From 0855d80eec1435f0d4bd656271164077c19f0f07 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Tue, 10 Nov 2009 22:41:07 -0800 Subject: [PATCH] Optional setuptools-based cython build --- Cython/Compiler/Main.py | 2 ++ setup.py | 21 ++++++++++++++++++--- setupegg.py | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 setupegg.py diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index 67a8a1da..1bc90028 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -741,6 +741,8 @@ def compile(source, options = None, c_compile = 0, c_link = 0, # Main command-line entry point # #------------------------------------------------------------------------ +def setuptools_main(): + return main(command_line = 1) def main(command_line = 0): args = sys.argv[1:] diff --git a/setup.py b/setup.py index 67571793..627affb6 100644 --- a/setup.py +++ b/setup.py @@ -40,10 +40,24 @@ else: 'Compiler/*.pxd', 'Runtime/*.pyx']} -if os.name == "posix": - scripts = ["bin/cython"] +# This dict is used for passing extra arguments that are setuptools +# specific to setup +setuptools_extra_args = {} + +if 'setuptools' in sys.modules: + setuptools_extra_args['zip_safe'] = False + setuptools_extra_args['entry_points'] = { + 'console_scripts': [ + 'cython = Cython.Compiler.Main:setuptools_main', + ] + } + scripts = [] else: - scripts = ["cython.py"] + if os.name == "posix": + scripts = ["bin/cython"] + else: + scripts = ["cython.py"] + try: if sys.version_info[0] >= 3: @@ -93,6 +107,7 @@ except ValueError: print("ERROR: %s" % sys.exc_info()[1]) print("Extension module compilation failed, using plain Python implementation") +setup_args.update(setuptools_extra_args) from Cython.Compiler.Version import version diff --git a/setupegg.py b/setupegg.py new file mode 100644 index 00000000..cf97861b --- /dev/null +++ b/setupegg.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +"""Wrapper to run setup.py using setuptools.""" +import setuptools +execfile('setup.py') -- 2.26.2