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
29d9fc67
Commit
29d9fc67
authored
Aug 19, 2016
by
Jason R. Coombs
Committed by
GitHub
Aug 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #742 from stepshal/whitespace
Add missing whitespace after comma.
parents
30594015
a527fa46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
52 deletions
+52
-52
pkg_resources/__init__.py
pkg_resources/__init__.py
+17
-17
pkg_resources/tests/test_resources.py
pkg_resources/tests/test_resources.py
+35
-35
No files found.
pkg_resources/__init__.py
View file @
29d9fc67
...
...
@@ -752,8 +752,8 @@ class WorkingSet(object):
if entry is None:
entry = dist.location
keys = self.entry_keys.setdefault(entry,[])
keys2 = self.entry_keys.setdefault(dist.location,[])
keys = self.entry_keys.setdefault(entry,
[])
keys2 = self.entry_keys.setdefault(dist.location,
[])
if not replace and dist.key in self.by_key:
# ignore hidden distros
return
...
...
@@ -1353,7 +1353,7 @@ def get_default_cache():
# best option, should be locale-safe
(('
APPDATA
',), None),
(('
USERPROFILE
',), app_data),
(('
HOMEDRIVE
','
HOMEPATH
'), app_data),
(('
HOMEDRIVE
',
'
HOMEPATH
'), app_data),
(('
HOMEPATH
',), app_data),
(('
HOME
',), None),
# 95/98/ME
...
...
@@ -1392,7 +1392,7 @@ def safe_version(version):
# normalize the version
return str(packaging.version.Version(version))
except packaging.version.InvalidVersion:
version = version.replace('
','
.
')
version = version.replace('
',
'
.
')
return re.sub('
[
^
A
-
Za
-
z0
-
9.
]
+
', '
-
', version)
...
...
@@ -1410,7 +1410,7 @@ def to_filename(name):
Any '
-
' characters are currently replaced with '
_
'.
"""
return name.replace('
-
','
_
')
return name.replace('
-
',
'
_
')
def invalid_marker(text):
...
...
@@ -1508,7 +1508,7 @@ class NullProvider:
cache[script_filename] = (
len(script_text), 0, script_text.split('
\
n
'), script_filename
)
script_code = compile(script_text, script_filename,'
exec
')
script_code = compile(script_text, script_filename,
'
exec
')
exec(script_code, namespace, namespace)
def _has(self, path):
...
...
@@ -1965,7 +1965,7 @@ def find_on_path(importer, path_item, only=False):
if
_is_unpacked_egg
(
path_item
):
yield
Distribution
.
from_filename
(
path_item
,
metadata
=
PathMetadata
(
path_item
,
os
.
path
.
join
(
path_item
,
'EGG-INFO'
)
path_item
,
os
.
path
.
join
(
path_item
,
'EGG-INFO'
)
)
)
else
:
...
...
@@ -2037,7 +2037,7 @@ def _handle_ns(packageName, path_item):
module
=
sys
.
modules
[
packageName
]
=
types
.
ModuleType
(
packageName
)
module
.
__path__
=
[]
_set_parent_ns
(
packageName
)
elif
not
hasattr
(
module
,
'__path__'
):
elif
not
hasattr
(
module
,
'__path__'
):
raise
TypeError
(
"Not a package:"
,
packageName
)
handler
=
_find_adapter
(
_namespace_handlers
,
importer
)
subpath
=
handler
(
importer
,
path_item
,
packageName
,
module
)
...
...
@@ -2089,8 +2089,8 @@ def declare_namespace(packageName):
# Track what packages are namespaces, so when new path items are added,
# they can be updated
_namespace_packages
.
setdefault
(
parent
,[]).
append
(
packageName
)
_namespace_packages
.
setdefault
(
packageName
,[])
_namespace_packages
.
setdefault
(
parent
,
[]).
append
(
packageName
)
_namespace_packages
.
setdefault
(
packageName
,
[])
for
path_item
in
path
:
# Ensure all the parent's path items are reflected in the child,
...
...
@@ -2104,7 +2104,7 @@ def fixup_namespace_packages(path_item, parent=None):
"""Ensure that previously-declared namespace packages include path_item"""
_imp
.
acquire_lock
()
try
:
for
package
in
_namespace_packages
.
get
(
parent
,()):
for
package
in
_namespace_packages
.
get
(
parent
,
()):
subpath
=
_handle_ns
(
package
,
path_item
)
if
subpath
:
fixup_namespace_packages
(
subpath
,
package
)
...
...
@@ -2482,7 +2482,7 @@ class Distribution(object):
elif
not
evaluate_marker
(
marker
):
reqs
=
[]
extra
=
safe_extra
(
extra
)
or
None
dm
.
setdefault
(
extra
,[]).
extend
(
parse_requirements
(
reqs
))
dm
.
setdefault
(
extra
,
[]).
extend
(
parse_requirements
(
reqs
))
return
dm
def
requires
(
self
,
extras
=
()):
...
...
@@ -2578,7 +2578,7 @@ class Distribution(object):
self
.
_get_metadata
(
'entry_points.txt'
),
self
)
if
group
is
not
None
:
return
ep_map
.
get
(
group
,{})
return
ep_map
.
get
(
group
,
{})
return
ep_map
def
get_entry_info
(
self
,
group
,
name
):
...
...
@@ -2682,7 +2682,7 @@ class Distribution(object):
return
False
return
True
def
clone
(
self
,
**
kw
):
def
clone
(
self
,
**
kw
):
"""Copy this distribution, substituting in any changed keyword args"""
names
=
'project_name version py_version platform location precedence'
for
attr
in
names
.
split
():
...
...
@@ -2769,7 +2769,7 @@ _distributionImpl = {
}
def issue_warning(*args,**kw):
def issue_warning(*args,
**kw):
level = 1
g = globals()
try:
...
...
@@ -2916,12 +2916,12 @@ def split_sections(s):
# wrap up last segment
yield section, content
def _mkstemp(*args,**kw):
def _mkstemp(*args,
**kw):
old_open = os.open
try:
# temporarily bypass sandboxing
os.open = os_open
return tempfile.mkstemp(*args,**kw)
return tempfile.mkstemp(*args,
**kw)
finally:
# and then put it back
os.open = old_open
...
...
pkg_resources/tests/test_resources.py
View file @
29d9fc67
...
...
@@ -51,15 +51,15 @@ class TestDistro:
assert
list
(
ad
)
==
[
'foopkg'
]
# Distributions sort by version
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
[
'1.4'
,
'1.3-1'
,
'1.2'
]
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
[
'1.4'
,
'1.3-1'
,
'1.2'
]
# Removing a distribution leaves sequence alone
ad
.
remove
(
ad
[
'FooPkg'
][
1
])
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
[
'1.4'
,
'1.2'
]
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
[
'1.4'
,
'1.2'
]
# And inserting adds them in order
ad
.
add
(
dist_from_fn
(
"FooPkg-1.9.egg"
))
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
[
'1.9'
,
'1.4'
,
'1.2'
]
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
[
'1.9'
,
'1.4'
,
'1.2'
]
ws
=
WorkingSet
([])
foo12
=
dist_from_fn
(
"FooPkg-1.2-py2.4.egg"
)
...
...
@@ -86,7 +86,7 @@ class TestDistro:
ws
.
add
(
foo14
)
assert
ad
.
best_match
(
req
,
ws
).
version
==
'1.4'
def
checkFooPkg
(
self
,
d
):
def
checkFooPkg
(
self
,
d
):
assert
d
.
project_name
==
"FooPkg"
assert
d
.
key
==
"foopkg"
assert
d
.
version
==
"1.3.post1"
...
...
@@ -97,7 +97,7 @@ class TestDistro:
def
testDistroBasics
(
self
):
d
=
Distribution
(
"/some/path"
,
project_name
=
"FooPkg"
,
version
=
"1.3-1"
,
py_version
=
"2.4"
,
platform
=
"win32"
project_name
=
"FooPkg"
,
version
=
"1.3-1"
,
py_version
=
"2.4"
,
platform
=
"win32"
)
self
.
checkFooPkg
(
d
)
...
...
@@ -115,7 +115,7 @@ class TestDistro:
d
=
Distribution
(
"/some/path"
,
project_name
=
"FooPkg"
,
py_version
=
"2.4"
,
platform
=
"win32"
,
metadata
=
Metadata
(
(
'PKG-INFO'
,
"Metadata-Version: 1.0
\
n
Version: 1.3-1
\
n
"
)
(
'PKG-INFO'
,
"Metadata-Version: 1.0
\
n
Version: 1.3-1
\
n
"
)
)
)
self
.
checkFooPkg
(
d
)
...
...
@@ -164,7 +164,7 @@ class TestDistro:
ad
.
add
(
Baz
)
# Activation list now includes resolved dependency
assert
list
(
ws
.
resolve
(
parse_requirements
(
"Foo[bar]"
),
ad
))
==
[
Foo
,
Baz
]
assert
list
(
ws
.
resolve
(
parse_requirements
(
"Foo[bar]"
),
ad
))
==
[
Foo
,
Baz
]
# Requests for conflicting versions produce VersionConflict
with
pytest
.
raises
(
VersionConflict
)
as
vc
:
ws
.
resolve
(
parse_requirements
(
"Foo==1.2
\
n
Foo!=1.2"
),
ad
)
...
...
@@ -218,7 +218,7 @@ class TestDistro:
quux
=
Distribution
.
from_filename
(
"/foo_dir/quux-1.0.dist-info"
)
ad
.
add
(
quux
)
res
=
list
(
ws
.
resolve
(
parse_requirements
(
"Foo[baz]"
),
ad
))
assert
res
==
[
Foo
,
quux
]
assert
res
==
[
Foo
,
quux
]
def
test_marker_evaluation_with_multiple_extras
(
self
):
ad
=
pkg_resources
.
Environment
([])
...
...
@@ -238,7 +238,7 @@ class TestDistro:
fred
=
Distribution
.
from_filename
(
"/foo_dir/fred-0.1.dist-info"
)
ad
.
add
(
fred
)
res
=
list
(
ws
.
resolve
(
parse_requirements
(
"Foo[baz,bar]"
),
ad
))
assert
sorted
(
res
)
==
[
fred
,
quux
,
Foo
]
assert
sorted
(
res
)
==
[
fred
,
quux
,
Foo
]
def
test_marker_evaluation_with_extras_loop
(
self
):
ad
=
pkg_resources
.
Environment
([])
...
...
@@ -274,19 +274,19 @@ class TestDistro:
docutils>=0.3
[fastcgi]
fcgiapp>=0.1"""
)
self
.
checkRequires
(
d
,
"Twisted>=1.5"
)
self
.
checkRequires
(
d
,
"Twisted>=1.5"
)
self
.
checkRequires
(
d
,
"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3"
.
split
(),
[
"docgen"
]
d
,
"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3"
.
split
(),
[
"docgen"
]
)
self
.
checkRequires
(
d
,
"Twisted>=1.5 fcgiapp>=0.1"
.
split
(),
[
"fastcgi"
]
d
,
"Twisted>=1.5 fcgiapp>=0.1"
.
split
(),
[
"fastcgi"
]
)
self
.
checkRequires
(
d
,
"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3 fcgiapp>=0.1"
.
split
(),
[
"docgen"
,
"fastcgi"
]
d
,
"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3 fcgiapp>=0.1"
.
split
(),
[
"docgen"
,
"fastcgi"
]
)
self
.
checkRequires
(
d
,
"Twisted>=1.5 fcgiapp>=0.1 ZConfig>=2.0 docutils>=0.3"
.
split
(),
d
,
"Twisted>=1.5 fcgiapp>=0.1 ZConfig>=2.0 docutils>=0.3"
.
split
(),
[
"fastcgi"
,
"docgen"
]
)
with
pytest
.
raises
(
pkg_resources
.
UnknownExtra
):
...
...
@@ -348,7 +348,7 @@ class TestEntryPoints:
def
setup_method
(
self
,
method
):
self
.
dist
=
Distribution
.
from_filename
(
"FooPkg-1.2-py2.4.egg"
,
metadata
=
Metadata
((
'requires.txt'
,
'[x]'
)))
"FooPkg-1.2-py2.4.egg"
,
metadata
=
Metadata
((
'requires.txt'
,
'[x]'
)))
def
testBasics
(
self
):
ep
=
EntryPoint
(
...
...
@@ -405,7 +405,7 @@ class TestEntryPoints:
submap_expect
=
dict
(
feature1
=
EntryPoint
(
'feature1'
,
'somemodule'
,
[
'somefunction'
]),
feature2
=
EntryPoint
(
'feature2'
,
'another.module'
,
[
'SomeClass'
],
[
'extra1'
,
'extra2'
]),
feature2
=
EntryPoint
(
'feature2'
,
'another.module'
,
[
'SomeClass'
],
[
'extra1'
,
'extra2'
]),
feature3
=
EntryPoint
(
'feature3'
,
'this.module'
,
extras
=
[
'something'
])
)
submap_str
=
"""
...
...
@@ -423,7 +423,7 @@ class TestEntryPoints:
EntryPoint
.
parse_group
(
"x"
,
[
"foo=baz"
,
"foo=bar"
])
def
testParseMap
(
self
):
m
=
EntryPoint
.
parse_map
({
'xyz'
:
self
.
submap_str
})
m
=
EntryPoint
.
parse_map
({
'xyz'
:
self
.
submap_str
})
self
.
checkSubMap
(
m
[
'xyz'
])
assert
list
(
m
.
keys
())
==
[
'xyz'
]
m
=
EntryPoint
.
parse_map
(
"[xyz]
\
n
"
+
self
.
submap_str
)
...
...
@@ -480,7 +480,7 @@ class TestRequirements:
hash
((
"twisted"
,
packaging
.
specifiers
.
SpecifierSet
(
">=1.2"
),
frozenset
([
"foo"
,
"bar"
]),
frozenset
([
"foo"
,
"bar"
]),
None
))
)
...
...
@@ -521,9 +521,9 @@ class TestParsing:
assert
list
(
parse_requirements
(
''
))
==
[]
def
testYielding
(
self
):
for
inp
,
out
in
[
([],
[]),
(
'x'
,
[
'x'
]),
([[]],[]),
(
' x
\
n
y'
,
[
'x'
,
'y'
]),
([
'x
\
n
\
n
'
,
'y'
],
[
'x'
,
'y'
]),
for
inp
,
out
in
[
([],
[]),
(
'x'
,
[
'x'
]),
([[]],
[]),
(
' x
\
n
y'
,
[
'x'
,
'y'
]),
([
'x
\
n
\
n
'
,
'y'
],
[
'x'
,
'y'
]),
]:
assert
list
(
pkg_resources
.
yield_lines
(
inp
))
==
out
...
...
@@ -626,9 +626,9 @@ class TestParsing:
req
,
=
parse_requirements
(
'foo >= 1.0, < 3'
)
def
testVersionEquality
(
self
):
def
c
(
s1
,
s2
):
p1
,
p2
=
parse_version
(
s1
),
parse_version
(
s2
)
assert
p1
==
p2
,
(
s1
,
s2
,
p1
,
p2
)
def
c
(
s1
,
s2
):
p1
,
p2
=
parse_version
(
s1
),
parse_version
(
s2
)
assert
p1
==
p2
,
(
s1
,
s2
,
p1
,
p2
)
c
(
'1.2-rc1'
,
'1.2rc1'
)
c
(
'0.4'
,
'0.4.0'
)
...
...
@@ -642,13 +642,13 @@ class TestParsing:
c
(
'1.2.a'
,
'1.2a'
)
def
testVersionOrdering
(
self
):
def
c
(
s1
,
s2
):
p1
,
p2
=
parse_version
(
s1
),
parse_version
(
s2
)
assert
p1
<
p2
,
(
s1
,
s2
,
p1
,
p2
)
def
c
(
s1
,
s2
):
p1
,
p2
=
parse_version
(
s1
),
parse_version
(
s2
)
assert
p1
<
p2
,
(
s1
,
s2
,
p1
,
p2
)
c
(
'2.1'
,
'2.1.1'
)
c
(
'2a1'
,
'2b0'
)
c
(
'2a1'
,
'2.1'
)
c
(
'2.1'
,
'2.1.1'
)
c
(
'2a1'
,
'2b0'
)
c
(
'2a1'
,
'2.1'
)
c
(
'2.3a1'
,
'2.3'
)
c
(
'2.1-1'
,
'2.1-2'
)
c
(
'2.1-1'
,
'2.1.1'
)
...
...
@@ -660,8 +660,8 @@ class TestParsing:
c
(
'0.4'
,
'4.0'
)
c
(
'0.0.4'
,
'0.4.0'
)
c
(
'0post1'
,
'0.4post1'
)
c
(
'2.1.0-rc1'
,
'2.1.0'
)
c
(
'2.1dev'
,
'2.1a0'
)
c
(
'2.1.0-rc1'
,
'2.1.0'
)
c
(
'2.1dev'
,
'2.1a0'
)
torture
=
"""
0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1
...
...
@@ -669,9 +669,9 @@ class TestParsing:
0.77.2-1 0.77.1-1 0.77.0-1
"""
.
split
()
for
p
,
v1
in
enumerate
(
torture
):
for
p
,
v1
in
enumerate
(
torture
):
for
v2
in
torture
[
p
+
1
:]:
c
(
v2
,
v1
)
c
(
v2
,
v1
)
def
testVersionBuildout
(
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