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
e75bb059
Commit
e75bb059
authored
May 22, 2016
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-use unique_everseen from itertools recipes.
parent
1af011b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
setuptools/command/build_py.py
setuptools/command/build_py.py
+24
-7
No files found.
setuptools/command/build_py.py
View file @
e75bb059
...
...
@@ -6,10 +6,9 @@ import fnmatch
import
textwrap
import
io
import
distutils.errors
import
collections
import
itertools
from
setuptools.extern.six.moves
import
map
,
filter
from
setuptools.extern.six.moves
import
map
,
filter
,
filterfalse
try
:
from
setuptools.lib2to3_ex
import
Mixin2to3
...
...
@@ -204,14 +203,13 @@ class build_py(orig.build_py, Mixin2to3):
# flatten the groups of matches into an iterable of matches
matches
=
itertools
.
chain
.
from_iterable
(
match_groups
)
bad
=
set
(
matches
)
seen
=
collections
.
defaultdict
(
itertools
.
count
)
return
[
keepers
=
(
fn
for
fn
in
files
if
fn
not
in
bad
# ditch dupes
and
not
next
(
seen
[
fn
])
]
)
# ditch dupes
return
list
(
_unique_everseen
(
keepers
))
@
staticmethod
def
_get_platform_patterns
(
spec
,
package
,
src_dir
):
...
...
@@ -232,6 +230,25 @@ class build_py(orig.build_py, Mixin2to3):
)
# from Python docs
def
_unique_everseen
(
iterable
,
key
=
None
):
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
seen
=
set
()
seen_add
=
seen
.
add
if
key
is
None
:
for
element
in
filterfalse
(
seen
.
__contains__
,
iterable
):
seen_add
(
element
)
yield
element
else
:
for
element
in
iterable
:
k
=
key
(
element
)
if
k
not
in
seen
:
seen_add
(
k
)
yield
element
def
assert_relative
(
path
):
if
not
os
.
path
.
isabs
(
path
):
return
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