Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
0578cb68
Commit
0578cb68
authored
Sep 09, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PGO wrapper code and file path handling in Py2.
parent
7419d794
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
Cython/Build/IpythonMagic.py
Cython/Build/IpythonMagic.py
+13
-3
No files found.
Cython/Build/IpythonMagic.py
View file @
0578cb68
...
@@ -345,13 +345,20 @@ class CythonMagics(Magics):
...
@@ -345,13 +345,20 @@ class CythonMagics(Magics):
pgo_module_name
=
'_pgo_'
+
module_name
pgo_module_name
=
'_pgo_'
+
module_name
pgo_wrapper_c_file
=
os
.
path
.
join
(
lib_dir
,
pgo_module_name
+
'.c'
)
pgo_wrapper_c_file
=
os
.
path
.
join
(
lib_dir
,
pgo_module_name
+
'.c'
)
with
io
.
open
(
pgo_wrapper_c_file
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
with
io
.
open
(
pgo_wrapper_c_file
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
textwrap
.
dedent
(
"""
f
.
write
(
textwrap
.
dedent
(
u
"""
#include "Python.h"
#include "Python.h"
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
extern PyMODINIT_FUNC init%(module_name)s(void);
extern PyMODINIT_FUNC init%(module_name)s(void);
PyMODINIT_FUNC init%(pgo_module_name)s(void); /*proto*/
PyMODINIT_FUNC init%(pgo_module_name)s(void); /*proto*/
PyMODINIT_FUNC init%(pgo_module_name)s(void) {
PyMODINIT_FUNC init%(pgo_module_name)s(void) {
init%(module_name)s();
PyObject *sys_modules;
init%(module_name)s(); if (PyErr_Occurred()) return;
sys_modules = PyImport_GetModuleDict(); /* borrowed, no exception, "never" fails */
if (sys_modules) {
PyObject *module = PyDict_GetItemString(sys_modules, "%(module_name)s"); if (!module) return;
PyDict_SetItemString(sys_modules, "%(pgo_module_name)s", module);
Py_DECREF(module);
}
}
}
#else
#else
extern PyMODINIT_FUNC PyInit_%(module_name)s(void);
extern PyMODINIT_FUNC PyInit_%(module_name)s(void);
...
@@ -477,16 +484,19 @@ class CythonMagics(Magics):
...
@@ -477,16 +484,19 @@ class CythonMagics(Magics):
add_pgo_flags
=
self
.
_add_pgo_flags
add_pgo_flags
=
self
.
_add_pgo_flags
if
pgo_step_name
:
if
pgo_step_name
:
base_build_ext
=
_build_ext
class
_build_ext
(
_build_ext
):
class
_build_ext
(
_build_ext
):
def
build_extensions
(
self
):
def
build_extensions
(
self
):
add_pgo_flags
(
self
,
pgo_step_name
,
temp_dir
)
add_pgo_flags
(
self
,
pgo_step_name
,
temp_dir
)
super
(
_build_ext
,
self
).
build_extensions
(
)
base_build_ext
.
build_extensions
(
self
)
build_extension
=
_build_ext
(
dist
)
build_extension
=
_build_ext
(
dist
)
build_extension
.
finalize_options
()
build_extension
.
finalize_options
()
if
temp_dir
:
if
temp_dir
:
temp_dir
=
py3compat
.
cast_bytes_py2
(
temp_dir
,
encoding
=
sys
.
getfilesystemencoding
())
build_extension
.
build_temp
=
temp_dir
build_extension
.
build_temp
=
temp_dir
if
lib_dir
:
if
lib_dir
:
lib_dir
=
py3compat
.
cast_bytes_py2
(
lib_dir
,
encoding
=
sys
.
getfilesystemencoding
())
build_extension
.
build_lib
=
lib_dir
build_extension
.
build_lib
=
lib_dir
if
extension
is
not
None
:
if
extension
is
not
None
:
build_extension
.
extensions
=
[
extension
]
build_extension
.
extensions
=
[
extension
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment