Commit 6965934d authored by Stefan Behnel's avatar Stefan Behnel

merge

parents 32b1a50f c37a4543
...@@ -27,6 +27,9 @@ Options: ...@@ -27,6 +27,9 @@ Options:
performing any binary operations. performing any binary operations.
--cleanup <level> Release interned objects on python exit, for memory debugging. --cleanup <level> Release interned objects on python exit, for memory debugging.
Level indicates aggressiveness, default 0 releases nothing. Level indicates aggressiveness, default 0 releases nothing.
-w, --working <directory> Sets the working directory for Cython (the directory modules
are searched from)
-D, --no-docstrings Remove docstrings. -D, --no-docstrings Remove docstrings.
-a, --annotate Produce an colorized version of the source. -a, --annotate Produce an colorized version of the source.
--convert-range Convert for loops using range() function to for...from loops. --convert-range Convert for loops using range() function to for...from loops.
...@@ -104,6 +107,8 @@ def parse_command_line(args): ...@@ -104,6 +107,8 @@ def parse_command_line(args):
options.include_path.append(get_param(option)) options.include_path.append(get_param(option))
elif option == "--include-dir": elif option == "--include-dir":
options.include_path.append(pop_arg()) options.include_path.append(pop_arg())
elif option in ("-w", "--working"):
options.working_path = pop_arg()
elif option in ("-o", "--output-file"): elif option in ("-o", "--output-file"):
options.output_file = pop_arg() options.output_file = pop_arg()
elif option in ("-p", "--embed-positions"): elif option in ("-p", "--embed-positions"):
......
...@@ -4083,9 +4083,8 @@ bad: ...@@ -4083,9 +4083,8 @@ bad:
cpp_exception_utility_code = [ cpp_exception_utility_code = [
""" """
static int __Pyx_CppExn2PyErr(); /*proto*/ #ifndef __Pyx_CppExn2PyErr
""",""" static void __Pyx_CppExn2PyErr() {
void __Pyx_CppExn2PyErr() {
try { try {
if (PyErr_Occurred()) if (PyErr_Occurred())
; // let the latest Python exn pass through and ignore the current one ; // let the latest Python exn pass through and ignore the current one
...@@ -4102,6 +4101,7 @@ void __Pyx_CppExn2PyErr() { ...@@ -4102,6 +4101,7 @@ void __Pyx_CppExn2PyErr() {
PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
} }
} }
"""] #endif
""",""]
#------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------
...@@ -328,6 +328,8 @@ def main(command_line = 0): ...@@ -328,6 +328,8 @@ def main(command_line = 0):
sources = args sources = args
if options.show_version: if options.show_version:
sys.stderr.write("Cython version %s\n" % Version.version) sys.stderr.write("Cython version %s\n" % Version.version)
if options.working_path!="":
os.chdir(options.working_path)
context = Context(options.include_path) context = Context(options.include_path)
for source in sources: for source in sources:
try: try:
...@@ -355,7 +357,8 @@ default_options = dict( ...@@ -355,7 +357,8 @@ default_options = dict(
cplus = 0, cplus = 0,
output_file = None, output_file = None,
generate_pxi = 0, generate_pxi = 0,
transforms = Transform.TransformSet()) transforms = Transform.TransformSet(),
working_path = "")
if sys.platform == "mac": if sys.platform == "mac":
from Cython.Mac.MacSystem import c_compile, c_link, CCompilerError from Cython.Mac.MacSystem import c_compile, c_link, CCompilerError
......
...@@ -347,7 +347,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -347,7 +347,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self.generate_typeobject_predeclaration(entry, code) self.generate_typeobject_predeclaration(entry, code)
self.generate_exttype_vtable_struct(entry, code) self.generate_exttype_vtable_struct(entry, code)
self.generate_exttype_vtabptr_declaration(entry, code) self.generate_exttype_vtabptr_declaration(entry, code)
def generate_declarations_for_modules(self, env, modules, code): def generate_declarations_for_modules(self, env, modules, code):
code.putln("") code.putln("")
code.putln("/* Declarations */") code.putln("/* Declarations */")
...@@ -770,13 +770,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -770,13 +770,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"static void %s(PyObject *o) {" "static void %s(PyObject *o) {"
% scope.mangle_internal("tp_dealloc")) % scope.mangle_internal("tp_dealloc"))
py_attrs = [] py_attrs = []
weakref_slot = scope.lookup_here("__weakref__")
for entry in scope.var_entries: for entry in scope.var_entries:
if entry.type.is_pyobject and entry.name != "__weakref__": if entry.type.is_pyobject and entry is not weakref_slot:
py_attrs.append(entry) py_attrs.append(entry)
if py_attrs or scope.lookup_here("__weakref__"): if py_attrs or weakref_slot in scope.var_entries:
self.generate_self_cast(scope, code) self.generate_self_cast(scope, code)
self.generate_usr_dealloc_call(scope, code) self.generate_usr_dealloc_call(scope, code)
if scope.lookup_here("__weakref__"): if weakref_slot in scope.var_entries:
code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);") code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);")
for entry in py_attrs: for entry in py_attrs:
code.put_xdecref("p->%s" % entry.cname, entry.type) code.put_xdecref("p->%s" % entry.cname, entry.type)
......
import glob
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
from Cython.Distutils import build_ext from Cython.Distutils import build_ext
setup( ext_modules=[
name = 'Demos',
ext_modules=[
Extension("primes", ["primes.pyx"]), Extension("primes", ["primes.pyx"]),
Extension("spam", ["spam.pyx"]), Extension("spam", ["spam.pyx"]),
# Extension("numeric_demo", ["numeric_demo.pyx"]), ]
Extension("test", ["test.pyx"]),
Extension("func_pointers", ["func_pointers.pyx"]), for file in glob.glob("*.pyx"):
# Extension("inplace", ["inplace.pyx"]), if file != "numeric_demo.pyx":
# Extension("withGIL", ["withGIL.pyx"]), ext_modules.append(Extension(file[:-4], [file]))
Extension("class_members", ["class_members.pyx"]),
# Extension("inherit_bug", ["inherit_bug.pyx"]), setup(
Extension("override", ["override.pyx"]), name = 'Demos',
Extension("cond", ["cond.pyx"]),
# Extension("submodule.test", ["submodule/test.pyx"]),
Extension("errors", ["errors.pyx"]),
Extension("cpdef", ["cpdef.pyx"]),
Extension("range", ["range.pyx"]),
Extension("early_temps", ["early_temps.pyx"]),
Extension("ints", ["ints.pyx"]),
Extension("clear", ["clear.pyx"]),
Extension("detect_override", ["detect_override.pyx"]),
Extension("fixes", ["fixes.pyx"]),
],
cmdclass = {'build_ext': build_ext}, cmdclass = {'build_ext': build_ext},
# include_dirs = "/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3/" ext_modules = ext_modules,
) )
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