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
52939bcc
Commit
52939bcc
authored
Feb 21, 2019
by
Chris Jerdonek
Committed by
Paul Ganssle
Apr 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Distribution._get_version() for DRY
parent
4876dbb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
pkg_resources/__init__.py
pkg_resources/__init__.py
+8
-2
No files found.
pkg_resources/__init__.py
View file @
52939bcc
...
...
@@ -2661,7 +2661,7 @@ class Distribution:
try
:
return
self
.
_version
except
AttributeError
:
version
=
_version_from_file
(
self
.
_get_metadata
(
self
.
PKG_INFO
)
)
version
=
self
.
_get_version
(
)
if
version
is
None
:
tmpl
=
"Missing 'Version:' header and/or %s file"
raise
ValueError
(
tmpl
%
self
.
PKG_INFO
,
self
)
...
...
@@ -2727,6 +2727,12 @@ class Distribution:
for
line
in
self
.
get_metadata_lines
(
name
):
yield
line
def
_get_version
(
self
):
lines
=
self
.
_get_metadata
(
self
.
PKG_INFO
)
version
=
_version_from_file
(
lines
)
return
version
def
activate
(
self
,
path
=
None
,
replace
=
False
):
"""Ensure distribution is importable on `path` (default=sys.path)"""
if
path
is
None
:
...
...
@@ -2945,7 +2951,7 @@ class EggInfoDistribution(Distribution):
take an extra step and try to get the version number from
the metadata file itself instead of the filename.
"""
md_version
=
_version_from_file
(
self
.
_get_metadata
(
self
.
PKG_INFO
)
)
md_version
=
self
.
_get_version
(
)
if
md_version
:
self
.
_version
=
md_version
return
self
...
...
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