Skip to content

Commit

Permalink
Merge branch 'develop2' into fix-nested-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Todiq authored Dec 18, 2024
2 parents e546d30 + 5fbf896 commit 8e7c9bf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
17 changes: 9 additions & 8 deletions conan/tools/env/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,15 @@ def save_script(self, filename):
is_bat = self._subsystem == WINDOWS
try:
is_ps1 = self._conanfile.conf.get("tools.env.virtualenv:powershell", check_type=bool)
ConanOutput().warning(
"Boolean values for 'tools.env.virtualenv:powershell' are deprecated. "
"Please specify 'powershell.exe' or 'pwsh' instead, appending arguments if needed "
"(for example: 'powershell.exe -argument'). "
"To unset this configuration, use `tools.env.virtualenv:powershell=!`, which matches "
"the previous 'False' behavior.",
warn_tag="deprecated"
)
if is_ps1 is not None:
ConanOutput().warning(
"Boolean values for 'tools.env.virtualenv:powershell' are deprecated. "
"Please specify 'powershell.exe' or 'pwsh' instead, appending arguments if needed "
"(for example: 'powershell.exe -argument'). "
"To unset this configuration, use `tools.env.virtualenv:powershell=!`, which matches "
"the previous 'False' behavior.",
warn_tag="deprecated"
)
except ConanException:
is_ps1 = self._conanfile.conf.get("tools.env.virtualenv:powershell", check_type=str)
if is_ps1:
Expand Down
17 changes: 9 additions & 8 deletions conan/tools/microsoft/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,15 @@ def generate(self, scope="build"):

try:
is_ps1 = self._conanfile.conf.get("tools.env.virtualenv:powershell", check_type=bool)
ConanOutput().warning(
"Boolean values for 'tools.env.virtualenv:powershell' are deprecated. "
"Please specify 'powershell.exe' or 'pwsh' instead, appending arguments if needed "
"(for example: 'powershell.exe -argument'). "
"To unset this configuration, use `tools.env.virtualenv:powershell=!`, which matches "
"the previous 'False' behavior.",
warn_tag="deprecated"
)
if is_ps1 is not None:
ConanOutput().warning(
"Boolean values for 'tools.env.virtualenv:powershell' are deprecated. "
"Please specify 'powershell.exe' or 'pwsh' instead, appending arguments if needed "
"(for example: 'powershell.exe -argument'). "
"To unset this configuration, use `tools.env.virtualenv:powershell=!`, which matches "
"the previous 'False' behavior.",
warn_tag="deprecated"
)
except ConanException:
is_ps1 = self._conanfile.conf.get("tools.env.virtualenv:powershell", check_type=str)
if is_ps1:
Expand Down
21 changes: 21 additions & 0 deletions test/functional/toolchains/env/test_virtualenv_powershell.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,24 @@ class Pkg(ConanFile):
client.current_folder,"mycompiler1.bat")
client.run_command(cmd)
assert "MYTOOL 1!!" in client.out


@pytest.mark.parametrize("powershell", [None, True, False])
def test_powershell_deprecated_message(powershell):
client = TestClient(light=True)
conanfile = textwrap.dedent("""\
from conan import ConanFile
class Pkg(ConanFile):
settings = "os"
name = "pkg"
version = "0.1"
""")

client.save({"conanfile.py": conanfile})
powershell_arg = f'-c tools.env.virtualenv:powershell={powershell}' if powershell is not None else ""
client.run(f'install . {powershell_arg}')
# only show message if the value is set to False or True if not set do not show message
if powershell is not None:
assert "Boolean values for 'tools.env.virtualenv:powershell' are deprecated" in client.out
else:
assert "Boolean values for 'tools.env.virtualenv:powershell' are deprecated" not in client.out

0 comments on commit 8e7c9bf

Please sign in to comment.