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
e065e901
Commit
e065e901
authored
Mar 06, 2018
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feed the hobgoblins (delint).
parent
c9ecd46f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
18 deletions
+42
-18
pkg_resources/__init__.py
pkg_resources/__init__.py
+1
-1
pkg_resources/tests/test_find_distributions.py
pkg_resources/tests/test_find_distributions.py
+1
-0
pkg_resources/tests/test_pkg_resources.py
pkg_resources/tests/test_pkg_resources.py
+4
-2
pkg_resources/tests/test_resources.py
pkg_resources/tests/test_resources.py
+29
-12
pkg_resources/tests/test_working_set.py
pkg_resources/tests/test_working_set.py
+7
-3
No files found.
pkg_resources/__init__.py
View file @
e065e901
...
@@ -1307,7 +1307,7 @@ class ResourceManager:
...
@@ -1307,7 +1307,7 @@ class ResourceManager:
target_path = os.path.join(extract_path, archive_name + '-tmp', *names)
target_path = os.path.join(extract_path, archive_name + '-tmp', *names)
try:
try:
_bypass_ensure_directory(target_path)
_bypass_ensure_directory(target_path)
except:
except
Exception
:
self.extraction_error()
self.extraction_error()
self._warn_unsafe_extraction_path(extract_path)
self._warn_unsafe_extraction_path(extract_path)
...
...
pkg_resources/tests/test_find_distributions.py
View file @
e065e901
...
@@ -13,6 +13,7 @@ setuptools.setup(
...
@@ -13,6 +13,7 @@ setuptools.setup(
)
)
"""
.
lstrip
()
"""
.
lstrip
()
class
TestFindDistributions
:
class
TestFindDistributions
:
@
pytest
.
fixture
@
pytest
.
fixture
...
...
pkg_resources/tests/test_pkg_resources.py
View file @
e065e901
...
@@ -154,8 +154,10 @@ class TestIndependence:
...
@@ -154,8 +154,10 @@ class TestIndependence:
lines
=
(
lines
=
(
'import pkg_resources'
,
'import pkg_resources'
,
'import sys'
,
'import sys'
,
'assert "setuptools" not in sys.modules, '
(
'"setuptools was imported"'
,
'assert "setuptools" not in sys.modules, '
'"setuptools was imported"'
),
)
)
cmd
=
[
sys
.
executable
,
'-c'
,
'; '
.
join
(
lines
)]
cmd
=
[
sys
.
executable
,
'-c'
,
'; '
.
join
(
lines
)]
subprocess
.
check_call
(
cmd
)
subprocess
.
check_call
(
cmd
)
...
...
pkg_resources/tests/test_resources.py
View file @
e065e901
...
@@ -11,7 +11,8 @@ import pytest
...
@@ -11,7 +11,8 @@ import pytest
from
pkg_resources.extern
import
packaging
from
pkg_resources.extern
import
packaging
import
pkg_resources
import
pkg_resources
from
pkg_resources
import
(
parse_requirements
,
VersionConflict
,
parse_version
,
from
pkg_resources
import
(
parse_requirements
,
VersionConflict
,
parse_version
,
Distribution
,
EntryPoint
,
Requirement
,
safe_version
,
safe_name
,
Distribution
,
EntryPoint
,
Requirement
,
safe_version
,
safe_name
,
WorkingSet
)
WorkingSet
)
...
@@ -51,7 +52,8 @@ class TestDistro:
...
@@ -51,7 +52,8 @@ class TestDistro:
assert
list
(
ad
)
==
[
'foopkg'
]
assert
list
(
ad
)
==
[
'foopkg'
]
# Distributions sort by version
# Distributions sort by version
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
[
'1.4'
,
'1.3-1'
,
'1.2'
]
expected
=
[
'1.4'
,
'1.3-1'
,
'1.2'
]
assert
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]]
==
expected
# Removing a distribution leaves sequence alone
# Removing a distribution leaves sequence alone
ad
.
remove
(
ad
[
'FooPkg'
][
1
])
ad
.
remove
(
ad
[
'FooPkg'
][
1
])
...
@@ -97,7 +99,10 @@ class TestDistro:
...
@@ -97,7 +99,10 @@ class TestDistro:
def
testDistroBasics
(
self
):
def
testDistroBasics
(
self
):
d
=
Distribution
(
d
=
Distribution
(
"/some/path"
,
"/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
)
self
.
checkFooPkg
(
d
)
...
@@ -113,10 +118,11 @@ class TestDistro:
...
@@ -113,10 +118,11 @@ class TestDistro:
def
testDistroMetadata
(
self
):
def
testDistroMetadata
(
self
):
d
=
Distribution
(
d
=
Distribution
(
"/some/path"
,
project_name
=
"FooPkg"
,
py_version
=
"2.4"
,
platform
=
"win32"
,
"/some/path"
,
project_name
=
"FooPkg"
,
py_version
=
"2.4"
,
platform
=
"win32"
,
metadata
=
Metadata
(
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
)
self
.
checkFooPkg
(
d
)
...
@@ -164,7 +170,10 @@ class TestDistro:
...
@@ -164,7 +170,10 @@ class TestDistro:
ad
.
add
(
Baz
)
ad
.
add
(
Baz
)
# Activation list now includes resolved dependency
# 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
# Requests for conflicting versions produce VersionConflict
with
pytest
.
raises
(
VersionConflict
)
as
vc
:
with
pytest
.
raises
(
VersionConflict
)
as
vc
:
ws
.
resolve
(
parse_requirements
(
"Foo==1.2
\
n
Foo!=1.2"
),
ad
)
ws
.
resolve
(
parse_requirements
(
"Foo==1.2
\
n
Foo!=1.2"
),
ad
)
...
@@ -415,7 +424,8 @@ class TestEntryPoints:
...
@@ -415,7 +424,8 @@ class TestEntryPoints:
submap_expect
=
dict
(
submap_expect
=
dict
(
feature1
=
EntryPoint
(
'feature1'
,
'somemodule'
,
[
'somefunction'
]),
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'
])
feature3
=
EntryPoint
(
'feature3'
,
'this.module'
,
extras
=
[
'something'
])
)
)
submap_str
=
"""
submap_str
=
"""
...
@@ -518,11 +528,17 @@ class TestRequirements:
...
@@ -518,11 +528,17 @@ class TestRequirements:
Requirement
.
parse
(
'setuptools'
).
project_name
==
'setuptools'
)
Requirement
.
parse
(
'setuptools'
).
project_name
==
'setuptools'
)
# setuptools 0.7 and higher means setuptools.
# setuptools 0.7 and higher means setuptools.
assert
(
assert
(
Requirement
.
parse
(
'setuptools == 0.7'
).
project_name
==
'setuptools'
)
Requirement
.
parse
(
'setuptools == 0.7'
).
project_name
==
'setuptools'
)
assert
(
assert
(
Requirement
.
parse
(
'setuptools == 0.7a1'
).
project_name
==
'setuptools'
)
Requirement
.
parse
(
'setuptools == 0.7a1'
).
project_name
==
'setuptools'
)
assert
(
assert
(
Requirement
.
parse
(
'setuptools >= 0.7'
).
project_name
==
'setuptools'
)
Requirement
.
parse
(
'setuptools >= 0.7'
).
project_name
==
'setuptools'
)
class
TestParsing
:
class
TestParsing
:
...
@@ -552,7 +568,7 @@ class TestParsing:
...
@@ -552,7 +568,7 @@ class TestParsing:
"""
"""
assert
(
assert
(
list
(
pkg_resources
.
split_sections
(
sample
))
list
(
pkg_resources
.
split_sections
(
sample
))
==
==
[
[
(
None
,
[
"x"
]),
(
None
,
[
"x"
]),
(
"Y"
,
[
"z"
,
"a"
]),
(
"Y"
,
[
"z"
,
"a"
]),
...
@@ -838,7 +854,8 @@ class TestNamespaces:
...
@@ -838,7 +854,8 @@ class TestNamespaces:
subpkg
=
nspkg
/
'subpkg'
subpkg
=
nspkg
/
'subpkg'
subpkg
.
ensure_dir
()
subpkg
.
ensure_dir
()
(
nspkg
/
'__init__.py'
).
write_text
(
self
.
ns_str
,
encoding
=
'utf-8'
)
(
nspkg
/
'__init__.py'
).
write_text
(
self
.
ns_str
,
encoding
=
'utf-8'
)
(
subpkg
/
'__init__.py'
).
write_text
(
vers_str
%
number
,
encoding
=
'utf-8'
)
(
subpkg
/
'__init__.py'
).
write_text
(
vers_str
%
number
,
encoding
=
'utf-8'
)
import
nspkg.subpkg
import
nspkg.subpkg
import
nspkg
import
nspkg
...
...
pkg_resources/tests/test_working_set.py
View file @
e065e901
import
inspect
import
inspect
import
re
import
re
import
textwrap
import
textwrap
import
functools
import
pytest
import
pytest
...
@@ -15,6 +16,7 @@ def strip_comments(s):
...
@@ -15,6 +16,7 @@ def strip_comments(s):
if
l
.
strip
()
and
not
l
.
strip
().
startswith
(
'#'
)
if
l
.
strip
()
and
not
l
.
strip
().
startswith
(
'#'
)
)
)
def
parse_distributions
(
s
):
def
parse_distributions
(
s
):
'''
'''
Parse a series of distribution specs of the form:
Parse a series of distribution specs of the form:
...
@@ -31,7 +33,8 @@ def parse_distributions(s):
...
@@ -31,7 +33,8 @@ def parse_distributions(s):
yield 2 distributions:
yield 2 distributions:
- project_name=foo, version=0.2
- project_name=foo, version=0.2
- project_name=bar, version=1.0, requires=['foo>=3.0', 'baz; extra=="feature"']
- project_name=bar, version=1.0,
requires=['foo>=3.0', 'baz; extra=="feature"']
'''
'''
s
=
s
.
strip
()
s
=
s
.
strip
()
for
spec
in
re
.
split
(
'
\
n
(?=[^
\
s])
'
, s):
for
spec
in
re
.
split
(
'
\
n
(?=[^
\
s])
'
, s):
...
@@ -42,7 +45,7 @@ def parse_distributions(s):
...
@@ -42,7 +45,7 @@ def parse_distributions(s):
name, version = fields.pop(0).split('
-
')
name, version = fields.pop(0).split('
-
')
if fields:
if fields:
requires = textwrap.dedent(fields.pop(0))
requires = textwrap.dedent(fields.pop(0))
metadata
=
Metadata(('
requires
.
txt
', requires))
metadata
=
Metadata(('
requires
.
txt
', requires))
else:
else:
metadata = None
metadata = None
dist = pkg_resources.Distribution(project_name=name,
dist = pkg_resources.Distribution(project_name=name,
...
@@ -467,7 +470,8 @@ def test_working_set_resolve(installed_dists, installable_dists, requirements,
...
@@ -467,7 +470,8 @@ def test_working_set_resolve(installed_dists, installable_dists, requirements,
replace_conflicting, resolved_dists_or_exception):
replace_conflicting, resolved_dists_or_exception):
ws = pkg_resources.WorkingSet([])
ws = pkg_resources.WorkingSet([])
list(map(ws.add, installed_dists))
list(map(ws.add, installed_dists))
resolve_call = lambda: ws.resolve(
resolve_call = functools.partial(
ws.resolve,
requirements, installer=FakeInstaller(installable_dists),
requirements, installer=FakeInstaller(installable_dists),
replace_conflicting=replace_conflicting,
replace_conflicting=replace_conflicting,
)
)
...
...
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