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
880774ac
Commit
880774ac
authored
Jul 23, 2017
by
Benoit Pierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "fix `install_requires` handling of extras"
This reverts commit
a3ec721e
.
parent
f26bf186
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
13 deletions
+40
-13
setuptools/dist.py
setuptools/dist.py
+4
-7
setuptools/tests/test_egg_info.py
setuptools/tests/test_egg_info.py
+36
-6
No files found.
setuptools/dist.py
View file @
880774ac
...
...
@@ -376,7 +376,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
def _move_install_requirements_markers(self):
"""
Move requirements in `install_requires` that are using environment
markers
or extras to
`extras_require`.
markers `extras_require`.
"""
# divide the install_requires into two sets, simple ones still
...
...
@@ -384,7 +384,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
# by extras_require.
def is_simple_req(req):
return not req.marker
and not req.extras
return not req.marker
spec_inst_reqs = getattr(self, '
install_requires
', None) or ()
simple_reqs = filter(
...
...
@@ -398,9 +398,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
self.install_requires = list(map(str, simple_reqs))
for r in complex_reqs:
suffix = '
:
' + str(r.marker) if r.marker else ''
for section in r.extras or ('',):
self._tmp_extras_require[section + suffix].append(r)
self._tmp_extras_require['
:
' + str(r.marker)].append(r)
self.extras_require = dict(
(k, [str(r) for r in map(self._clean_req, v)])
for k, v in self._tmp_extras_require.items()
...
...
@@ -408,9 +406,8 @@ class Distribution(Distribution_parse_config_files, _Distribution):
def _clean_req(self, req):
"""
Given a Requirement, remove e
xtras and
markers and return it.
Given a Requirement, remove e
nvironment
markers and return it.
"""
req.extras = ()
req.marker = None
return req
...
...
setuptools/tests/test_egg_info.py
View file @
880774ac
...
...
@@ -207,14 +207,13 @@ class TestEggInfo(object):
def
test_install_requires_with_extra
(
self
,
tmpdir_cwd
,
env
):
req
=
'install_requires=["barbazquux [test]"],'
self
.
_setup_script_with_requires
(
req
)
self
.
_run_install_command
(
tmpdir_cwd
,
env
)
egg_info_dir
=
self
.
_find_egg_info_files
(
env
.
paths
[
'lib'
]).
base
self
.
_run_install_command
(
tmpdir_cwd
,
env
,
cmd
=
[
'egg_info'
]
)
egg_info_dir
=
os
.
path
.
join
(
'.'
,
'foo.egg-info'
)
requires_txt
=
os
.
path
.
join
(
egg_info_dir
,
'requires.txt'
)
with
open
(
requires_txt
)
as
fp
:
install_requires
=
fp
.
read
()
expected_requires
=
DALS
(
'''
[test]
barbazquux
barbazquux[test]
'''
)
assert
install_requires
.
lstrip
()
==
expected_requires
assert
glob
.
glob
(
os
.
path
.
join
(
env
.
paths
[
'lib'
],
'barbazquux*'
))
==
[]
...
...
@@ -229,8 +228,8 @@ class TestEggInfo(object):
with
open
(
requires_txt
)
as
fp
:
install_requires
=
fp
.
read
()
expected_requires
=
DALS
(
'''
[
test
:{marker}]
barbazquux
[:{marker}]
barbazquux
[test]
'''
).
format
(
marker
=
self
.
mismatch_marker_alternate
)
assert
install_requires
.
lstrip
()
==
expected_requires
assert
glob
.
glob
(
os
.
path
.
join
(
env
.
paths
[
'lib'
],
'barbazquux*'
))
==
[]
...
...
@@ -250,6 +249,37 @@ class TestEggInfo(object):
tmpdir_cwd
,
env
,
cmd
=
[
'test'
],
output
=
"Ran 0 tests in"
)
assert
glob
.
glob
(
os
.
path
.
join
(
env
.
paths
[
'lib'
],
'barbazquux*'
))
==
[]
def
test_extras_require_with_extra
(
self
,
tmpdir_cwd
,
env
):
req
=
'extras_require={"extra": ["barbazquux [test]"]},'
self
.
_setup_script_with_requires
(
req
)
self
.
_run_install_command
(
tmpdir_cwd
,
env
,
cmd
=
[
'egg_info'
])
egg_info_dir
=
os
.
path
.
join
(
'.'
,
'foo.egg-info'
)
requires_txt
=
os
.
path
.
join
(
egg_info_dir
,
'requires.txt'
)
with
open
(
requires_txt
)
as
fp
:
install_requires
=
fp
.
read
()
expected_requires
=
DALS
(
'''
[extra]
barbazquux[test]
'''
)
assert
install_requires
.
lstrip
()
==
expected_requires
assert
glob
.
glob
(
os
.
path
.
join
(
env
.
paths
[
'lib'
],
'barbazquux*'
))
==
[]
def
test_extras_require_with_extra_and_marker_in_req
(
self
,
tmpdir_cwd
,
env
):
tmpl
=
'extras_require={{"extra": ["barbazquux [test]; {marker}"]}},'
req
=
tmpl
.
format
(
marker
=
self
.
mismatch_marker
)
self
.
_setup_script_with_requires
(
req
)
self
.
_run_install_command
(
tmpdir_cwd
,
env
)
egg_info_dir
=
self
.
_find_egg_info_files
(
env
.
paths
[
'lib'
]).
base
requires_txt
=
os
.
path
.
join
(
egg_info_dir
,
'requires.txt'
)
with
open
(
requires_txt
)
as
fp
:
install_requires
=
fp
.
read
()
expected_requires
=
DALS
(
'''
[extra:{marker}]
barbazquux[test]
'''
).
format
(
marker
=
self
.
mismatch_marker_alternate
)
assert
install_requires
.
lstrip
()
==
expected_requires
assert
glob
.
glob
(
os
.
path
.
join
(
env
.
paths
[
'lib'
],
'barbazquux*'
))
==
[]
def
test_extras_require_with_marker
(
self
,
tmpdir_cwd
,
env
):
tmpl
=
'extras_require={{":{marker}": ["barbazquux"]}},'
req
=
tmpl
.
format
(
marker
=
self
.
mismatch_marker
)
...
...
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