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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
7b59e3b7
Commit
7b59e3b7
authored
Apr 10, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up some code in cython.inline() implementation.
parent
4e785d42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
Cython/Build/Inline.py
Cython/Build/Inline.py
+18
-11
No files found.
Cython/Build/Inline.py
View file @
7b59e3b7
from
__future__
import
absolute_import
import
sys
,
os
,
re
,
inspect
import
imp
import
hashlib
import
inspect
import
os
import
re
import
sys
from
distutils.core
import
Distribution
,
Extension
from
distutils.command.build_ext
import
build_ext
import
Cython
from
..Compiler.Main
import
Context
from
..Compiler.Options
import
CompilationOptions
,
default_options
from
..Compiler.Options
import
default_options
from
..Compiler.ParseTreeTransforms
import
(
CythonTransform
,
SkipDeclarations
,
AnalyseDeclarationsTransform
,
EnvTransform
)
from
..Compiler.ParseTreeTransforms
import
CythonTransform
,
SkipDeclarations
,
EnvTransform
from
..Compiler.TreeFragment
import
parse_from_strings
from
..Compiler.StringEncoding
import
_unicode
from
.Dependencies
import
strip_string_literals
,
cythonize
,
cached_function
from
..Compiler
import
Pipeline
,
Nodes
from
..Compiler
import
Pipeline
from
..Utils
import
get_cython_cache_dir
import
cython
as
cython_module
IS_PY3
=
sys
.
version_info
>=
(
3
,
0
)
IS_PY3
=
sys
.
version_info
>=
(
3
,)
# A utility function to convert user-supplied ASCII strings to unicode.
if
sys
.
version_info
[
0
]
<
3
:
if
not
IS_PY
3
:
def
to_unicode
(
s
):
if
isinstance
(
s
,
bytes
):
return
s
.
decode
(
'ascii'
)
...
...
@@ -32,7 +34,8 @@ if sys.version_info[0] < 3:
else
:
to_unicode
=
lambda
x
:
x
if
sys
.
version_info
[:
2
]
<
(
3
,
3
):
if
sys
.
version_info
<
(
3
,
3
):
import
imp
def
load_dynamic
(
name
,
module_path
):
return
imp
.
load_dynamic
(
name
,
module_path
)
...
...
@@ -130,6 +133,7 @@ def _create_context(cython_include_dirs):
_cython_inline_cache
=
{}
_cython_inline_default_context
=
_create_context
((
'.'
,))
def
_populate_unbound
(
kwds
,
unbound_symbols
,
locals
=
None
,
globals
=
None
):
for
symbol
in
unbound_symbols
:
if
symbol
not
in
kwds
:
...
...
@@ -146,10 +150,12 @@ def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None):
else
:
print
(
"Couldn't find %r"
%
symbol
)
def
_inline_key
(
orig_code
,
arg_sigs
,
language_level
):
key
=
orig_code
,
arg_sigs
,
sys
.
version_info
,
sys
.
executable
,
language_level
,
Cython
.
__version__
return
hashlib
.
sha1
(
_unicode
(
key
).
encode
(
'utf-8'
)).
hexdigest
()
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
lib_dir
=
os
.
path
.
join
(
get_cython_cache_dir
(),
'inline'
),
cython_include_dirs
=
None
,
cython_compiler_directives
=
None
,
...
...
@@ -159,7 +165,7 @@ def cython_inline(code, get_type=unsafe_type,
get_type
=
lambda
x
:
'object'
ctx
=
_create_context
(
tuple
(
cython_include_dirs
))
if
cython_include_dirs
else
_cython_inline_default_context
cython_compiler_directives
=
dict
(
cython_compiler_directives
or
{})
cython_compiler_directives
=
dict
(
cython_compiler_directives
)
if
cython_compiler_directives
else
{}
if
language_level
is
None
and
'language_level'
not
in
cython_compiler_directives
:
language_level
=
'3str'
if
language_level
is
not
None
:
...
...
@@ -284,6 +290,7 @@ def __invoke(%(params)s):
arg_list = [kwds[arg] for arg in arg_names]
return module.__invoke(*arg_list)
# Cached suffix used by cython_inline above. None should get
# overridden with actual value upon the first cython_inline invocation
cython_inline.so_ext = None
...
...
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