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
Gwenaël Samain
cython
Commits
df41d977
Commit
df41d977
authored
Jan 22, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'markpeek/compile_time_env'
parents
1773ac3b
4b83dc91
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
1 deletion
+40
-1
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+1
-0
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+6
-0
Cython/Distutils/build_ext.py
Cython/Distutils/build_ext.py
+8
-1
Cython/Distutils/extension.py
Cython/Distutils/extension.py
+2
-0
tests/build/compile_env_distutils.srctree
tests/build/compile_env_distutils.srctree
+23
-0
No files found.
Cython/Compiler/Main.py
View file @
df41d977
...
...
@@ -686,4 +686,5 @@ default_options = dict(
c_line_in_traceback
=
True
,
language_level
=
2
,
gdb_debug
=
False
,
compile_time_env
=
None
,
)
Cython/Compiler/Scanning.py
View file @
df41d977
...
...
@@ -67,6 +67,9 @@ class CompileTimeScope(object):
def
declare
(
self
,
name
,
value
):
self
.
entries
[
name
]
=
value
def
update
(
self
,
other
):
self
.
entries
.
update
(
other
)
def
lookup_here
(
self
,
name
):
return
self
.
entries
[
name
]
...
...
@@ -286,6 +289,9 @@ class PyrexScanner(Scanner):
self
.
compile_time_env
=
initial_compile_time_env
()
self
.
compile_time_eval
=
1
self
.
compile_time_expr
=
0
if
hasattr
(
context
.
options
,
'compile_time_env'
)
and
\
context
.
options
.
compile_time_env
is
not
None
:
self
.
compile_time_env
.
update
(
context
.
options
.
compile_time_env
)
self
.
parse_comments
=
parse_comments
self
.
source_encoding
=
source_encoding
if
filename
.
is_python_file
():
...
...
Cython/Distutils/build_ext.py
View file @
df41d977
...
...
@@ -83,6 +83,8 @@ class build_ext(_build_ext.build_ext):
"compiler directive overrides"
),
(
'pyrex-gdb'
,
None
,
"generate debug information for cygdb"
),
(
'pyrex-compile-time-env'
,
None
,
"pyrex compile time environment"
),
])
boolean_options
.
extend
([
...
...
@@ -101,6 +103,7 @@ class build_ext(_build_ext.build_ext):
self
.
pyrex_gen_pxi
=
0
self
.
pyrex_gdb
=
False
self
.
no_c_in_traceback
=
0
self
.
pyrex_compile_time_env
=
None
def
finalize_options
(
self
):
_build_ext
.
build_ext
.
finalize_options
(
self
)
...
...
@@ -182,6 +185,9 @@ class build_ext(_build_ext.build_ext):
(
extension
.
language
and
extension
.
language
.
lower
()
==
'c++'
)
pyrex_gen_pxi
=
self
.
pyrex_gen_pxi
or
getattr
(
extension
,
'pyrex_gen_pxi'
,
0
)
pyrex_gdb
=
self
.
pyrex_gdb
or
getattr
(
extension
,
'pyrex_gdb'
,
False
)
pyrex_compile_time_env
=
self
.
pyrex_compile_time_env
or
\
getattr
(
extension
,
'pyrex_compile_time_env'
,
None
)
# Set up the include_path for the Cython compiler:
# 1. Start with the command line option.
# 2. Add in any (unique) paths from the extension
...
...
@@ -270,7 +276,8 @@ class build_ext(_build_ext.build_ext):
c_line_in_traceback
=
not
no_c_in_traceback
,
generate_pxi
=
pyrex_gen_pxi
,
output_dir
=
output_dir
,
gdb_debug
=
pyrex_gdb
)
gdb_debug
=
pyrex_gdb
,
compile_time_env
=
pyrex_compile_time_env
)
result
=
cython_compile
(
source
,
options
=
options
,
full_module_name
=
module_name
)
else
:
...
...
Cython/Distutils/extension.py
View file @
df41d977
...
...
@@ -63,6 +63,7 @@ class Extension(_Extension.Extension):
pyrex_gen_pxi
=
0
,
pyrex_gdb
=
False
,
no_c_in_traceback
=
False
,
pyrex_compile_time_env
=
None
,
**
kw
):
_Extension
.
Extension
.
__init__
(
self
,
name
,
sources
,
...
...
@@ -90,6 +91,7 @@ class Extension(_Extension.Extension):
self
.
pyrex_gen_pxi
=
pyrex_gen_pxi
self
.
pyrex_gdb
=
pyrex_gdb
self
.
no_c_in_traceback
=
no_c_in_traceback
self
.
pyrex_compile_time_env
=
pyrex_compile_time_env
# class Extension
...
...
tests/build/compile_env_distutils.srctree
0 → 100644
View file @
df41d977
PYTHON setup.py build_ext --inplace
PYTHON -c "import a; import sys; sys.exit(a.compile_env_test())"
######## setup.py ########
from distutils.core import setup
from Cython.Distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension(
"a", ["a.pyx"],
pyrex_compile_time_env = {'TEST': True},
)],
)
######## a.pyx ########
def compile_env_test():
IF TEST:
return 0
ELSE:
return 1
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