Skip to content

Commit

Permalink
feat: rename USE_EMOJI to PIPX_USE_EMOJI (#1581)
Browse files Browse the repository at this point in the history
Rename environmental variable USE_EMOJI to PIPX_USE_EMOJI. Keeps support for USE_EMOJI. Fixes #1395.
  • Loading branch information
dkav authored Nov 28, 2024
1 parent a521400 commit 31f2501
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.d/1395.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename environmental variable `USE_EMOJI` to `PIPX_USE_EMOJI`.
4 changes: 2 additions & 2 deletions src/pipx/commands/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"PIPX_SHARED_LIBS",
"PIPX_DEFAULT_PYTHON",
"PIPX_FETCH_MISSING_PYTHON",
"USE_EMOJI",
"PIPX_USE_EMOJI",
"PIPX_HOME_ALLOW_SPACE",
]

Expand All @@ -34,7 +34,7 @@ def environment(value: str) -> ExitCode:
"PIPX_VENV_CACHEDIR": paths.ctx.venv_cache,
"PIPX_STANDALONE_PYTHON_CACHEDIR": paths.ctx.standalone_python_cachedir,
"PIPX_DEFAULT_PYTHON": DEFAULT_PYTHON,
"USE_EMOJI": str(EMOJI_SUPPORT).lower(),
"PIPX_USE_EMOJI": str(EMOJI_SUPPORT).lower(),
"PIPX_HOME_ALLOW_SPACE": str(paths.ctx.allow_spaces_in_home_path).lower(),
}
if value is None:
Expand Down
5 changes: 4 additions & 1 deletion src/pipx/emojis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def use_emojis() -> bool:
platform_emoji_support = True
except UnicodeEncodeError:
platform_emoji_support = False
return strtobool(str(os.getenv("USE_EMOJI", platform_emoji_support)))
use_emoji = os.getenv("PIPX_USE_EMOJI")
if use_emoji is None:
use_emoji = str(os.getenv("USE_EMOJI", platform_emoji_support))
return strtobool(use_emoji)


EMOJI_SUPPORT = use_emojis()
Expand Down
2 changes: 1 addition & 1 deletion src/pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def prog_name() -> str:
PIPX_MAN_DIR Overrides location of manual pages installations. Manual pages are symlinked or copied here.
PIPX_GLOBAL_MAN_DIR Used instead of PIPX_MAN_DIR when the `--global` option is given.
PIPX_DEFAULT_PYTHON Overrides default python used for commands.
USE_EMOJI Overrides emoji behavior. Default value varies based on platform.
PIPX_USE_EMOJI Overrides emoji behavior. Default value varies based on platform.
PIPX_HOME_ALLOW_SPACE Overrides default warning on spaces in the home path
""",
subsequent_indent=" " * 24, # match the indent of argparse options
Expand Down
8 changes: 4 additions & 4 deletions tests/test_emojis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@pytest.mark.parametrize(
"USE_EMOJI, encoding, expected",
"PIPX_USE_EMOJI, encoding, expected",
[
# utf-8
(None, "utf-8", True),
Expand Down Expand Up @@ -39,8 +39,8 @@
("false", "cp1252", False),
],
)
def test_use_emojis(monkeypatch, USE_EMOJI, encoding, expected):
def test_use_emojis(monkeypatch, PIPX_USE_EMOJI, encoding, expected):
with mock.patch.object(sys, "stderr", TextIOWrapper(BytesIO(), encoding=encoding)):
if USE_EMOJI is not None:
monkeypatch.setenv("USE_EMOJI", USE_EMOJI)
if PIPX_USE_EMOJI is not None:
monkeypatch.setenv("PIPX_USE_EMOJI", PIPX_USE_EMOJI)
assert use_emojis() is expected
2 changes: 1 addition & 1 deletion tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_cli_with_args(monkeypatch, capsys):
assert not run_pipx_cli(["environment", "--value", "PIPX_TRASH_DIR"])
assert not run_pipx_cli(["environment", "--value", "PIPX_VENV_CACHEDIR"])
assert not run_pipx_cli(["environment", "--value", "PIPX_DEFAULT_PYTHON"])
assert not run_pipx_cli(["environment", "--value", "USE_EMOJI"])
assert not run_pipx_cli(["environment", "--value", "PIPX_USE_EMOJI"])
assert not run_pipx_cli(["environment", "--value", "PIPX_HOME_ALLOW_SPACE"])

assert run_pipx_cli(["environment", "--value", "SSS"])
Expand Down

0 comments on commit 31f2501

Please sign in to comment.