'type inference' for special temp nodes
[cython.git] / setup.py
index fe69cdb275f3650c01a7bc09a9bacf14e9c58a02..90c125f4ee001bc8032b8ce7742cd96b25466c94 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -2,12 +2,27 @@ from distutils.core import setup, Extension
 from distutils.sysconfig import get_python_lib
 import os, os.path
 import sys
-from Cython.Compiler.Version import version
+
+if 'sdist' in sys.argv:
+    # Record the current revision in .hgrev
+    import subprocess # os.popen is cleaner but depricated
+    changset = subprocess.Popen("hg log --rev tip | grep changeset", 
+                                shell=True,
+                                stdout=subprocess.PIPE).stdout.read()
+    rev = changset.split(':')[-1].strip()
+    hgrev = open('.hgrev', 'w')
+    hgrev.write(rev)
+    hgrev.close()
 
 compiler_dir = os.path.join(get_python_lib(prefix=''), 'Cython/Compiler')
 if sys.platform == "win32":
     compiler_dir = compiler_dir[len(sys.prefix)+1:]
 
+if sys.platform == "darwin":
+    # Don't create resource files on OS X tar.
+    os.environ['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
+    os.environ['COPYFILE_DISABLE'] = 'true'
+
 setup_args = {}
 
 if sys.version_info[0] >= 3:
@@ -41,10 +56,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:
@@ -94,6 +123,9 @@ 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
 
 setup(
   name = 'Cython',
@@ -125,6 +157,8 @@ setup(
     "License :: OSI Approved :: Apache Software License",
     "Operating System :: OS Independent",
     "Programming Language :: Python",
+    "Programming Language :: Python :: 2",
+    "Programming Language :: Python :: 3",
     "Programming Language :: C",
     "Programming Language :: Cython",
     "Topic :: Software Development :: Code Generators",