diff options
author | Stefan Behnel <scoder@users.berlios.de> | 2011-04-15 18:22:59 +0200 |
---|---|---|
committer | Stefan Behnel <scoder@users.berlios.de> | 2011-04-15 18:22:59 +0200 |
commit | a0a27779ebf0312a2e179d299d5d3732b1259a80 (patch) | |
tree | 62cb1998cade3f30eb1ff930cfea00a68a24d040 /bin | |
parent | f8735fb85d4c7d45aeed08487e8e14c2cc8e7d13 (diff) | |
download | cython-a0a27779ebf0312a2e179d299d5d3732b1259a80.tar.gz |
moved cythonrun implementation into Cython/Build/BuildExecutable.py to make it generally available
--HG--
rename : bin/cythonrun => Cython/Build/BuildExecutable.py
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cythonrun | 82 |
1 files changed, 3 insertions, 79 deletions
diff --git a/bin/cythonrun b/bin/cythonrun index 4bdffc062..1c6195492 100755 --- a/bin/cythonrun +++ b/bin/cythonrun @@ -9,84 +9,8 @@ Basic usage: python cythonrun somefile.py [ARGS] """ -DEBUG = True - -import sys -import os -import subprocess -from distutils import sysconfig - -INCDIR = sysconfig.get_python_inc() -LIBDIR1 = sysconfig.get_config_var('LIBDIR') -LIBDIR2 = sysconfig.get_config_var('LIBPL') -PYLIB = sysconfig.get_config_var('LIBRARY')[3:-2] - -CC = sysconfig.get_config_var('CC') -CFLAGS = sysconfig.get_config_var('CFLAGS') + ' ' + os.environ.get('CFLAGS', '') -LINKCC = sysconfig.get_config_var('LINKCC') -LINKFORSHARED = sysconfig.get_config_var('LINKFORSHARED') -LIBS = sysconfig.get_config_var('LIBS') -SYSLIBS = sysconfig.get_config_var('SYSLIBS') - -if DEBUG: - def _debug(msg, *args): - if args: - msg = msg % args - sys.stderr.write(msg + '\n') -else: - def _debug(*args): - pass - -_debug('INCDIR: %s', INCDIR) -_debug('LIBDIR1: %s', LIBDIR1) -_debug('LIBDIR2: %s', LIBDIR2) -_debug('PYLIB: %s', PYLIB) - -def runcmd(cmd, shell=True): - if shell: - cmd = ' '.join(cmd) - _debug(cmd) - else: - _debug(' '.join(cmd)) - - returncode = subprocess.call(cmd, shell=shell) - if returncode: - sys.exit(returncode) - -def clink(basename): - runcmd([LINKCC, '-o', basename, basename+'.o', '-L'+LIBDIR1, '-L'+LIBDIR2, '-l'+PYLIB] - + LIBS.split() + SYSLIBS.split() + LINKFORSHARED.split()) - -def ccompile(basename): - runcmd([CC, '-c', '-o', basename+'.o', basename+'.c', '-I' + INCDIR] + CFLAGS.split()) - -def cycompile(input_file, options=()): - from Cython.Compiler import Version, CmdLine, Main - options, sources = CmdLine.parse_command_line(list(options or ()) + ['--embed', input_file]) - _debug('Using Cython %s to compile %s', Version.version, input_file) - result = Main.compile(sources, options) - if result.num_errors > 0: - sys.exit(1) - -def exec_file(basename, args=()): - runcmd([os.path.abspath(basename)] + list(args), shell=False) - -def main(args): - cy_args = [] - for i, arg in enumerate(args): - if arg.startswith('-'): - cy_args.append(arg) - else: - input_file = arg - args = args[i+1:] - break - else: - raise ValueError('no input file provided') - basename = os.path.splitext(input_file)[0] - cycompile(input_file, cy_args) - ccompile(basename) - clink(basename) - exec_file(basename, args) +from Cython.Build.BuildExecutable import build, build_and_run if __name__ == '__main__': - main(sys.argv[1:]) + import sys + build_and_run(sys.argv[1:]) |