From 4d1b7984653c4365c101c86b1436703332d79f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Thu, 26 May 2016 12:41:01 +0200 Subject: [PATCH] Allow creating wheels for editable packages (#3695) --- CHANGES.txt | 4 ++++ pip/commands/wheel.py | 2 ++ pip/wheel.py | 7 ++----- tests/functional/test_wheel.py | 15 +++++++++++++++ tests/unit/test_wheel.py | 10 ---------- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 508bdacf5..7190a9ca5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,10 @@ * Fix regression in pip freeze: when there is more than one git remote, priority is given to the remote named origin (:issue:`3616`) +* Pip wheel now works on editable packages too (it was only working on + editable dependencies before); this allows running pip wheel on the result + of pip freeze in presence of editable requirements (:issue:`3291`) + **8.1.2 (2016-05-10)** diff --git a/pip/commands/wheel.py b/pip/commands/wheel.py index 2796ec4be..53f85e31b 100644 --- a/pip/commands/wheel.py +++ b/pip/commands/wheel.py @@ -157,6 +157,8 @@ class WheelCommand(RequirementCommand): if options.build_dir: options.build_dir = os.path.abspath(options.build_dir) + options.src_dir = os.path.abspath(options.src_dir) + with self._build_session(options) as session: finder = self._build_package_finder(options, session) build_delete = (not (options.no_clean or options.build_dir)) diff --git a/pip/wheel.py b/pip/wheel.py index b257d7665..01fbc9c1d 100644 --- a/pip/wheel.py +++ b/pip/wheel.py @@ -759,11 +759,8 @@ class WheelBuilder(object): if not autobuilding: logger.info( 'Skipping %s, due to already being wheel.', req.name) - elif req.editable: - if not autobuilding: - logger.info( - 'Skipping bdist_wheel for %s, due to being editable', - req.name) + elif autobuilding and req.editable: + pass elif autobuilding and req.link and not req.link.is_artifact: pass elif autobuilding and not req.source_dir: diff --git a/tests/functional/test_wheel.py b/tests/functional/test_wheel.py index b90604238..ac08d4280 100644 --- a/tests/functional/test_wheel.py +++ b/tests/functional/test_wheel.py @@ -74,6 +74,21 @@ def test_pip_wheel_builds_editable_deps(script, data): assert wheel_file_path in result.files_created, result.stdout +@pytest.mark.network +def test_pip_wheel_builds_editable(script, data): + """ + Test 'pip wheel' builds an editable package + """ + script.pip('install', 'wheel') + editable_path = os.path.join(data.src, 'simplewheel-1.0') + result = script.pip( + 'wheel', '--no-index', '-e', editable_path + ) + wheel_file_name = 'simplewheel-1.0-py%s-none-any.whl' % pyversion[0] + wheel_file_path = script.scratch / wheel_file_name + assert wheel_file_path in result.files_created, result.stdout + + @pytest.mark.network def test_pip_wheel_fail(script, data): """ diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index b6dc1f607..0e030e5bb 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -380,16 +380,6 @@ class TestWheelBuilder(object): 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 = Mock(editable=True, is_wheel=False, constraint=False) - reqset = Mock(requirements=Mock(values=lambda: [editable]), - 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 == [] - class TestWheelCache: