Permalink
Browse files

BLD: generate sources using Cython at setup.py time

  • Loading branch information...
1 parent 907e47e commit 1040b16b9ea44a0b5180976096b80e1a2e27169c @pv pv committed Dec 21, 2012
Showing with 29 additions and 0 deletions.
  1. +10 −0 bscript
  2. +16 −0 setup.py
  3. +3 −0 setupscons.py
View
10 bscript
@@ -1,4 +1,6 @@
import sys
+import os
+import subprocess
from numpy.distutils.misc_util \
import \
@@ -122,6 +124,12 @@ def _set_mangling_var(conf, u, du, case, f2pycompat=True):
env.DEFINES.extend(macros)
+def _generate_cython():
+ cwd = os.path.dirname(__file__)
+ subprocess.call([sys.executable,
+ os.path.join(cwd, 'tools', 'cythonize'),
+ os.path.join(cwd, 'scipy')])
+
@hooks.post_configure
def post_configure(context):
opts = context.waf_options_context
@@ -174,6 +182,8 @@ def post_configure(context):
def pre_build(context):
bld = context.waf_context
+ _generate_cython()
+
context.register_category("gen_pymodule")
bld(features="gen_pymodule",
target="scipy/__config__.py",
View
@@ -125,6 +125,19 @@ def write_version_py(filename='scipy/version.py'):
a.close()
+def generate_cython():
+ cwd = os.path.dirname(__file__)
+ p = subprocess.Popen([sys.executable,
+ os.path.join(cwd, 'tools', 'cythonize'),
+ os.path.join(cwd, 'scipy')],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ out, err = p.communicate()
+ if p.returncode != 0:
+ print(out)
+ raise RuntimeError("Running cythonize failed!")
+
+
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration(None, parent_package, top_path)
@@ -147,6 +160,9 @@ def setup_package():
# Rewrite the version file everytime
write_version_py()
+ # Generate Cython sources
+ generate_cython()
+
setup(
name = 'scipy',
maintainer = "SciPy Developers",
View
@@ -50,6 +50,7 @@
try:
setup_py = __import__("setup")
write_version_py = setup_py.write_version_py
+ generate_cython = setup_py.generate_cython
finally:
sys.path.pop(0)
@@ -87,6 +88,8 @@ def setup_package():
write_version_py()
+ generate_cython()
+
try:
setup(
name = 'scipy',

0 comments on commit 1040b16

Please sign in to comment.