Skip to content

Commit

Permalink
Optional setuptools-based cython build
Browse files Browse the repository at this point in the history
  • Loading branch information
cournape committed Nov 11, 2009
1 parent 8b27f1d commit 0855d80
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Cython/Compiler/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand Down
21 changes: 18 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,24 @@
'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:
Expand Down Expand Up @@ -93,6 +107,7 @@ def build_extension(self, ext, *args, **kargs):
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

Expand Down
4 changes: 4 additions & 0 deletions setupegg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python
"""Wrapper to run setup.py using setuptools."""
import setuptools
execfile('setup.py')

0 comments on commit 0855d80

Please sign in to comment.