diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index d8ba386e6b..73e18982fa 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -111,7 +111,6 @@ def upgrade_pip_dependencies(verbose): "pip", "install", "--upgrade", - "pip", *get_pip_dependencies(), ], check=True, diff --git a/platformio/dependencies.py b/platformio/dependencies.py index 51e1725d2c..66e3cdb1c4 100644 --- a/platformio/dependencies.py +++ b/platformio/dependencies.py @@ -28,6 +28,7 @@ def get_core_dependencies(): def get_pip_dependencies(): core = [ + "pip", "bottle == 0.13.*", "click >=8.0.4, <8.5, !=8.3", # click 9.0 removes 'protected_args' attribute "colorama", diff --git a/tests/misc/test_dependencies.py b/tests/misc/test_dependencies.py new file mode 100644 index 0000000000..4854b4d0ce --- /dev/null +++ b/tests/misc/test_dependencies.py @@ -0,0 +1,40 @@ +# Copyright (c) 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from platformio.commands import upgrade as cmd_upgrade +from platformio.dependencies import get_pip_dependencies + + +def test_pip_is_declared_dependency(): + assert get_pip_dependencies().count("pip") == 1 + + +def test_upgrade_pip_dependencies_upgrades_declared_pip_once(monkeypatch): + calls = [] + + monkeypatch.setattr(cmd_upgrade, "get_pythonexe_path", lambda: "python") + monkeypatch.setattr( + cmd_upgrade.subprocess, + "run", + lambda args, **kwargs: calls.append((args, kwargs)), + ) + + cmd_upgrade.upgrade_pip_dependencies(verbose=False) + + args, kwargs = calls[0] + assert args[:5] == ["python", "-m", "pip", "install", "--upgrade"] + assert args[5:] == get_pip_dependencies() + assert args[5:].count("pip") == 1 + assert kwargs["check"] is True + assert kwargs["stdout"] == cmd_upgrade.subprocess.PIPE