Commit 96aa3561 authored by Jason Madden's avatar Jason Madden

fix the name of corecext in sys.modules.

parent c4b95fc4
...@@ -15,7 +15,7 @@ export LC_ALL=C.UTF-8 ...@@ -15,7 +15,7 @@ export LC_ALL=C.UTF-8
all: src/gevent/libev/gevent.corecext.c src/gevent/gevent.ares.c src/gevent/gevent._semaphore.c all: src/gevent/libev/gevent.corecext.c src/gevent/gevent.ares.c src/gevent/gevent._semaphore.c
src/gevent/libev/gevent.corecext.c: src/gevent/libev/corecext.ppyx src/gevent/libev/libev.pxd util/cythonpp.py src/gevent/libev/gevent.corecext.c: src/gevent/libev/corecext.ppyx src/gevent/libev/libev.pxd util/cythonpp.py
$(PYTHON) util/cythonpp.py -o gevent.corecext.c src/gevent/libev/corecext.ppyx $(PYTHON) util/cythonpp.py -o gevent.corecext.c --module-name gevent.libev.corecext.pyx src/gevent/libev/corecext.ppyx
echo '#include "callbacks.c"' >> gevent.corecext.c echo '#include "callbacks.c"' >> gevent.corecext.c
mv gevent.corecext.* src/gevent/libev/ mv gevent.corecext.* src/gevent/libev/
......
IF "%PYTHON_EXE%" == "python" ( IF "%PYTHON_EXE%" == "python" (
%PYEXE% util\cythonpp.py -o gevent.corecext.c src\gevent\libev\corecext.ppyx %PYEXE% util\cythonpp.py -o gevent.corecext.c --module-name gevent.libev.corecext.pyx src\gevent\libev\corecext.ppyx
type src\gevent\libev\callbacks.c >> gevent.corecext.c type src\gevent\libev\callbacks.c >> gevent.corecext.c
move gevent.corecext.* src\gevent\libev move gevent.corecext.* src\gevent\libev
) )
......
/* Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. */ /* Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. */
#ifdef Py_PYTHON_H #ifdef Py_PYTHON_H
#if 1 /* the name changes depending on our file layout and --module-name option */
/* name generated by cython when we use threads */ #define _GEVENTLOOP struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop
#define _GEVENTLOOP struct __pyx_vtabstruct_8corecext_loop
#else
#define _GEVENTLOOP struct __pyx_vtabstruct_6gevent_8corecext_loop
#endif
static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context) { static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context) {
PyThreadState *tstate; PyThreadState *tstate;
......
...@@ -407,7 +407,8 @@ def _run_cython_on_file(configuration, pyx_filename, ...@@ -407,7 +407,8 @@ def _run_cython_on_file(configuration, pyx_filename,
py_banner, banner, py_banner, banner,
output_filename, output_filename,
counter, lines, counter, lines,
cache=None): cache=None,
module_name=None):
value = ''.join(lines) value = ''.join(lines)
sourcehash = md5(value.encode("utf-8")).hexdigest() sourcehash = md5(value.encode("utf-8")).hexdigest()
comment = configuration.format_tag() + " hash:" + str(sourcehash) comment = configuration.format_tag() + " hash:" + str(sourcehash)
...@@ -420,7 +421,7 @@ def _run_cython_on_file(configuration, pyx_filename, ...@@ -420,7 +421,7 @@ def _run_cython_on_file(configuration, pyx_filename,
tempdir = tempfile.mkdtemp() tempdir = tempfile.mkdtemp()
#unique_pyx_filename = pyx_filename #unique_pyx_filename = pyx_filename
#unique_output_filename = output_filename #unique_output_filename = output_filename
unique_pyx_filename = os.path.join(tempdir, pyx_filename) unique_pyx_filename = os.path.join(tempdir, module_name or pyx_filename)
unique_output_filename = os.path.join(tempdir, output_filename) unique_output_filename = os.path.join(tempdir, output_filename)
dirname = os.path.dirname(unique_pyx_filename) # output must be in same dir dirname = os.path.dirname(unique_pyx_filename) # output must be in same dir
...@@ -442,7 +443,8 @@ def _run_cython_on_file(configuration, pyx_filename, ...@@ -442,7 +443,8 @@ def _run_cython_on_file(configuration, pyx_filename,
return configuration.attach_tags(output), configuration, sourcehash return configuration.attach_tags(output), configuration, sourcehash
def _run_cython_on_files(pyx_filename, py_banner, banner, output_filename, preprocessed): def _run_cython_on_files(pyx_filename, py_banner, banner, output_filename, preprocessed,
module_name=None):
counter = 0 counter = 0
threads = [] threads = []
cache = {} cache = {}
...@@ -452,7 +454,7 @@ def _run_cython_on_files(pyx_filename, py_banner, banner, output_filename, prepr ...@@ -452,7 +454,7 @@ def _run_cython_on_files(pyx_filename, py_banner, banner, output_filename, prepr
args=(configuration, pyx_filename, args=(configuration, pyx_filename,
py_banner, banner, output_filename, py_banner, banner, output_filename,
counter, lines, counter, lines,
cache))) cache, module_name)))
threads[-1].start() threads[-1].start()
for t in threads: for t in threads:
...@@ -482,7 +484,7 @@ def _run_cython_on_files(pyx_filename, py_banner, banner, output_filename, prepr ...@@ -482,7 +484,7 @@ def _run_cython_on_files(pyx_filename, py_banner, banner, output_filename, prepr
return ordered_results return ordered_results
def process_filename(filename, output_filename=None): def process_filename(filename, output_filename=None, module_name=None):
"""Process the .ppyx file with preprocessor and compile it with cython. """Process the .ppyx file with preprocessor and compile it with cython.
The algorithm is as following: The algorithm is as following:
...@@ -515,7 +517,7 @@ def process_filename(filename, output_filename=None): ...@@ -515,7 +517,7 @@ def process_filename(filename, output_filename=None):
reference_pyx = preprocessed.pop(None) reference_pyx = preprocessed.pop(None)
sources = _run_cython_on_files(pyx_filename, py_banner, banner, output_filename, sources = _run_cython_on_files(pyx_filename, py_banner, banner, output_filename,
preprocessed) preprocessed, module_name)
log('Generating %s ', output_filename) log('Generating %s ', output_filename)
result = generate_merged(sources) result = generate_merged(sources)
...@@ -1026,6 +1028,9 @@ def main(): ...@@ -1026,6 +1028,9 @@ def main():
parser.add_argument('--ignore-cond', action='store_true', help='Ignore conditional directives (only expand definitions)') parser.add_argument('--ignore-cond', action='store_true', help='Ignore conditional directives (only expand definitions)')
parser.add_argument('--write-intermediate', action='store_true', help='Save intermediate files produced by preprocessor and Cython') parser.add_argument('--write-intermediate', action='store_true', help='Save intermediate files produced by preprocessor and Cython')
parser.add_argument('-o', '--output-file', help='Specify name of generated C file') parser.add_argument('-o', '--output-file', help='Specify name of generated C file')
# TODO: Derive the module name automatically from the input filename relative to the base
# dir.
parser.add_argument('--module-name', help="specify name of .pyx module")
parser.add_argument("input") parser.add_argument("input")
options = parser.parse_args() options = parser.parse_args()
filename = options.input filename = options.input
...@@ -1060,7 +1065,7 @@ def main(): ...@@ -1060,7 +1065,7 @@ def main():
sys.stdout.write(preprocess_filename(filename, FakeConfig())) sys.stdout.write(preprocess_filename(filename, FakeConfig()))
if run: if run:
process_filename(filename, options.output_file) process_filename(filename, options.output_file, options.module_name)
if __name__ == '__main__': if __name__ == '__main__':
......
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