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
c23282d8
Commit
c23282d8
authored
Feb 22, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make pyxbuild.py Py3 compatible with .c compile fallback if Cython import fails
parent
af51810b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
pyximport/pyxbuild.py
pyximport/pyxbuild.py
+20
-11
No files found.
pyximport/pyxbuild.py
View file @
c23282d8
...
@@ -4,13 +4,18 @@ the installed distutils infrastructure. Call:
...
@@ -4,13 +4,18 @@ the installed distutils infrastructure. Call:
out_fname = pyx_to_dll("foo.pyx")
out_fname = pyx_to_dll("foo.pyx")
"""
"""
import
os
import
os
import
sys
import
distutils
import
distutils
from
distutils.dist
import
Distribution
from
distutils.dist
import
Distribution
from
distutils.errors
import
DistutilsArgError
,
DistutilsError
,
CCompilerError
from
distutils.errors
import
DistutilsArgError
,
DistutilsError
,
CCompilerError
from
distutils.extension
import
Extension
from
distutils.extension
import
Extension
from
distutils.util
import
grok_environment_error
from
distutils.util
import
grok_environment_error
from
Cython.Distutils
import
build_ext
try
:
from
Cython.Distutils
import
build_ext
HAS_CYTHON
=
True
except
ImportError
:
HAS_CYTHON
=
False
import
shutil
import
shutil
DEBUG
=
0
DEBUG
=
0
...
@@ -25,6 +30,8 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
...
@@ -25,6 +30,8 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
if
not
ext
:
if
not
ext
:
modname
,
extension
=
os
.
path
.
splitext
(
name
)
modname
,
extension
=
os
.
path
.
splitext
(
name
)
assert
extension
in
(
".pyx"
,
".py"
),
extension
assert
extension
in
(
".pyx"
,
".py"
),
extension
if
not
HAS_CYTHON
:
filename
=
filename
[:
-
len
(
extension
)]
+
'.c'
ext
=
Extension
(
name
=
modname
,
sources
=
[
filename
])
ext
=
Extension
(
name
=
modname
,
sources
=
[
filename
])
if
not
pyxbuild_dir
:
if
not
pyxbuild_dir
:
...
@@ -37,23 +44,24 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
...
@@ -37,23 +44,24 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
args
=
[
quiet
,
"build_ext"
]
args
=
[
quiet
,
"build_ext"
]
if
force_rebuild
:
if
force_rebuild
:
args
.
append
(
"--force"
)
args
.
append
(
"--force"
)
if
build_in_temp
:
if
HAS_CYTHON
and
build_in_temp
:
args
.
append
(
"--pyrex-c-in-temp"
)
args
.
append
(
"--pyrex-c-in-temp"
)
dist
=
Distribution
({
"script_name"
:
None
,
"script_args"
:
args
})
dist
=
Distribution
({
"script_name"
:
None
,
"script_args"
:
args
})
if
not
dist
.
ext_modules
:
if
not
dist
.
ext_modules
:
dist
.
ext_modules
=
[]
dist
.
ext_modules
=
[]
dist
.
ext_modules
.
append
(
ext
)
dist
.
ext_modules
.
append
(
ext
)
if
HAS_CYTHON
:
dist
.
cmdclass
=
{
'build_ext'
:
build_ext
}
dist
.
cmdclass
=
{
'build_ext'
:
build_ext
}
build
=
dist
.
get_command_obj
(
'build'
)
build
=
dist
.
get_command_obj
(
'build'
)
build
.
build_base
=
pyxbuild_dir
build
.
build_base
=
pyxbuild_dir
try
:
try
:
ok
=
dist
.
parse_command_line
()
ok
=
dist
.
parse_command_line
()
except
DistutilsArgError
,
msg
:
except
DistutilsArgError
:
raise
raise
if
DEBUG
:
if
DEBUG
:
print
"options (after parsing command line):"
print
(
"options (after parsing command line):"
)
dist
.
dump_option_dicts
()
dist
.
dump_option_dicts
()
assert
ok
assert
ok
...
@@ -62,22 +70,23 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
...
@@ -62,22 +70,23 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
dist
.
run_commands
()
dist
.
run_commands
()
return
dist
.
get_command_obj
(
"build_ext"
).
get_outputs
()[
0
]
return
dist
.
get_command_obj
(
"build_ext"
).
get_outputs
()[
0
]
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
raise
SystemExit
,
"interrupted"
sys
.
exit
(
1
)
except
(
IOError
,
os
.
error
),
exc
:
except
(
IOError
,
os
.
error
):
exc
=
sys
.
exc_info
()[
1
]
error
=
grok_environment_error
(
exc
)
error
=
grok_environment_error
(
exc
)
if
DEBUG
:
if
DEBUG
:
sys
.
stderr
.
write
(
error
+
"
\
n
"
)
sys
.
stderr
.
write
(
error
+
"
\
n
"
)
raise
raise
else
:
else
:
raise
RuntimeError
,
error
raise
RuntimeError
(
error
)
except
(
DistutilsError
,
except
(
DistutilsError
,
CCompilerError
):
CCompilerError
),
msg
:
if
DEBUG
:
if
DEBUG
:
raise
raise
else
:
else
:
raise
RuntimeError
(
repr
(
msg
))
exc
=
sys
.
exc_info
()[
1
]
raise
RuntimeError
(
repr
(
exc
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
pyx_to_dll
(
"dummy.pyx"
)
pyx_to_dll
(
"dummy.pyx"
)
...
...
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