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
1af011b1
Commit
1af011b1
authored
May 22, 2016
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract duplicate code into a single method.
parent
c05fd079
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
20 deletions
+28
-20
setuptools/command/build_py.py
setuptools/command/build_py.py
+28
-20
No files found.
setuptools/command/build_py.py
View file @
1af011b1
...
...
@@ -94,17 +94,12 @@ class build_py(orig.build_py, Mixin2to3):
def
find_data_files
(
self
,
package
,
src_dir
):
"""Return filenames for package's data files in 'src_dir'"""
spec
=
self
.
package_data
raw_patterns
=
itertools
.
chain
(
spec
.
get
(
''
,
[]),
spec
.
get
(
package
,
[]),
)
platform_patterns
=
(
# Each pattern has to be converted to a platform-specific path
os
.
path
.
join
(
src_dir
,
convert_path
(
pattern
))
for
pattern
in
raw_patterns
patterns
=
self
.
_get_platform_patterns
(
self
.
package_data
,
package
,
src_dir
,
)
globs_expanded
=
map
(
glob
,
p
latform_p
atterns
)
globs_expanded
=
map
(
glob
,
patterns
)
# flatten the expanded globs into an iterable of matches
globs_matches
=
itertools
.
chain
.
from_iterable
(
globs_expanded
)
glob_files
=
filter
(
os
.
path
.
isfile
,
globs_matches
)
...
...
@@ -197,19 +192,14 @@ class build_py(orig.build_py, Mixin2to3):
def
exclude_data_files
(
self
,
package
,
src_dir
,
files
):
"""Filter filenames for package's data files in 'src_dir'"""
files
=
list
(
files
)
spec
=
self
.
exclude_package_data
raw_patterns
=
itertools
.
chain
(
spec
.
get
(
''
,
[]),
spec
.
get
(
package
,
[]),
)
platform_patterns
=
(
# Each pattern has to be converted to a platform-specific path
os
.
path
.
join
(
src_dir
,
convert_path
(
pattern
))
for
pattern
in
raw_patterns
patterns
=
self
.
_get_platform_patterns
(
self
.
exclude_package_data
,
package
,
src_dir
,
)
match_groups
=
(
fnmatch
.
filter
(
files
,
pattern
)
for
pattern
in
p
latform_p
atterns
for
pattern
in
patterns
)
# flatten the groups of matches into an iterable of matches
matches
=
itertools
.
chain
.
from_iterable
(
match_groups
)
...
...
@@ -223,6 +213,24 @@ class build_py(orig.build_py, Mixin2to3):
and
not
next
(
seen
[
fn
])
]
@
staticmethod
def
_get_platform_patterns
(
spec
,
package
,
src_dir
):
"""
yield platfrom-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
"""
raw_patterns
=
itertools
.
chain
(
spec
.
get
(
''
,
[]),
spec
.
get
(
package
,
[]),
)
return
(
# Each pattern has to be converted to a platform-specific path
os
.
path
.
join
(
src_dir
,
convert_path
(
pattern
))
for
pattern
in
raw_patterns
)
def
assert_relative
(
path
):
if
not
os
.
path
.
isabs
(
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