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
deef9b9f
Commit
deef9b9f
authored
Feb 10, 2017
by
Sergei Lebedev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressed review comments
parent
17bef673
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
20 deletions
+33
-20
pyximport/pyximport.py
pyximport/pyximport.py
+24
-20
pyximport/test/test_pyximport.py
pyximport/test/test_pyximport.py
+9
-0
No files found.
pyximport/pyximport.py
View file @
deef9b9f
...
@@ -308,27 +308,31 @@ class PyxImporter(object):
...
@@ -308,27 +308,31 @@ class PyxImporter(object):
elif
not
os
.
path
.
isabs
(
path
):
elif
not
os
.
path
.
isabs
(
path
):
path
=
os
.
path
.
abspath
(
path
)
path
=
os
.
path
.
abspath
(
path
)
try
:
if
os
.
path
.
isfile
(
path
):
zi
=
zipimporter
(
path
)
try
:
data
=
zi
.
get_data
(
pyx_module_name
)
zi
=
zipimporter
(
path
)
except
(
ZipImportError
,
IOError
):
data
=
zi
.
get_data
(
pyx_module_name
)
pyx_module_path
=
os
.
path
.
join
(
path
,
pyx_module_name
)
except
(
ZipImportError
,
IOError
):
continue
# Module not found.
else
:
# XXX unzip the imported file into the build dir. A bit
# hacky, but it works!
if
not
os
.
path
.
exists
(
self
.
pyxbuild_dir
):
os
.
makedirs
(
self
.
pyxbuild_dir
)
pyx_module_path
=
os
.
path
.
join
(
self
.
pyxbuild_dir
,
pyx_module_name
)
with
open
(
pyx_module_path
,
"wb"
)
as
f
:
f
.
write
(
data
)
else
:
else
:
# XXX unzip the imported file into the build dir. A bit
pyx_module_path
=
os
.
path
.
join
(
path
,
pyx_module_name
)
# hacky, but it works!
if
not
os
.
path
.
isfile
(
pyx_module_path
):
if
not
os
.
path
.
exists
(
self
.
pyxbuild_dir
):
continue
# Module not found.
os
.
makedirs
(
self
.
pyxbuild_dir
)
return
PyxLoader
(
fullname
,
pyx_module_path
,
pyx_module_path
=
os
.
path
.
join
(
self
.
pyxbuild_dir
,
pyxbuild_dir
=
self
.
pyxbuild_dir
,
pyx_module_name
)
inplace
=
self
.
inplace
,
with
open
(
pyx_module_path
,
"wb"
)
as
handle
:
language_level
=
self
.
language_level
)
handle
.
write
(
data
)
if
os
.
path
.
isfile
(
pyx_module_path
):
return
PyxLoader
(
fullname
,
pyx_module_path
,
pyxbuild_dir
=
self
.
pyxbuild_dir
,
inplace
=
self
.
inplace
,
language_level
=
self
.
language_level
)
# not found, normal package, not a .pyx file, none of our business
# not found, normal package, not a .pyx file, none of our business
_debug
(
"%s not found"
%
fullname
)
_debug
(
"%s not found"
%
fullname
)
...
...
pyximport/test/test_pyximport.py
View file @
deef9b9f
...
@@ -96,6 +96,15 @@ def test_zip():
...
@@ -96,6 +96,15 @@ def test_zip():
assert
test_zip_module
.
x
==
42
assert
test_zip_module
.
x
==
42
finally
:
finally
:
os
.
remove
(
zip_path
)
os
.
remove
(
zip_path
)
sys
.
path
.
remove
(
zip_path
)
def
test_zip_nonexisting
():
sys
.
path
.
append
(
"nonexisting_zip_module.zip"
)
try
:
import
nonexisting_zip_module
except
ImportError
:
pass
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
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