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
d7ee877a
Commit
d7ee877a
authored
Feb 11, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up zip support code in pyximport trying to remove some redundancy
parent
4f175b3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
30 deletions
+28
-30
pyximport/pyximport.py
pyximport/pyximport.py
+28
-30
No files found.
pyximport/pyximport.py
View file @
d7ee877a
...
...
@@ -287,47 +287,45 @@ class PyxImporter(object):
# searching sys.path ...
#if DEBUG_IMPORT: print "SEARCHING", fullname, package_path
if
'.'
in
fullname
:
# only when package_path anyway?
mod_parts
=
fullname
.
split
(
'.'
)
module_name
=
mod_parts
[
-
1
]
else
:
module_name
=
fullname
mod_parts
=
fullname
.
split
(
'.'
)
module_name
=
mod_parts
[
-
1
]
pyx_module_name
=
module_name
+
self
.
extension
# this may work, but it returns the file content, not its path
#import pkgutil
#pyx_source = pkgutil.get_data(package, pyx_module_name)
if
package_path
:
paths
=
package_path
else
:
paths
=
sys
.
path
paths
=
package_path
or
sys
.
path
for
path
in
paths
:
pyx_data
=
None
if
not
path
:
path
=
os
.
getcwd
()
elif
not
os
.
path
.
isabs
(
path
):
path
=
os
.
path
.
abspath
(
path
)
if
os
.
path
.
isfile
(
path
):
elif
os
.
path
.
isfile
(
path
):
try
:
zi
=
zipimporter
(
path
)
data
=
zi
.
get_data
(
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
:
pyx_module_path
=
os
.
path
.
join
(
path
,
pyx_module_name
)
if
not
os
.
path
.
isfile
(
pyx_module_path
):
pyx_data
=
zi
.
get_data
(
pyx_module_name
)
except
(
ZipImportError
,
IOError
,
OSError
):
continue
# Module not found.
# unzip the imported file into the build dir
# FIXME: can interfere with later imports if build dir is in sys.path and comes before zip file
path
=
self
.
pyxbuild_dir
elif
not
os
.
path
.
isabs
(
path
):
path
=
os
.
path
.
abspath
(
path
)
pyx_module_path
=
os
.
path
.
join
(
path
,
pyx_module_name
)
if
pyx_data
is
not
None
:
if
not
os
.
path
.
exists
(
path
):
try
:
os
.
makedirs
(
path
)
except
OSError
:
# concurrency issue?
if
not
os
.
path
.
exists
(
path
):
raise
with
open
(
pyx_module_path
,
"wb"
)
as
f
:
f
.
write
(
pyx_data
)
elif
not
os
.
path
.
isfile
(
pyx_module_path
):
continue
# Module not found.
return
PyxLoader
(
fullname
,
pyx_module_path
,
pyxbuild_dir
=
self
.
pyxbuild_dir
,
...
...
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