Commit 162043e3 authored by Mark Lodato's avatar Mark Lodato

freeze: add -o option for setting output file

parent 986559fb
......@@ -7,7 +7,7 @@ cython_freeze - create a C file for embedding Cython modules
SYNOPSIS
========
cython_freeze module [...]
cython_freeze [-o outfile] module [...]
DESCRIPTION
......@@ -28,6 +28,12 @@ simplicity. This module, on the other hand, can be used with multiple
modules, but it requires another C source file to be created.
OPTIONS
=======
-o FILE, --outfile=FILE write output to FILE instead of standard output
EXAMPLE
=======
......
......@@ -8,9 +8,11 @@ See Demos/freeze/README.rst for more details.
import optparse
usage= '%prog module [module ...]'
usage= '%prog [-o outfile] module [module ...]'
description = 'Create a C file for embedding Cython modules.'
p = optparse.OptionParser(usage=usage, description=description)
p.add_option('-o', '--output', metavar='FILE',
help='write output to FILE instead of standard output')
options, args = p.parse_args()
......@@ -18,6 +20,11 @@ if len(args) < 1:
p.print_help()
p.exit(1)
if options.output:
import sys
old_stdout = sys.stdout
sys.stdout = open(options.output, 'w')
def format_modname(name):
if name.endswith('.pyx'):
name = name[:-4]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment