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
eeeb9b27
Commit
eeeb9b27
authored
Mar 17, 2018
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove SetuptoolsVersion and SetuptoolsLegacyVersion. Ref #296.
parent
d97e55a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
109 deletions
+12
-109
CHANGES.rst
CHANGES.rst
+10
-0
pkg_resources/__init__.py
pkg_resources/__init__.py
+2
-109
No files found.
CHANGES.rst
View file @
eeeb9b27
v39
.0.0
-------
*
#
296
:
Removed
long
-
deprecated
support
for
iteration
on
Version
objects
as
returned
by
``
pkg_resources
.
parse_version
``.
Removed
the
``
SetuptoolsVersion
``
and
``
SetuptoolsLegacyVersion
``
names
as
well
.
They
should
not
have
been
used
,
but
if
they
were
,
replace
with
``
Version
``
and
``
LegacyVersion
``
from
``
packaging
.
version
``.
v38
.7.0
v38
.7.0
-------
-------
...
...
pkg_resources/__init__.py
View file @
eeeb9b27
...
@@ -114,118 +114,11 @@ class PEP440Warning(RuntimeWarning):
...
@@ -114,118 +114,11 @@ class PEP440Warning(RuntimeWarning):
"""
"""
class
_SetuptoolsVersionMixin
(
object
):
def
__hash__
(
self
):
return
super
(
_SetuptoolsVersionMixin
,
self
).
__hash__
()
def
__lt__
(
self
,
other
):
if
isinstance
(
other
,
tuple
):
return
tuple
(
self
)
<
other
else
:
return
super
(
_SetuptoolsVersionMixin
,
self
).
__lt__
(
other
)
def
__le__
(
self
,
other
):
if
isinstance
(
other
,
tuple
):
return
tuple
(
self
)
<=
other
else
:
return
super
(
_SetuptoolsVersionMixin
,
self
).
__le__
(
other
)
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
tuple
):
return
tuple
(
self
)
==
other
else
:
return
super
(
_SetuptoolsVersionMixin
,
self
).
__eq__
(
other
)
def
__ge__
(
self
,
other
):
if
isinstance
(
other
,
tuple
):
return
tuple
(
self
)
>=
other
else
:
return
super
(
_SetuptoolsVersionMixin
,
self
).
__ge__
(
other
)
def
__gt__
(
self
,
other
):
if
isinstance
(
other
,
tuple
):
return
tuple
(
self
)
>
other
else
:
return
super
(
_SetuptoolsVersionMixin
,
self
).
__gt__
(
other
)
def
__ne__
(
self
,
other
):
if
isinstance
(
other
,
tuple
):
return
tuple
(
self
)
!=
other
else
:
return
super
(
_SetuptoolsVersionMixin
,
self
).
__ne__
(
other
)
def
__getitem__
(
self
,
key
):
return
tuple
(
self
)[
key
]
def
__iter__
(
self
):
component_re
=
re
.
compile
(
r'(\
d+ | [
a-z]+ | \
.| -)
', re.VERBOSE)
replace = {
'
pre
': '
c
',
'
preview
': '
c
',
'
-
': '
final
-
',
'
rc
': '
c
',
'
dev
': '
@
',
}.get
def _parse_version_parts(s):
for part in component_re.split(s):
part = replace(part, part)
if not part or part == '
.
':
continue
if part[:1] in '
0123456789
':
# pad for numeric comparison
yield part.zfill(8)
else:
yield '
*
' + part
# ensure that alpha/beta/candidate are before final
yield '
*
final
'
def old_parse_version(s):
parts = []
for part in _parse_version_parts(s.lower()):
if part.startswith('
*
'):
# remove '
-
' before a prerelease tag
if part < '
*
final
':
while parts and parts[-1] == '
*
final
-
':
parts.pop()
# remove trailing zeros from each series of numeric parts
while parts and parts[-1] == '
00000000
':
parts.pop()
parts.append(part)
return tuple(parts)
# Warn for use of this function
warnings.warn(
"You have iterated over the result of "
"pkg_resources.parse_version. This is a legacy behavior which is "
"inconsistent with the new version class introduced in setuptools "
"8.0. In most cases, conversion to a tuple is unnecessary. For "
"comparison of versions, sort the Version instances directly. If "
"you have another use case requiring the tuple, please file a "
"bug with the setuptools project describing that need.",
RuntimeWarning,
stacklevel=1,
)
for part in old_parse_version(str(self)):
yield part
class SetuptoolsVersion(_SetuptoolsVersionMixin, packaging.version.Version):
pass
class SetuptoolsLegacyVersion(_SetuptoolsVersionMixin,
packaging.version.LegacyVersion):
pass
def
parse_version
(
v
):
def
parse_version
(
v
):
try
:
try
:
return
Setuptools
Version(v)
return
packaging
.
version
.
Version
(
v
)
except
packaging
.
version
.
InvalidVersion
:
except
packaging
.
version
.
InvalidVersion
:
return
Setuptools
LegacyVersion(v)
return
packaging
.
version
.
LegacyVersion
(
v
)
_state_vars
=
{}
_state_vars
=
{}
...
...
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