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
e2e71004
Commit
e2e71004
authored
Sep 01, 2015
by
Eric Larson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Look deeper at .egg-info files for package name and version information when available.
parent
03e7e8c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
pkg_resources/__init__.py
pkg_resources/__init__.py
+28
-7
No files found.
pkg_resources/__init__.py
View file @
e2e71004
...
...
@@ -2466,6 +2466,13 @@ def _remove_md5_fragment(location):
return location
def _version_from_file(fid):
for line in fid:
if line.lower().startswith('
version
:
'):
version = safe_version(line.split('
:
', 1)[1].strip())
return version
class Distribution(object):
"""Wrap an actual or potential sys.path entry w/metadata"""
PKG_INFO = '
PKG
-
INFO
'
...
...
@@ -2483,7 +2490,7 @@ class Distribution(object):
self._provider = metadata or empty_provider
@classmethod
def from_location(cls, location, basename, metadata=None,**kw):
def from_location(cls, location, basename, metadata=None,
**kw):
project_name, version, py_version, platform = [None]*4
basename, ext = os.path.splitext(basename)
if ext.lower() in _distributionImpl:
...
...
@@ -2491,9 +2498,25 @@ class Distribution(object):
match = EGG_NAME(basename)
if match:
project_name, version, py_version, platform = match.group(
'
name
',
'
ver
','
pyver
',
'
plat
'
'
name
',
'
ver
', '
pyver
',
'
plat
'
)
cls = _distributionImpl[ext.lower()]
# Some packages e.g. numpy and scipy use distutils instead of
# setuptools, and their version numbers can get mangled when
# converted to filenames (e.g., 1.11.0.dev0+2329eae to
# 1.11.0.dev0_2329eae). These will not be parsed properly
# downstream by Distribution and safe_version, so we need to
# take an extra step and try to get the version number from
# the file itself instead of the filename.
if ext == '
.
egg
-
info
':
full_name = os.path.join(location, basename + ext)
try:
with open(full_name, 'r') as fid:
version_ = _version_from_file(fid)
version = version_ if version_ is not None else version
except IOError:
pass
return cls(
location, metadata, project_name=project_name, version=version,
py_version=py_version, platform=platform, **kw
...
...
@@ -2584,13 +2607,11 @@ class Distribution(object):
try
:
return
self
.
_version
except
AttributeError
:
for
line
in
self
.
_get_metadata
(
self
.
PKG_INFO
):
if
line
.
lower
().
startswith
(
'version:'
):
self
.
_version
=
safe_version
(
line
.
split
(
':'
,
1
)[
1
].
strip
())
return
self
.
_version
else
:
version
=
_version_from_file
(
self
.
_get_metadata
(
self
.
PKG_INFO
))
if
version
is
None
:
tmpl
=
"Missing 'Version:' header and/or %s file"
raise
ValueError
(
tmpl
%
self
.
PKG_INFO
,
self
)
return
version
@
property
def
_dep_map
(
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