Skip to content

Commit

Permalink
Merge pull request #2685 from dstufft/upgrade-packaging
Browse files Browse the repository at this point in the history
Upgrade packaging to 15.1
  • Loading branch information
dstufft committed Apr 15, 2015
2 parents d043e4b + fca9173 commit a761f01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pip/_vendor/packaging/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__summary__ = "Core utilities for Python packages"
__uri__ = "https:/pypa/packaging"

__version__ = "15.0"
__version__ = "15.1"

__author__ = "Donald Stufft"
__email__ = "[email protected]"
Expand Down
46 changes: 19 additions & 27 deletions pip/_vendor/packaging/specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,14 @@ def prereleases(self):
if self._prereleases is not None:
return self._prereleases

# If we don't have any specifiers, and we don't have a forced value,
# then we'll just return None since we don't know if this should have
# pre-releases or not.
if not self._specs:
return None

# Otherwise we'll see if any of the given specifiers accept
# prereleases, if any of them do we'll return True, otherwise False.
# Note: The use of any() here means that an empty set of specifiers
# will always return False, this is an explicit design decision.
return any(s.prereleases for s in self._specs)

@prereleases.setter
Expand All @@ -688,27 +692,21 @@ def contains(self, item, prereleases=None):
if not isinstance(item, (LegacyVersion, Version)):
item = parse(item)

# Determine if we're forcing a prerelease or not, if we're not forcing
# one for this particular filter call, then we'll use whatever the
# SpecifierSet thinks for whether or not we should support prereleases.
if prereleases is None:
prereleases = self.prereleases

# We can determine if we're going to allow pre-releases by looking to
# see if any of the underlying items supports them. If none of them do
# and this item is a pre-release then we do not allow it and we can
# short circuit that here.
# Note: This means that 1.0.dev1 would not be contained in something
# like >=1.0.devabc however it would be in >=1.0.debabc,>0.0.dev0
if (not (self.prereleases or prereleases)) and item.is_prerelease:
if not prereleases and item.is_prerelease:
return False

# Determine if we're forcing a prerelease or not, we bypass
# self.prereleases here and use self._prereleases because we want to
# only take into consideration actual *forced* values. The underlying
# specifiers will handle the other logic.
# The logic here is: If prereleases is anything but None, we'll just
# go aheand and continue to use that. However if
# prereleases is None, then we'll use whatever the
# value of self._prereleases is as long as it is not
# None itself.
if prereleases is None and self._prereleases is not None:
prereleases = self._prereleases

# We simply dispatch to the underlying specs here to make sure that the
# given version is contained within all of them.
# Note: This use of all() here means that an empty set of specifiers
Expand All @@ -719,24 +717,18 @@ def contains(self, item, prereleases=None):
)

def filter(self, iterable, prereleases=None):
# Determine if we're forcing a prerelease or not, we bypass
# self.prereleases here and use self._prereleases because we want to
# only take into consideration actual *forced* values. The underlying
# specifiers will handle the other logic.
# The logic here is: If prereleases is anything but None, we'll just
# go aheand and continue to use that. However if
# prereleases is None, then we'll use whatever the
# value of self._prereleases is as long as it is not
# None itself.
if prereleases is None and self._prereleases is not None:
prereleases = self._prereleases
# Determine if we're forcing a prerelease or not, if we're not forcing
# one for this particular filter call, then we'll use whatever the
# SpecifierSet thinks for whether or not we should support prereleases.
if prereleases is None:
prereleases = self.prereleases

# If we have any specifiers, then we want to wrap our iterable in the
# filter method for each one, this will act as a logical AND amongst
# each specifier.
if self._specs:
for spec in self._specs:
iterable = spec.filter(iterable, prereleases=prereleases)
iterable = spec.filter(iterable, prereleases=bool(prereleases))
return iterable
# If we do not have any specifiers, then we need to have a rough filter
# which will filter out any pre-releases, unless there are no final
Expand Down
2 changes: 1 addition & 1 deletion pip/_vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ CacheControl==0.11.2
lockfile==0.10.2
progress==1.2
ipaddress==1.0.7 # Only needed on 2.6, 2.7, and 3.2
packaging==15.0
packaging==15.1
retrying==1.3.3

0 comments on commit a761f01

Please sign in to comment.