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
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
Show 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,46 +287,44 @@ class PyxImporter(object):
...
@@ -287,46 +287,44 @@ class PyxImporter(object):
# searching sys.path ...
# searching sys.path ...
#if DEBUG_IMPORT: print "SEARCHING", fullname, package_path
#if DEBUG_IMPORT: print "SEARCHING", fullname, package_path
if
'.'
in
fullname
:
# only when package_path anyway?
mod_parts
=
fullname
.
split
(
'.'
)
mod_parts
=
fullname
.
split
(
'.'
)
module_name
=
mod_parts
[
-
1
]
module_name
=
mod_parts
[
-
1
]
else
:
module_name
=
fullname
pyx_module_name
=
module_name
+
self
.
extension
pyx_module_name
=
module_name
+
self
.
extension
# this may work, but it returns the file content, not its path
# this may work, but it returns the file content, not its path
#import pkgutil
#import pkgutil
#pyx_source = pkgutil.get_data(package, pyx_module_name)
#pyx_source = pkgutil.get_data(package, pyx_module_name)
if
package_path
:
paths
=
package_path
or
sys
.
path
paths
=
package_path
else
:
paths
=
sys
.
path
for
path
in
paths
:
for
path
in
paths
:
pyx_data
=
None
if
not
path
:
if
not
path
:
path
=
os
.
getcwd
()
path
=
os
.
getcwd
()
elif
not
os
.
path
.
isabs
(
path
):
elif
os
.
path
.
isfile
(
path
):
path
=
os
.
path
.
abspath
(
path
)
if
os
.
path
.
isfile
(
path
):
try
:
try
:
zi
=
zipimporter
(
path
)
zi
=
zipimporter
(
path
)
data
=
zi
.
get_data
(
pyx_module_name
)
pyx_
data
=
zi
.
get_data
(
pyx_module_name
)
except
(
ZipImportError
,
IOError
):
except
(
ZipImportError
,
IOError
,
OSError
):
continue
# Module not found.
continue
# Module not found.
else
:
# unzip the imported file into the build dir
# XXX unzip the imported file into the build dir. A bit
# FIXME: can interfere with later imports if build dir is in sys.path and comes before zip file
# hacky, but it works!
path
=
self
.
pyxbuild_dir
if
not
os
.
path
.
exists
(
self
.
pyxbuild_dir
):
elif
not
os
.
path
.
isabs
(
path
):
os
.
makedirs
(
self
.
pyxbuild_dir
)
path
=
os
.
path
.
abspath
(
path
)
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
)
pyx_module_path
=
os
.
path
.
join
(
path
,
pyx_module_name
)
if
not
os
.
path
.
isfile
(
pyx_module_path
):
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.
continue
# Module not found.
return
PyxLoader
(
fullname
,
pyx_module_path
,
return
PyxLoader
(
fullname
,
pyx_module_path
,
...
...
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