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
75b870b9
Commit
75b870b9
authored
Oct 12, 2017
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feed the hobgoblins (delint).
parent
cb9e3a35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
25 deletions
+47
-25
pkg_resources/__init__.py
pkg_resources/__init__.py
+47
-25
No files found.
pkg_resources/__init__.py
View file @
75b870b9
...
...
@@ -480,8 +480,10 @@ def get_build_platform():
try:
version = _macosx_vers()
machine = os.uname()[4].replace(" ", "_")
return "macosx-%d.%d-%s" % (int(version[0]), int(version[1]),
_macosx_arch(machine))
return "macosx-%d.%d-%s" % (
int(version[0]), int(version[1]),
_macosx_arch(machine),
)
except ValueError:
# if someone is running a non-Mac darwin system, this will fall
# through to the default implementation
...
...
@@ -806,7 +808,8 @@ class WorkingSet(object):
already-installed distribution; it should return a ``Distribution`` or
``None``.
Unless `replace_conflicting=True`, raises a VersionConflict exception if
Unless `replace_conflicting=True`, raises a VersionConflict exception
if
any requirements are found on the path that have the correct name but
the wrong version. Otherwise, if an `installer` is supplied it will be
invoked to obtain the correct version of the requirement and activate
...
...
@@ -885,8 +888,8 @@ class WorkingSet(object):
# return list of distros to activate
return to_activate
def find_plugins(
self, plugin_env, full_env=None, installer=None,
fallback=True):
def find_plugins(
self, plugin_env, full_env=None, installer=None,
fallback=True):
"""Find all activatable distributions in `plugin_env`
Example usage::
...
...
@@ -1040,7 +1043,8 @@ class _ReqExtras(dict):
class Environment(object):
"""
Searchable
snapshot
of
distributions
on
a
search
path
"""
def __init__(self, search_path=None, platform=get_supported_platform(),
def __init__(
self, search_path=None, platform=get_supported_platform(),
python=PY_MAJOR):
"""
Snapshot
distributions
available
on
a
search
path
...
...
@@ -1113,7 +1117,8 @@ class Environment(object):
dists.append(dist)
dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
def best_match(self, req, working_set, installer=None, replace_conflicting=False):
def best_match(
self, req, working_set, installer=None, replace_conflicting=False):
"""
Find
distribution
best
matching
`req`
and
usable
on
`working_set`
This
calls
the
``
find
(
req
)
``
method
of
the
`working_set`
to
see
if
a
...
...
@@ -1248,8 +1253,8 @@ class ResourceManager:
tmpl = textwrap.dedent("""
Can
't extract file(s) to egg cache
The following error occurred while trying to extract file(s)
to the Python egg
cache:
The following error occurred while trying to extract file(s)
to the Python egg
cache:
{old_exc}
...
...
@@ -1257,9 +1262,9 @@ class ResourceManager:
{cache_path}
Perhaps your account does not have write access to this directory?
You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.
Perhaps your account does not have write access to this directory?
You can change the cache directory by setting the PYTHON_EGG_CACHE
environment
variable to point to an accessible directory.
""").lstrip()
err = ExtractionError(tmpl.format(**locals()))
err.manager = self
...
...
@@ -1309,11 +1314,13 @@ class ResourceManager:
return
mode = os.stat(path).st_mode
if mode & stat.S_IWOTH or mode & stat.S_IWGRP:
msg = ("%s is writable by group/others and vulnerable to attack "
msg = (
"%s is writable by group/others and vulnerable to attack "
"when "
"used with get_resource_filename. Consider a more secure "
"location (set with .set_extraction_path or the "
"PYTHON_EGG_CACHE environment variable)." % path)
"PYTHON_EGG_CACHE environment variable)." % path
)
warnings.warn(msg, UserWarning)
def postprocess(self, tempname, filename):
...
...
@@ -1597,8 +1604,11 @@ class DefaultProvider(EggProvider):
@classmethod
def _register(cls):
loader_cls = getattr(importlib_machinery, 'SourceFileLoader',
type(None))
loader_cls = getattr(
importlib_machinery,
'SourceFileLoader',
type(None),
)
register_loader_type(loader_cls, cls)
...
...
@@ -1766,7 +1776,10 @@ class ZipProvider(EggProvider):
if self._is_current(real_path, zip_path):
return real_path
outf, tmpnam = _mkstemp(".$extract", dir=os.path.dirname(real_path))
outf, tmpnam = _mkstemp(
".$extract",
dir=os.path.dirname(real_path),
)
os.write(outf, self.loader.get_data(zip_path))
os.close(outf)
utime(tmpnam, (timestamp, timestamp))
...
...
@@ -1972,7 +1985,8 @@ def find_eggs_in_zip(importer, path_item, only=False):
for subitem in metadata.resource_listdir('/'):
if _is_egg_path(subitem):
subpath = os.path.join(path_item, subitem)
for dist in find_eggs_in_zip(zipimport.zipimporter(subpath), subpath):
dists = find_eggs_in_zip(zipimport.zipimporter(subpath), subpath)
for dist in dists:
yield dist
elif subitem.lower().endswith('.dist-info'):
subpath = os.path.join(path_item, subitem)
...
...
@@ -1981,7 +1995,6 @@ def find_eggs_in_zip(importer, path_item, only=False):
yield Distribution.from_location(path_item, subitem, submeta)
register_finder(zipimport.zipimporter, find_eggs_in_zip)
...
...
@@ -2527,7 +2540,8 @@ class Distribution(object):
"""
Wrap
an
actual
or
potential
sys
.
path
entry
w
/
metadata
"""
PKG_INFO = 'PKG-INFO'
def __init__(self, location=None, metadata=None, project_name=None,
def __init__(
self, location=None, metadata=None, project_name=None,
version=None, py_version=PY_MAJOR, platform=None,
precedence=EGG_DIST):
self.project_name = safe_name(project_name or 'Unknown')
...
...
@@ -2803,7 +2817,8 @@ class Distribution(object):
if replace:
break
else:
# don'
t
modify
path
(
even
removing
duplicates
)
if
found
and
not
replace
# don'
t
modify
path
(
even
removing
duplicates
)
if
# found and not replace
return
elif
item
==
bdir
and
self
.
precedence
==
EGG_DIST
:
# if it's an .egg, give it precedence over its directory
...
...
@@ -2900,7 +2915,10 @@ class EggInfoDistribution(Distribution):
class
DistInfoDistribution
(
Distribution
):
"""Wrap an actual or potential sys.path entry w/metadata, .dist-info style"""
"""
Wrap an actual or potential sys.path entry
w/metadata, .dist-info style.
"""
PKG_INFO
=
'METADATA'
EQEQ
=
re
.
compile
(
r"([\
(,])
\s*(\
d.*?)
\s*([,\
)])
")
...
...
@@ -2950,7 +2968,7 @@ _distributionImpl = {
'.egg': Distribution,
'.egg-info': EggInfoDistribution,
'.dist-info': DistInfoDistribution,
}
}
def issue_warning(*args, **kw):
...
...
@@ -3035,7 +3053,8 @@ class Requirement(packaging.requirements.Requirement):
def __hash__(self):
return self.__hash
def __repr__(self): return "
Requirement
.
parse
(
%
r
)
" % str(self)
def __repr__(self):
return "
Requirement
.
parse
(
%
r
)
" % str(self)
@staticmethod
def parse(s):
...
...
@@ -3169,7 +3188,10 @@ def _initialize_master_working_set():
dist.activate(replace=False)
for dist in working_set
)
add_activation_listener(lambda dist: dist.activate(replace=True), existing=False)
add_activation_listener(
lambda dist: dist.activate(replace=True),
existing=False,
)
working_set.entries = []
# match order
list(map(working_set.add_entry, sys.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