Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
77b7c39d
Commit
77b7c39d
authored
Mar 22, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extracted _all_dirs and rewrote _find_packages_iter as a proper iterator.
parent
53ee4c9c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
25 deletions
+18
-25
setuptools/__init__.py
setuptools/__init__.py
+18
-25
No files found.
setuptools/__init__.py
View file @
77b7c39d
...
...
@@ -53,21 +53,24 @@ def find_packages(where='.', exclude=(), include=('*',)):
out
=
filterfalse
(
excludes
,
out
)
return
list
(
out
)
def
_find_packages_iter
(
where
):
out
=
[]
stack
=
[(
where
,
''
)]
while
stack
:
where
,
prefix
=
stack
.
pop
(
0
)
dirs
=
_dirs
(
where
)
def
_all_dirs
(
base_path
):
"""
Return all dirs in base_path, relative to base_path
"""
for
root
,
dirs
,
files
in
os
.
walk
(
base_path
):
for
dir
in
dirs
:
yield
os
.
path
.
relpath
(
os
.
path
.
join
(
root
,
dir
),
base_path
)
def
_find_packages_iter
(
base_path
):
dirs
=
_all_dirs
(
base_path
)
suitable
=
filterfalse
(
lambda
n
:
'.'
in
n
,
dirs
)
paths
=
(
os
.
path
.
join
(
where
,
name
)
for
name
in
suitable
)
packages
=
filter
(
_looks_like_package
,
paths
)
for
path
in
packages
:
name
=
os
.
path
.
basename
(
path
)
pkg_name
=
prefix
+
name
out
.
append
(
pkg_name
)
stack
.
append
((
path
,
pkg_name
+
'.'
))
return
out
packages
=
(
path
for
path
in
suitable
if
_looks_like_package
(
os
.
path
.
join
(
base_path
,
path
))
)
for
pkg_path
in
packages
:
yield
pkg_path
.
replace
(
os
.
path
.
sep
,
'.'
)
def
_looks_like_package
(
path
):
return
(
...
...
@@ -75,16 +78,6 @@ def _looks_like_package(path):
or
sys
.
version_info
[:
2
]
>=
(
3
,
3
)
# PEP 420
)
def
_dirs
(
target
):
"""
Return all directories in target
"""
return
(
fn
for
fn
in
os
.
listdir
(
target
)
if
os
.
path
.
isdir
(
os
.
path
.
join
(
target
,
fn
))
)
def
_build_filter
(
*
patterns
):
"""
Given a list of patterns, return a callable that will be true only if
...
...
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