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
acf3abf8
Commit
acf3abf8
authored
Jan 02, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.29.x'
parents
a3d3ab54
fe3315ba
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
20 deletions
+22
-20
Cython/Build/IpythonMagic.py
Cython/Build/IpythonMagic.py
+14
-5
Cython/Build/Tests/TestIpythonMagic.py
Cython/Build/Tests/TestIpythonMagic.py
+8
-15
No files found.
Cython/Build/IpythonMagic.py
View file @
acf3abf8
...
...
@@ -56,6 +56,8 @@ import copy
import
distutils.log
import
textwrap
IO_ENCODING
=
sys
.
getfilesystemencoding
()
IS_PY2
=
sys
.
version_info
[
0
]
<
3
try
:
from
importlib
import
reload
...
...
@@ -69,7 +71,6 @@ from distutils.command.build_ext import build_ext
from
IPython.core
import
display
from
IPython.core
import
magic_arguments
from
IPython.core.magic
import
Magics
,
magics_class
,
cell_magic
from
IPython.utils
import
py3compat
try
:
from
IPython.paths
import
get_ipython_cache_dir
except
ImportError
:
...
...
@@ -97,6 +98,14 @@ PGO_CONFIG = {
PGO_CONFIG
[
'mingw32'
]
=
PGO_CONFIG
[
'gcc'
]
if
IS_PY2
:
def
encode_fs
(
name
):
return
name
if
isinstance
(
name
,
bytes
)
else
name
.
encode
(
IO_ENCODING
)
else
:
def
encode_fs
(
name
):
return
name
@
magics_class
class
CythonMagics
(
Magics
):
...
...
@@ -307,7 +316,7 @@ class CythonMagics(Magics):
key
+=
(
time
.
time
(),)
if
args
.
name
:
module_name
=
py3compat
.
unicode_to_str
(
args
.
name
)
module_name
=
str
(
args
.
name
)
# no-op in Py3
else
:
module_name
=
"_cython_magic_"
+
hashlib
.
sha1
(
str
(
key
).
encode
(
'utf-8'
)).
hexdigest
()
html_file
=
os
.
path
.
join
(
lib_dir
,
module_name
+
'.html'
)
...
...
@@ -407,7 +416,7 @@ class CythonMagics(Magics):
def
_cythonize
(
self
,
module_name
,
code
,
lib_dir
,
args
,
quiet
=
True
):
pyx_file
=
os
.
path
.
join
(
lib_dir
,
module_name
+
'.pyx'
)
pyx_file
=
py3compat
.
cast_bytes_py2
(
pyx_file
,
encoding
=
sys
.
getfilesystemencoding
()
)
pyx_file
=
encode_fs
(
pyx_file
)
c_include_dirs
=
args
.
include
c_src_files
=
list
(
map
(
str
,
args
.
src
))
...
...
@@ -526,10 +535,10 @@ class CythonMagics(Magics):
build_extension
=
_build_ext
(
dist
)
build_extension
.
finalize_options
()
if
temp_dir
:
temp_dir
=
py3compat
.
cast_bytes_py2
(
temp_dir
,
encoding
=
sys
.
getfilesystemencoding
()
)
temp_dir
=
encode_fs
(
temp_dir
)
build_extension
.
build_temp
=
temp_dir
if
lib_dir
:
lib_dir
=
py3compat
.
cast_bytes_py2
(
lib_dir
,
encoding
=
sys
.
getfilesystemencoding
()
)
lib_dir
=
encode_fs
(
lib_dir
)
build_extension
.
build_lib
=
lib_dir
if
extension
is
not
None
:
build_extension
.
extensions
=
[
extension
]
...
...
Cython/Build/Tests/TestIpythonMagic.py
View file @
acf3abf8
...
...
@@ -14,15 +14,8 @@ from Cython.Compiler.Annotate import AnnotationCCodeWriter
try
:
import
IPython.testing.globalipapp
from
IPython.utils
import
py3compat
except
ImportError
:
# Disable tests and fake helpers for initialisation below.
class
_py3compat
(
object
):
def
str_to_unicode
(
self
,
s
):
return
s
py3compat
=
_py3compat
()
def
skip_if_not_installed
(
_
):
return
None
else
:
...
...
@@ -36,24 +29,24 @@ try:
except
ImportError
:
pass
code
=
py3compat
.
str_to_unicode
(
"""
\
code
=
u
"""
\
def f(x):
return 2*x
"""
)
"""
cython3_code
=
py3compat
.
str_to_unicode
(
"""
\
cython3_code
=
u
"""
\
def f(int x):
return 2 / x
def call(x):
return f(*(x,))
"""
)
"""
pgo_cython3_code
=
cython3_code
+
py3compat
.
str_to_unicode
(
"""
\
pgo_cython3_code
=
cython3_code
+
u
"""
\
def main():
for _ in range(100): call(5)
main()
"""
)
"""
if
sys
.
platform
==
'win32'
:
...
...
@@ -162,10 +155,10 @@ class TestIPythonMagic(CythonTest):
@
skip_win32
(
'Skip on Windows'
)
def
test_extlibs
(
self
):
ip
=
self
.
_ip
code
=
py3compat
.
str_to_unicode
(
"""
code
=
u
"""
from libc.math cimport sin
x = sin(0.0)
"""
)
"""
ip
.
user_ns
[
'x'
]
=
1
ip
.
run_cell_magic
(
'cython'
,
'-l m'
,
code
)
self
.
assertEqual
(
ip
.
user_ns
[
'x'
],
0
)
...
...
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