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
d71ace55
Commit
d71ace55
authored
Nov 11, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extended glob that handles ** for arbitrary directory nesting.
parent
595fd56e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
4 deletions
+60
-4
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+22
-4
tests/build/cythonize_glob.srctree
tests/build/cythonize_glob.srctree
+38
-0
No files found.
Cython/Build/Dependencies.py
View file @
d71ace55
from
glob
import
glob
from
glob
import
i
glob
import
re
,
os
,
sys
...
...
@@ -33,6 +33,24 @@ def cached_method(f):
return
res
return
wrapper
def
extended_iglob
(
pattern
):
if
'**/'
in
pattern
:
seen
=
set
()
first
,
rest
=
pattern
.
split
(
'**/'
,
1
)
if
first
==
''
:
first
=
'.'
for
root
in
iglob
(
first
+
"/"
):
for
path
in
extended_iglob
(
os
.
path
.
join
(
root
,
rest
)):
if
path
not
in
seen
:
seen
.
add
(
path
)
yield
path
for
path
in
extended_iglob
(
os
.
path
.
join
(
root
,
'*'
,
'**'
,
rest
)):
if
path
not
in
seen
:
seen
.
add
(
path
)
yield
path
else
:
for
path
in
iglob
(
pattern
):
yield
path
def
parse_list
(
s
):
"""
...
...
@@ -411,7 +429,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None):
if
not
isinstance
(
exclude
,
list
):
exclude
=
[
exclude
]
for
pattern
in
exclude
:
to_exclude
.
update
(
glob
(
pattern
))
to_exclude
.
update
(
extended_i
glob
(
pattern
))
if
not
isinstance
(
patterns
,
list
):
patterns
=
[
patterns
]
module_list
=
[]
...
...
@@ -434,7 +452,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None):
exn_type
=
template
.
__class__
else
:
raise
TypeError
(
pattern
)
for
file
in
glob
(
filepattern
):
for
file
in
extended_i
glob
(
filepattern
):
if
file
in
to_exclude
:
continue
pkg
=
deps
.
package
(
file
)
...
...
tests/build/cythonize_glob.srctree
0 → 100644
View file @
d71ace55
PYTHON setup.py build_ext --inplace
PYTHON -c "import runner"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize("**/a*.pyx", include_path=['subdir'], compiler_directives={'cdivision': True}),
)
######## a.pyx ########
######## p1/__init__.py ########
######## p1/a.pyx ########
######## p1/ab.pyx ########
######## p1/b.pyx ########
######## p1/p2/__init__.py ########
######## p1/p2/a.pyx ########
######## runner.py ########
import a
import p1.a
import p1.ab
import p1.p2.a
try:
import p1.b
assert False, "b should not be complied"
except ImportError:
pass
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