Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent pipx from erroneously listing other apps installed outside of pipx #650

Merged
merged 4 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dev

- Make sure log files are utf-8 encoded to preven Unicode encoding errors from occurring with emojis. (#646)
- Fixed issue which made pipx incorrectly list apps as part of a venv when they were not installed by pipx. (#650)

0.16.1.0

Expand Down
7 changes: 5 additions & 2 deletions src/pipx/commands/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ def get_venv_summary(
VenvProblems(not_installed=True),
)

apps = package_metadata.apps + package_metadata.apps_of_dependencies
apps = package_metadata.apps
if package_metadata.include_dependencies:
apps += package_metadata.apps_of_dependencies

exposed_app_paths = _get_exposed_app_paths_for_package(
venv.bin_path, apps, constants.LOCAL_BIN_DIR
)
Expand Down Expand Up @@ -238,7 +241,7 @@ def _get_exposed_app_paths_for_package(
# Windows, we use a less strict check if we don't have a symlink.
if _can_symlink(local_bin_dir) and b.is_symlink():
is_same_file = b.resolve().parent.samefile(venv_bin_path)
else:
elif not _can_symlink(local_bin_dir):
Copy link
Contributor

@pdecat pdecat Apr 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the test below:

pipx install py-spy
...
Traceback (most recent call last):
  File "/home/patrick/.local/bin/pipx", line 8, in <module>
    sys.exit(cli())
  File "/home/patrick/.local/lib/python3.9/site-packages/pipx/main.py", line 762, in cli
    return run_pipx_command(parsed_pipx_args)
  File "/home/patrick/.local/lib/python3.9/site-packages/pipx/main.py", line 193, in run_pipx_command
    return commands.install(
  File "/home/patrick/.local/lib/python3.9/site-packages/pipx/commands/install.py", line 69, in install
    run_post_install_actions(
  File "/home/patrick/.local/lib/python3.9/site-packages/pipx/commands/common.py", line 377, in run_post_install_actions
    package_summary, _ = get_venv_summary(
  File "/home/patrick/.local/lib/python3.9/site-packages/pipx/commands/common.py", line 201, in get_venv_summary
    exposed_app_paths = _get_exposed_app_paths_for_package(
  File "/home/patrick/.local/lib/python3.9/site-packages/pipx/commands/common.py", line 249, in _get_exposed_app_paths_for_package
    if is_same_file:
UnboundLocalError: local variable 'is_same_file' referenced before assignment

Using current master https://github.com/pipxproject/pipx/blame/13b6a271fcddad00cad6eab82fc2714cf6ad4503/src/pipx/commands/common.py#L249

is_same_file = b.name in package_binary_names

if is_same_file:
Expand Down