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
Boxiang Sun
cython
Commits
17ebac85
Commit
17ebac85
authored
Jun 04, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
another little Pyrex merge that extracts FQ module names from source file names
parent
f6a3f4c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+25
-5
No files found.
Cython/Compiler/Main.py
View file @
17ebac85
...
...
@@ -190,7 +190,14 @@ class Context:
def
find_cimported_module_names
(
self
,
source_path
):
return
[
name
for
kind
,
name
in
self
.
read_dependency_file
(
source_path
)
if
kind
==
"cimport"
]
def
is_package_dir
(
self
,
dir_path
):
# Return true if the given directory is a package directory.
for
filename
in
(
"__init__.py"
,
"__init__.pyx"
):
path
=
os
.
path
.
join
(
dir_path
,
filename
)
if
os
.
path
.
exists
(
path
):
return
1
def
read_dependency_file
(
self
,
source_path
):
dep_path
=
replace_suffix
(
source_path
,
".dep"
)
if
os
.
path
.
exists
(
dep_path
):
...
...
@@ -234,10 +241,23 @@ class Context:
return
tree
def
extract_module_name
(
self
,
path
,
options
):
# Get the module name out of a source file pathname.
_
,
tail
=
os
.
path
.
split
(
path
)
name
,
_
=
os
.
path
.
splitext
(
tail
)
return
name
# Find fully_qualified module name from the full pathname
# of a source file.
dir
,
filename
=
os
.
path
.
split
(
path
)
module_name
,
_
=
os
.
path
.
splitext
(
filename
)
if
"."
in
module_name
:
return
module_name
if
module_name
==
"__init__"
:
dir
,
module_name
=
os
.
path
.
split
(
dir
)
names
=
[
module_name
]
while
self
.
is_package_dir
(
dir
):
parent
,
package_name
=
os
.
path
.
split
(
dir
)
if
parent
==
dir
:
break
names
.
append
(
package_name
)
dir
=
parent
names
.
reverse
()
return
"."
.
join
(
names
)
def
compile
(
self
,
source
,
options
=
None
,
full_module_name
=
None
):
# Compile a Pyrex implementation file in this context
...
...
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