Commit 2dc08fb1 authored by Lisandro Dalcin's avatar Lisandro Dalcin

build and install "Cython.Runtime.refnanny", use it as a fallback if a bare...

build and install "Cython.Runtime.refnanny", use it as a fallback if a bare "refnanny" module is not available for import
parent 461323b6
...@@ -1587,8 +1587,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1587,8 +1587,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("#ifdef CYTHON_REFNANNY") code.putln("#ifdef CYTHON_REFNANNY")
code.putln("void* __pyx_refchk = NULL;") code.putln("void* __pyx_refchk = NULL;")
code.putln("__Pyx_Refnanny = (__Pyx_RefnannyAPIStruct*) PyCObject_Import((char *)\"refnanny\", (char *)\"RefnannyAPI\");") code.putln("__Pyx_Refnanny = __Pyx_ImportRefcountAPI(\"refnanny\");")
code.putln("if (!__Pyx_Refnanny) Py_FatalError(\"failed to import refnanny module\");") code.putln("if (!__Pyx_Refnanny) {")
code.putln(" PyErr_Clear();")
code.putln(" __Pyx_Refnanny = __Pyx_ImportRefcountAPI(\"Cython.Runtime.refnanny\");")
code.putln(" if (!__Pyx_Refnanny)")
code.putln(" Py_FatalError(\"failed to import refnanny module\");")
code.putln("}")
code.putln("__pyx_refchk = __Pyx_Refnanny->NewContext(\"%s\", __LINE__);"% header3) code.putln("__pyx_refchk = __Pyx_Refnanny->NewContext(\"%s\", __LINE__);"% header3)
code.putln("#endif") code.putln("#endif")
...@@ -2337,6 +2342,8 @@ typedef struct { ...@@ -2337,6 +2342,8 @@ typedef struct {
int (*FinishContext)(void*); int (*FinishContext)(void*);
} __Pyx_RefnannyAPIStruct; } __Pyx_RefnannyAPIStruct;
static __Pyx_RefnannyAPIStruct* __Pyx_Refnanny = NULL; static __Pyx_RefnannyAPIStruct* __Pyx_Refnanny = NULL;
#define __Pyx_ImportRefcountAPI(name) \
(__Pyx_RefnannyAPIStruct*) PyCObject_Import((char *)name, (char *)\"RefnannyAPI\")
#define __Pyx_INCREF(r) __Pyx_Refnanny->INCREF(__pyx_refchk, (r), __LINE__) #define __Pyx_INCREF(r) __Pyx_Refnanny->INCREF(__pyx_refchk, (r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_Refnanny->DECREF(__pyx_refchk, (r), __LINE__) #define __Pyx_DECREF(r) __Pyx_Refnanny->DECREF(__pyx_refchk, (r), __LINE__)
#define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r) #define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r)
......
...@@ -14,6 +14,7 @@ clean: ...@@ -14,6 +14,7 @@ clean:
@rm -f Cython/Compiler/Parsing.{c,so,pyd} @rm -f Cython/Compiler/Parsing.{c,so,pyd}
@rm -f Cython/Compiler/Scanning.{c,so,pyd} @rm -f Cython/Compiler/Scanning.{c,so,pyd}
@rm -f Cython/Compiler/Visitor.{c,so,pyd} @rm -f Cython/Compiler/Visitor.{c,so,pyd}
@rm -f Cython/Runtime/refnanny.{c,so,pyd}
@rm -f Cython/Plex/Scanners.{c,so,pyd} @rm -f Cython/Plex/Scanners.{c,so,pyd}
@(cd Demos; $(MAKE) clean) @(cd Demos; $(MAKE) clean)
......
...@@ -41,12 +41,17 @@ except ValueError: ...@@ -41,12 +41,17 @@ except ValueError:
compiled_modules = ["Cython.Plex.Scanners", compiled_modules = ["Cython.Plex.Scanners",
"Cython.Compiler.Scanning", "Cython.Compiler.Scanning",
"Cython.Compiler.Parsing", "Cython.Compiler.Parsing",
"Cython.Compiler.Visitor"] "Cython.Compiler.Visitor",
"Cython.Runtime.refnanny"]
extensions = [] extensions = []
for module in compiled_modules: for module in compiled_modules:
source_file = os.path.join(source_root, *module.split('.')) source_file = os.path.join(source_root, *module.split('.'))
if os.path.exists(source_file + ".py"):
source_file = source_file + ".py"
else:
source_file = source_file + ".pyx"
print("Compiling module %s ..." % module) print("Compiling module %s ..." % module)
result = compile(source_file + ".py") result = compile(source_file)
if result.c_file: if result.c_file:
extensions.append( extensions.append(
Extension(module, sources = [result.c_file]) Extension(module, sources = [result.c_file])
...@@ -62,7 +67,7 @@ except ValueError: ...@@ -62,7 +67,7 @@ except ValueError:
setup( setup(
name = 'Cython', name = 'Cython',
version = version, version = version,
url = 'http://www.cython.org', url = 'http://www.cython.org',
author = 'Greg Ewing, Robert Bradshaw, Stefan Behnel, Dag Seljebotn, et al.', author = 'Greg Ewing, Robert Bradshaw, Stefan Behnel, Dag Seljebotn, et al.',
...@@ -101,6 +106,7 @@ setup( ...@@ -101,6 +106,7 @@ setup(
packages=[ packages=[
'Cython', 'Cython',
'Cython.Compiler', 'Cython.Compiler',
'Cython.Runtime',
'Cython.Distutils', 'Cython.Distutils',
'Cython.Mac', 'Cython.Mac',
'Cython.Unix', 'Cython.Unix',
...@@ -109,13 +115,13 @@ setup( ...@@ -109,13 +115,13 @@ setup(
'Cython.Tests', 'Cython.Tests',
'Cython.Compiler.Tests', 'Cython.Compiler.Tests',
], ],
# pyximport # pyximport
py_modules = ["pyximport/__init__", py_modules = ["pyximport/__init__",
"pyximport/pyximport", "pyximport/pyximport",
"pyximport/pyxbuild", "pyximport/pyxbuild",
"cython"], "cython"],
**setup_args **setup_args
) )
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