Skip to content

Commit 771df4e

Browse files
author
Patrik Kopkan
committed
added test
fixed flake errors renamed variables/attributes
1 parent 781c935 commit 771df4e

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

src/pip/_internal/commands/wheel.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, with_statement
2+
from __future__ import absolute_import
33

44
import logging
55
import os
@@ -105,7 +105,6 @@ def __init__(self, *args, **kw):
105105
help="stores the filenames of wheels in file of given path"
106106
)
107107

108-
109108
index_opts = cmdoptions.make_option_group(
110109
cmdoptions.index_group,
111110
self.parser,
@@ -178,7 +177,7 @@ def run(self, options, args):
178177
build_options=options.build_options or [],
179178
global_options=options.global_options or [],
180179
no_clean=options.no_clean,
181-
path_to_save_wheelnames = options.path_to_wheelnames
180+
path_to_wheelnames=options.path_to_wheelnames
182181
)
183182
build_failures = wb.build(
184183
requirement_set.requirements.values(), session=session,
@@ -187,15 +186,14 @@ def run(self, options, args):
187186
raise CommandError(
188187
"Failed to build one or more wheels"
189188
)
190-
if len(wb.wheel_filenames) !=0:
191-
try:
192-
with open(options.path_to_wheelnames, 'w') as file:
193-
output = ''
194-
for wheel_filename in wb.wheel_filenames:
195-
output = wheel_filename + os.linesep
196-
file.write(output)
197-
except EnvironmentError as e:
198-
logger.error(str(e))
189+
if wb.path_to_wheelnames is not None:
190+
if len(wb.wheel_filenames) != 0:
191+
with open(wb.path_to_wheelnames, 'w') as file:
192+
file.write(
193+
os.linesep.join(
194+
wb.wheel_filenames
195+
) + os.linesep
196+
)
199197

200198
except PreviousBuildDirError:
201199
options.no_clean = True

src/pip/_internal/wheel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ def __init__(
851851
wheel_cache, # type: WheelCache
852852
build_options=None, # type: Optional[List[str]]
853853
global_options=None, # type: Optional[List[str]]
854-
no_clean=False, # type: bool
855-
path_to_save_wheelnames=None # type: str
854+
no_clean=False, # type: bool
855+
path_to_wheelnames=None # Optional[str]
856856
):
857857
# type: (...) -> None
858858
self.finder = finder
@@ -864,7 +864,7 @@ def __init__(
864864
self.build_options = build_options or []
865865
self.global_options = global_options or []
866866
self.no_clean = no_clean
867-
self.path_to_save_wheelnames = path_to_save_wheelnames
867+
self.path_to_wheelnames = path_to_wheelnames
868868
self.wheel_filenames = []
869869

870870
def _build_one(self, req, output_dir, python_tag=None):

tests/functional/test_wheel.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,22 @@ def test_legacy_wheels_are_not_confused_with_other_files(script, tmpdir, data):
246246
wheel_file_name = 'simplewheel-1.0-py%s-none-any.whl' % pyversion[0]
247247
wheel_file_path = script.scratch / wheel_file_name
248248
assert wheel_file_path in result.files_created, result.stdout
249+
250+
251+
def test_pip_option_save_wheel_name(script, data):
252+
"""
253+
Test 'pip wheel ' success.
254+
"""
255+
script.pip(
256+
'wheel', '--no-index', '-f', data.find_links,
257+
'require_simple==1.0',
258+
'--save-wheel-name', './wheelnames',
259+
)
260+
261+
wheel_file_names = ['require_simple-1.0-py%s-none-any.whl' % pyversion[0],
262+
'simple-3.0-py%s-none-any.whl' % pyversion[0],
263+
]
264+
wheelnames_path = script.scratch_path / 'wheelnames'
265+
wheelnames_file = open(wheelnames_path, 'r')
266+
wheelnames_entries = (wheelnames_file.read()).splitlines()
267+
assert wheel_file_names == wheelnames_entries

0 commit comments

Comments
 (0)