Skip to content

Commit

Permalink
Rationalise wheel_dir usage.
Browse files Browse the repository at this point in the history
We we normalising it right before making it, after passing it
RequirementSet, which means RequirementSet also had to normalise it.

And then we passed it to WheelBuilder which as a result had to
normalise it too.

Instead, pass it as-is to RequirementSet, have that normalise it, and
then pull it back out in WheelBuilder.
  • Loading branch information
rbtcollins committed Mar 27, 2015
1 parent 19d88b0 commit ab7ae1a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 0 additions & 6 deletions pip/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ def run(self, options, args):
wheel_download_dir=options.wheel_dir
)

# make the wheelhouse
options.wheel_dir = normalize_path(options.wheel_dir)
if not os.path.exists(options.wheel_dir):
os.makedirs(options.wheel_dir)

try:
populate_requirement_set(
requirement_set, args, options, logger, finder,
Expand All @@ -203,7 +198,6 @@ def run(self, options, args):
wb = WheelBuilder(
requirement_set,
finder,
options.wheel_dir,
build_options=options.build_options or [],
global_options=options.global_options or [],
)
Expand Down
5 changes: 5 additions & 0 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ def prepare_files(self, finder):
"""
Prepare process. Create temp directories, download and/or unpack files.
"""
# make the wheelhouse
if self.wheel_download_dir:
if not os.path.exists(self.wheel_download_dir):
os.makedirs(self.wheel_download_dir)

self._walk_req_to_install(
functools.partial(self._prepare_file, finder))

Expand Down
4 changes: 2 additions & 2 deletions pip/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,11 @@ def supported(self, tags=None):
class WheelBuilder(object):
"""Build wheels from a RequirementSet."""

def __init__(self, requirement_set, finder, wheel_dir, build_options=None,
def __init__(self, requirement_set, finder, build_options=None,
global_options=None):
self.requirement_set = requirement_set
self.finder = finder
self.wheel_dir = normalize_path(wheel_dir)
self.wheel_dir = requirement_set.wheel_download_dir
self.build_options = build_options or []
self.global_options = global_options or []

Expand Down
10 changes: 6 additions & 4 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,19 @@ class TestWheelBuilder(object):
def test_skip_building_wheels(self, caplog):
with patch('pip.wheel.WheelBuilder._build_one') as mock_build_one:
wheel_req = Mock(is_wheel=True, editable=False)
reqset = Mock(requirements=Mock(values=lambda: [wheel_req]))
wb = wheel.WheelBuilder(reqset, Mock(), '/wheel/dir')
reqset = Mock(requirements=Mock(values=lambda: [wheel_req]),
wheel_download_dir='/wheel/dir')
wb = wheel.WheelBuilder(reqset, Mock())
wb.build()
assert "due to already being wheel" in caplog.text()
assert mock_build_one.mock_calls == []

def test_skip_building_editables(self, caplog):
with patch('pip.wheel.WheelBuilder._build_one') as mock_build_one:
editable_req = Mock(editable=True, is_wheel=False)
reqset = Mock(requirements=Mock(values=lambda: [editable_req]))
wb = wheel.WheelBuilder(reqset, Mock(), '/wheel/dir')
reqset = Mock(requirements=Mock(values=lambda: [editable_req]),
wheel_download_dir='/wheel/dir')
wb = wheel.WheelBuilder(reqset, Mock())
wb.build()
assert "due to being editable" in caplog.text()
assert mock_build_one.mock_calls == []

0 comments on commit ab7ae1a

Please sign in to comment.