From 57efa02c1e33081ff68d69a967f69061bdb809ec Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Thu, 2 Oct 2025 14:33:45 +0200 Subject: [PATCH 01/15] pyinstaller support added to PipEnv --- conan/tools/system/pip_manager.py | 39 +++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 214f613fad7..47cedefa1aa 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -1,9 +1,11 @@ -import venv import platform import os +import shutil +import sys from conan.tools.build import cmd_args_to_string from conan.tools.env.environment import Environment +from conan.errors import ConanException class PipEnv: @@ -23,6 +25,39 @@ def generate(self): env.prepend_path("PATH", self.bin_dir) env.vars(self._conanfile).save_script(self.env_name) + def _create_venv(self): + print("=" * 20) + python_executable = None + if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + if platform.system() == "Windows": + candidate_names = ['python.exe', 'pythonw.exe'] + else: + candidate_names = ['python', 'python3'] + + for name in candidate_names: + expected_path = os.path.join(sys._MEIPASS, name) + print(expected_path) + if os.path.exists(expected_path): + python_executable = expected_path + break + if not python_executable: + if platform.system() == "Windows": + system_py = shutil.which('python') + else: + system_py = shutil.which('python3') or shutil.which('python') + if system_py: + python_executable = system_py + else: + python_executable = sys.executable + print("=" * 20) + print(python_executable) + print(getattr(sys, 'frozen', False)) + print(getattr(sys, '_MEIPASS', False)) + print("=" * 20) + if not python_executable: + raise ConanException("PipEnv could not find a Python executable path.") + self._conanfile.run(cmd_args_to_string([python_executable, '-m', 'venv', self._env_dir])) + def install(self, packages, pip_args=None): """ Will try to install the list of pip packages passed as a parameter. @@ -34,7 +69,7 @@ def install(self, packages, pip_args=None): :return: the return code of the executed pip command. """ - venv.EnvBuilder(clear=True, with_pip=True).create(self._env_dir) + self._create_venv() args = [self._python_exe, "-m", "pip", "install", "--disable-pip-version-check"] if pip_args: args += list(pip_args) From ee7e38a07be878d6943624b8c62f29cbedd377b4 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Sat, 4 Oct 2025 10:31:15 +0200 Subject: [PATCH 02/15] wip --- conan/tools/system/pip_manager.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 47cedefa1aa..c69bb39bc5b 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -26,9 +26,10 @@ def generate(self): env.vars(self._conanfile).save_script(self.env_name) def _create_venv(self): - print("=" * 20) python_executable = None - if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + + # https://pyinstaller.org/en/stable/runtime-information.html#run-time-information + if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): # Conan is bundled if platform.system() == "Windows": candidate_names = ['python.exe', 'pythonw.exe'] else: @@ -40,22 +41,14 @@ def _create_venv(self): if os.path.exists(expected_path): python_executable = expected_path break - if not python_executable: - if platform.system() == "Windows": - system_py = shutil.which('python') - else: - system_py = shutil.which('python3') or shutil.which('python') - if system_py: - python_executable = system_py - else: + else: # Conan is running from source python_executable = sys.executable - print("=" * 20) - print(python_executable) - print(getattr(sys, 'frozen', False)) - print(getattr(sys, '_MEIPASS', False)) - print("=" * 20) + if not python_executable: - raise ConanException("PipEnv could not find a Python executable path.") + python_executable = shutil.which('python3') or shutil.which('python') + if not python_executable: + raise ConanException("PipEnv could not find a Python executable path.") + self._conanfile.run(cmd_args_to_string([python_executable, '-m', 'venv', self._env_dir])) def install(self, packages, pip_args=None): From ce2fe4ee9e83f8ab7c5ce4e823bc9edb12f6a8c1 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Sat, 4 Oct 2025 10:34:20 +0200 Subject: [PATCH 03/15] wip --- conan/tools/system/pip_manager.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index c69bb39bc5b..1be347e19a4 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -34,10 +34,8 @@ def _create_venv(self): candidate_names = ['python.exe', 'pythonw.exe'] else: candidate_names = ['python', 'python3'] - for name in candidate_names: expected_path = os.path.join(sys._MEIPASS, name) - print(expected_path) if os.path.exists(expected_path): python_executable = expected_path break From 4f03d6e9eaf7eed85ef5d89eea95c1a12cb4dc57 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Sat, 4 Oct 2025 10:43:51 +0200 Subject: [PATCH 04/15] wip --- conan/tools/system/pip_manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 1be347e19a4..da2a5bb90c2 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -43,7 +43,10 @@ def _create_venv(self): python_executable = sys.executable if not python_executable: - python_executable = shutil.which('python3') or shutil.which('python') + if platform.system() == "Windows": + python_executable = shutil.which('python') + else: + python_executable = shutil.which('python3') if not python_executable: raise ConanException("PipEnv could not find a Python executable path.") From 79b22353dcdc2a160fd5150d63dee831a75f57e8 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Sat, 4 Oct 2025 10:50:02 +0200 Subject: [PATCH 05/15] wip --- conan/tools/system/pip_manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index da2a5bb90c2..3a2a227d017 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -49,8 +49,10 @@ def _create_venv(self): python_executable = shutil.which('python3') if not python_executable: raise ConanException("PipEnv could not find a Python executable path.") - - self._conanfile.run(cmd_args_to_string([python_executable, '-m', 'venv', self._env_dir])) + try: + self._conanfile.run(cmd_args_to_string([python_executable, '-m', 'venv', self._env_dir])) + except ConanException: + raise ConanException("PipEnv could not create a Python virtual environment.") def install(self, packages, pip_args=None): """ From 354b6473975344684a3226ce753f5513748d6659 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Mon, 6 Oct 2025 16:55:46 +0200 Subject: [PATCH 06/15] wip --- conan/tools/system/pip_manager.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 3a2a227d017..6389de263ed 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -26,29 +26,12 @@ def generate(self): env.vars(self._conanfile).save_script(self.env_name) def _create_venv(self): - python_executable = None - - # https://pyinstaller.org/en/stable/runtime-information.html#run-time-information - if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): # Conan is bundled - if platform.system() == "Windows": - candidate_names = ['python.exe', 'pythonw.exe'] - else: - candidate_names = ['python', 'python3'] - for name in candidate_names: - expected_path = os.path.join(sys._MEIPASS, name) - if os.path.exists(expected_path): - python_executable = expected_path - break - else: # Conan is running from source - python_executable = sys.executable - + if platform.system() == "Windows": + python_executable = shutil.which('python') + else: + python_executable = shutil.which('python3') if not python_executable: - if platform.system() == "Windows": - python_executable = shutil.which('python') - else: - python_executable = shutil.which('python3') - if not python_executable: - raise ConanException("PipEnv could not find a Python executable path.") + raise ConanException("PipEnv could not find a Python executable path.") try: self._conanfile.run(cmd_args_to_string([python_executable, '-m', 'venv', self._env_dir])) except ConanException: From 42ff5cb242d1954c0a67d28c4b3e5b4dd3c5054d Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 8 Oct 2025 09:23:42 +0200 Subject: [PATCH 07/15] wip --- conan/internal/model/conf.py | 1 + conan/tools/system/pip_manager.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conan/internal/model/conf.py b/conan/internal/model/conf.py index 98c58bb5e35..cecb8fcffed 100644 --- a/conan/internal/model/conf.py +++ b/conan/internal/model/conf.py @@ -129,6 +129,7 @@ "tools.system.package_manager:mode": "Mode for package_manager tools: 'check', 'report', 'report-installed' or 'install'", "tools.system.package_manager:sudo": "Use 'sudo' when invoking the package manager tools in Linux (False by default)", "tools.system.package_manager:sudo_askpass": "Use the '-A' argument if using sudo in Linux to invoke the system package manager (False by default)", + "tools.system.pip_manager:python_interpreter": "Path to the Python interpreter to be used to create the virtualenv", "tools.apple:sdk_path": "Path to the SDK to be used", "tools.apple:enable_bitcode": "(boolean) Enable/Disable Bitcode Apple Clang flags", "tools.apple:enable_arc": "(boolean) Enable/Disable ARC Apple Clang flags", diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 6389de263ed..2e12af0952c 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -26,14 +26,14 @@ def generate(self): env.vars(self._conanfile).save_script(self.env_name) def _create_venv(self): - if platform.system() == "Windows": - python_executable = shutil.which('python') - else: - python_executable = shutil.which('python3') - if not python_executable: + python_interpreter = self._conanfile.conf.get( + "tools.system.pip_manager:python_interpreter", + default=shutil.which('python') if platform.system() == "Windows" else shutil.which('python3')) + if not python_interpreter: raise ConanException("PipEnv could not find a Python executable path.") + try: - self._conanfile.run(cmd_args_to_string([python_executable, '-m', 'venv', self._env_dir])) + self._conanfile.run(cmd_args_to_string([python_interpreter, '-m', 'venv', self._env_dir])) except ConanException: raise ConanException("PipEnv could not create a Python virtual environment.") From 42aa371d0a812625d974256d74fcd335c6c21715 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 22 Oct 2025 11:21:13 +0200 Subject: [PATCH 08/15] wip --- conan/internal/model/conf.py | 2 +- conan/tools/system/pip_manager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conan/internal/model/conf.py b/conan/internal/model/conf.py index cecb8fcffed..1d5f15279e7 100644 --- a/conan/internal/model/conf.py +++ b/conan/internal/model/conf.py @@ -129,7 +129,7 @@ "tools.system.package_manager:mode": "Mode for package_manager tools: 'check', 'report', 'report-installed' or 'install'", "tools.system.package_manager:sudo": "Use 'sudo' when invoking the package manager tools in Linux (False by default)", "tools.system.package_manager:sudo_askpass": "Use the '-A' argument if using sudo in Linux to invoke the system package manager (False by default)", - "tools.system.pip_manager:python_interpreter": "Path to the Python interpreter to be used to create the virtualenv", + "tools.system.pipenv:python_interpreter": "Path to the Python interpreter to be used to create the virtualenv", "tools.apple:sdk_path": "Path to the SDK to be used", "tools.apple:enable_bitcode": "(boolean) Enable/Disable Bitcode Apple Clang flags", "tools.apple:enable_arc": "(boolean) Enable/Disable ARC Apple Clang flags", diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 2e12af0952c..f17e6cd353c 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -27,7 +27,7 @@ def generate(self): def _create_venv(self): python_interpreter = self._conanfile.conf.get( - "tools.system.pip_manager:python_interpreter", + "tools.system.pipenv:python_interpreter", default=shutil.which('python') if platform.system() == "Windows" else shutil.which('python3')) if not python_interpreter: raise ConanException("PipEnv could not find a Python executable path.") From 5425e094b9ee8130321fcb74380e0679bc93c480 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Thu, 23 Oct 2025 09:00:35 +0200 Subject: [PATCH 09/15] wip --- conan/tools/system/pip_manager.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index f17e6cd353c..bf2698cc38e 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -1,7 +1,6 @@ import platform import os import shutil -import sys from conan.tools.build import cmd_args_to_string from conan.tools.env.environment import Environment @@ -26,9 +25,9 @@ def generate(self): env.vars(self._conanfile).save_script(self.env_name) def _create_venv(self): - python_interpreter = self._conanfile.conf.get( - "tools.system.pipenv:python_interpreter", - default=shutil.which('python') if platform.system() == "Windows" else shutil.which('python3')) + default_python = shutil.which('python') if platform.system() == "Windows" else shutil.which('python3') + python_interpreter = self._conanfile.conf.get("tools.system.pipenv:python_interpreter", + default=os.path.realpath(default_python) if default_python else None) if not python_interpreter: raise ConanException("PipEnv could not find a Python executable path.") From aa63728e1a1874a40c1a6200037a2098f231ad87 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 29 Oct 2025 09:47:27 +0100 Subject: [PATCH 10/15] new test added --- conan/tools/system/pip_manager.py | 5 ++- .../tools/system/pip_manager_test.py | 38 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/integration/tools/system/pip_manager_test.py diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index bf2698cc38e..00b003a73e5 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -29,7 +29,10 @@ def _create_venv(self): python_interpreter = self._conanfile.conf.get("tools.system.pipenv:python_interpreter", default=os.path.realpath(default_python) if default_python else None) if not python_interpreter: - raise ConanException("PipEnv could not find a Python executable path.") + raise ConanException("PipEnv could not find a Python executable path." + "Please set 'tools.system.pipenv:python_interpreter' to '' " + "in the [conf] section of the profile, or in the command line using " + "'-c tools.system.pipenv:python_interpreter='") try: self._conanfile.run(cmd_args_to_string([python_interpreter, '-m', 'venv', self._env_dir])) diff --git a/test/integration/tools/system/pip_manager_test.py b/test/integration/tools/system/pip_manager_test.py new file mode 100644 index 00000000000..122fcf0b798 --- /dev/null +++ b/test/integration/tools/system/pip_manager_test.py @@ -0,0 +1,38 @@ +from conan.tools.system import PipEnv +from unittest.mock import patch +import mock +import pytest +from unittest.mock import PropertyMock +from conan.errors import ConanException +from conan.internal.model.settings import Settings +from conan.test.utils.mocks import ConanFileMock + + +def test_pipenv_conf(): + # https://github.com/conan-io/conan/issues/11661 + conanfile = ConanFileMock() + conanfile.settings = Settings() + conanfile.conf.define("tools.system.pipenv:python_interpreter", "/python/interpreter/from/config") + result = "/python/interpreter/from/config -m venv" + pipenv = PipEnv(conanfile, "testenv") + + def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=False, quiet=False): + assert result in command + return 100 + conanfile.run = fake_run + pipenv._create_venv() + + +@patch('shutil.which') +def test_pipenv_error_message(mock_shutil_which): + # https://github.com/conan-io/conan/issues/11661 + conanfile = ConanFileMock() + conanfile.settings = Settings() + mock_shutil_which.return_value = None + with pytest.raises(ConanException) as exc_info: + pipenv = PipEnv(conanfile, "testenv") + pipenv._create_venv() + assert exc_info.value.args[0] == "PipEnv could not find a Python executable path." \ + "Please set 'tools.system.pipenv:python_interpreter' to '' " \ + "in the [conf] section of the profile, or in the command line using " \ + "'-c tools.system.pipenv:python_interpreter='" From 4a1d10ecaadc5ef03d5323a57e667a592b05c075 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 29 Oct 2025 11:46:19 +0100 Subject: [PATCH 11/15] _default_python method added --- conan/tools/system/pip_manager.py | 9 ++++++--- test/integration/tools/system/pip_manager_test.py | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 00b003a73e5..2b640a027cd 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -24,10 +24,13 @@ def generate(self): env.prepend_path("PATH", self.bin_dir) env.vars(self._conanfile).save_script(self.env_name) - def _create_venv(self): + @staticmethod + def _default_python(): default_python = shutil.which('python') if platform.system() == "Windows" else shutil.which('python3') - python_interpreter = self._conanfile.conf.get("tools.system.pipenv:python_interpreter", - default=os.path.realpath(default_python) if default_python else None) + return os.path.realpath(default_python) if default_python else None + + def _create_venv(self): + python_interpreter = self._conanfile.conf.get("tools.system.pipenv:python_interpreter") or self._default_python() if not python_interpreter: raise ConanException("PipEnv could not find a Python executable path." "Please set 'tools.system.pipenv:python_interpreter' to '' " diff --git a/test/integration/tools/system/pip_manager_test.py b/test/integration/tools/system/pip_manager_test.py index 122fcf0b798..e2d060b23e2 100644 --- a/test/integration/tools/system/pip_manager_test.py +++ b/test/integration/tools/system/pip_manager_test.py @@ -8,10 +8,12 @@ from conan.test.utils.mocks import ConanFileMock -def test_pipenv_conf(): +@patch('shutil.which') +def test_pipenv_conf(mock_shutil_which): # https://github.com/conan-io/conan/issues/11661 conanfile = ConanFileMock() conanfile.settings = Settings() + mock_shutil_which.side_effect = Exception() conanfile.conf.define("tools.system.pipenv:python_interpreter", "/python/interpreter/from/config") result = "/python/interpreter/from/config -m venv" pipenv = PipEnv(conanfile, "testenv") From 8df2e5c3c62f24ccb14e1f1960c95e3ea234ee42 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 29 Oct 2025 12:14:36 +0100 Subject: [PATCH 12/15] wip --- conan/tools/system/pip_manager.py | 11 ++++---- .../tools/system/pip_manager_test.py | 25 +++++++++++++------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/conan/tools/system/pip_manager.py b/conan/tools/system/pip_manager.py index 2b640a027cd..600ede2be82 100644 --- a/conan/tools/system/pip_manager.py +++ b/conan/tools/system/pip_manager.py @@ -32,15 +32,14 @@ def _default_python(): def _create_venv(self): python_interpreter = self._conanfile.conf.get("tools.system.pipenv:python_interpreter") or self._default_python() if not python_interpreter: - raise ConanException("PipEnv could not find a Python executable path." - "Please set 'tools.system.pipenv:python_interpreter' to '' " - "in the [conf] section of the profile, or in the command line using " - "'-c tools.system.pipenv:python_interpreter='") + raise ConanException("PipEnv could not find a Python executable path. " + "Please, install Python system-wide or set the 'tools.system.pipenv:python_interpreter' " + "conf to the full path of a Python executable") try: self._conanfile.run(cmd_args_to_string([python_interpreter, '-m', 'venv', self._env_dir])) - except ConanException: - raise ConanException("PipEnv could not create a Python virtual environment.") + except ConanException as e: + raise ConanException(f"PipEnv could not create a Python virtual environment using '{python_interpreter}': {e}") def install(self, packages, pip_args=None): """ diff --git a/test/integration/tools/system/pip_manager_test.py b/test/integration/tools/system/pip_manager_test.py index e2d060b23e2..6370575ff24 100644 --- a/test/integration/tools/system/pip_manager_test.py +++ b/test/integration/tools/system/pip_manager_test.py @@ -1,8 +1,6 @@ from conan.tools.system import PipEnv from unittest.mock import patch -import mock import pytest -from unittest.mock import PropertyMock from conan.errors import ConanException from conan.internal.model.settings import Settings from conan.test.utils.mocks import ConanFileMock @@ -10,7 +8,6 @@ @patch('shutil.which') def test_pipenv_conf(mock_shutil_which): - # https://github.com/conan-io/conan/issues/11661 conanfile = ConanFileMock() conanfile.settings = Settings() mock_shutil_which.side_effect = Exception() @@ -27,14 +24,26 @@ def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=Fa @patch('shutil.which') def test_pipenv_error_message(mock_shutil_which): - # https://github.com/conan-io/conan/issues/11661 conanfile = ConanFileMock() conanfile.settings = Settings() mock_shutil_which.return_value = None with pytest.raises(ConanException) as exc_info: pipenv = PipEnv(conanfile, "testenv") pipenv._create_venv() - assert exc_info.value.args[0] == "PipEnv could not find a Python executable path." \ - "Please set 'tools.system.pipenv:python_interpreter' to '' " \ - "in the [conf] section of the profile, or in the command line using " \ - "'-c tools.system.pipenv:python_interpreter='" + assert exc_info.value.args[0] == "PipEnv could not find a Python executable path. " \ + "Please, install Python system-wide or set the 'tools.system.pipenv:python_interpreter' " \ + "conf to the full path of a Python executable" + + +def test_pipenv_creation_error_message(): + conanfile = ConanFileMock() + conanfile.settings = Settings() + conanfile.conf.define("tools.system.pipenv:python_interpreter", "/python/interpreter/from/config") + pipenv = PipEnv(conanfile, "testenv") + + def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=False, quiet=False): + raise ConanException("fake error message") + conanfile.run = fake_run + with pytest.raises(ConanException) as exc_info: + pipenv._create_venv() + assert exc_info.value.args[0] == "PipEnv could not create a Python virtual environment using '/python/interpreter/from/config': fake error message" From 67fadfbbe0430cf655f790e60728050f60d6189d Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 29 Oct 2025 12:20:04 +0100 Subject: [PATCH 13/15] wip --- test/integration/tools/system/pip_manager_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/tools/system/pip_manager_test.py b/test/integration/tools/system/pip_manager_test.py index 6370575ff24..d98e864f2fd 100644 --- a/test/integration/tools/system/pip_manager_test.py +++ b/test/integration/tools/system/pip_manager_test.py @@ -10,7 +10,6 @@ def test_pipenv_conf(mock_shutil_which): conanfile = ConanFileMock() conanfile.settings = Settings() - mock_shutil_which.side_effect = Exception() conanfile.conf.define("tools.system.pipenv:python_interpreter", "/python/interpreter/from/config") result = "/python/interpreter/from/config -m venv" pipenv = PipEnv(conanfile, "testenv") @@ -20,6 +19,7 @@ def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=Fa return 100 conanfile.run = fake_run pipenv._create_venv() + mock_shutil_which.assert_not_called() @patch('shutil.which') From 31f3c5390515077d81a5e3af41d64304e0ac1550 Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 29 Oct 2025 12:22:18 +0100 Subject: [PATCH 14/15] wip --- test/integration/tools/system/pip_manager_test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/integration/tools/system/pip_manager_test.py b/test/integration/tools/system/pip_manager_test.py index d98e864f2fd..5ae24b1d993 100644 --- a/test/integration/tools/system/pip_manager_test.py +++ b/test/integration/tools/system/pip_manager_test.py @@ -30,9 +30,7 @@ def test_pipenv_error_message(mock_shutil_which): with pytest.raises(ConanException) as exc_info: pipenv = PipEnv(conanfile, "testenv") pipenv._create_venv() - assert exc_info.value.args[0] == "PipEnv could not find a Python executable path. " \ - "Please, install Python system-wide or set the 'tools.system.pipenv:python_interpreter' " \ - "conf to the full path of a Python executable" + assert "PipEnv could not find a Python executable path." in exc_info.value.args[0] def test_pipenv_creation_error_message(): @@ -46,4 +44,4 @@ def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=Fa conanfile.run = fake_run with pytest.raises(ConanException) as exc_info: pipenv._create_venv() - assert exc_info.value.args[0] == "PipEnv could not create a Python virtual environment using '/python/interpreter/from/config': fake error message" + assert "using '/python/interpreter/from/config': fake error message" in exc_info.value.args[0] From 5c8438e0b7ec82c54595452c662b37b1a209f02f Mon Sep 17 00:00:00 2001 From: David Sanchez Date: Wed, 29 Oct 2025 12:23:38 +0100 Subject: [PATCH 15/15] wip --- test/integration/tools/system/pip_manager_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/tools/system/pip_manager_test.py b/test/integration/tools/system/pip_manager_test.py index 5ae24b1d993..90b53fecea6 100644 --- a/test/integration/tools/system/pip_manager_test.py +++ b/test/integration/tools/system/pip_manager_test.py @@ -30,7 +30,7 @@ def test_pipenv_error_message(mock_shutil_which): with pytest.raises(ConanException) as exc_info: pipenv = PipEnv(conanfile, "testenv") pipenv._create_venv() - assert "PipEnv could not find a Python executable path." in exc_info.value.args[0] + assert "install Python system-wide or set the 'tools.system.pipenv:python_interpreter' conf" in exc_info.value.args[0] def test_pipenv_creation_error_message():