pypa / pipx

Install and Run Python Applications in Isolated Environments
https://pipx.pypa.io
MIT License
10.07k stars 407 forks source link

pipx list - show injected apps #997

Open J3ronimo opened 1 year ago

J3ronimo commented 1 year ago

Currently, pipx list shows only the main scripts (.exe's) executable from an installed venv:

   package flit 3.9.0, installed using Python 3.9.5
    - flit.exe

When injecting a package and including its apps:

pipx inject flit keyring --include-apps

pipx will happily report that this app is now globally available,

These apps are now globally available
    - keyring.exe

but nevertheless not show it when running pipx list, which still shows exactly the output above. AFAIK there is no way to discover the availability of keyring.exe after that.

There is pipx list --include-injected, but this will only list the included packages, not the apps / scripts they might bring along:

 package flit 3.9.0, installed using Python 3.9.5
    - flit.exe
    Injected Packages:
      - keyring 23.13.1

It would be nice if pipx list could somehow list all of them in one command, for example:

> pipx list
 package flit 3.9.0, installed using Python 3.9.5
    - flit.exe
    - keyring.exe (injected)

or like this

> pipx list --include-injected
 package flit 3.9.0, installed using Python 3.9.5
    - flit.exe
    Injected Packages:
      - keyring 23.13.1
          - keyring.exe

All the functionality is there to make injected apps available globally, which can make sense if they are dependencies of a root package anyway and therefore already installed in its venv. But at the moment it's hard for the user to discover and make use of them, even though they were explicitly made available with pipx inject.

gaborbernat commented 9 months ago

PR welcome.

lamyergeier commented 9 months ago

This works on Linux: (I did the following)

  pipx install argostranslate
  pipx inject argostranslate argostranslategui --include-app
$ pipx list --include-injected
venvs are in /mnt/Data/.local/pipx/venvs
apps are exposed on your $PATH at /mnt/Data/.local/bin
manual pages are exposed at /mnt/Data/.local/share/man
   package argostranslate 1.9.1, installed using Python 3.11.6
    - argos-translate
    - argos-translate-gui
    - argospm
    Injected Packages:
      - argostranslategui 1.6.5

We can see that it shows argos-translate-gui

@J3ronimo Did I misunderstand?

J3ronimo commented 9 months ago

Thanks for the repro @lamyergeier . Interestingly, argos-translate-gui is indeed missing when I run the same on Windows:

>pipx list --include-injected
package argostranslate 1.9.1, installed using Python 3.11.5
    - argos-translate
    - argospm
    Injected Packages:
      - argostranslategui 1.6.5

Although the script exists both in the Scripts folder of the venv and in the .local/bin folder, alongside the others shown above.

Here's my pipx_metadata.json, reduced to the relevant parts. Looks as expected. If pipx list prints based on the data taken from here, which I assume, then I wouldn't know why this would leave away the injected_packages.argostranslategui.apps on Windows.

{
    "injected_packages": {
        "argostranslategui": {
            "app_paths": [
                {
                    "__Path__": "C:\\Users\\J3ronimo\\.local\\pipx\\venvs\\argostranslate\\Scripts\\argos-translate-gui",
                    "__type__": "Path"
                }
            ],
            "apps": [
                "argos-translate-gui"
            ],            
            "include_apps": true,
            "package": "argostranslategui",            
            "package_version": "1.6.5",            
            "suffix": ""
        }
    },
    "main_package": {
        "app_paths": [
            {
                "__Path__": "C:\\Users\\J3ronimo\\.local\\pipx\\venvs\\argostranslate\\Scripts\\argos-translate",
                "__type__": "Path"
            },
            {
                "__Path__": "C:\\Users\\J3ronimo\\.local\\pipx\\venvs\\argostranslate\\Scripts\\argospm",
                "__type__": "Path"
            }
        ],
        "apps": [
            "argos-translate",
            "argospm"
        ],
        "include_apps": true,        
        "package": "argostranslate",        
        "package_version": "1.9.1",        
        "suffix": ""
    }    
}
huxuan commented 5 months ago

I can confirm the result from @lamyergeier, seems this is only windows-specific problem.

huxuan commented 4 months ago

After installing Python on my Windows finally, seems I still can not reproduce the problem.

@J3ronimo would you like to double confirm the problem still exists with the latest 1.5.0 version?

Below is the result on my local machine, I only installed pipx before flit.

PS C:\Users\huxuan> pipx install flit
  installed package flit 3.9.0, installed using Python 3.12.3
  These apps are now globally available
    - flit.exe
done! ✨ 🌟 ✨
PS C:\Users\huxuan> pipx inject flit keyring --include-apps
  installed package keyring 25.2.0, installed using Python 3.12.3
  These apps are now globally available
    - flit.exe
    - keyring.exe
done! ✨ 🌟 ✨
  injected package keyring into venv flit
done! ✨ 🌟 ✨
PS C:\Users\huxuan> pipx list --include-injected
venvs are in C:\Users\huxuan\AppData\Local\pipx\pipx\venvs
apps are exposed on your $PATH at C:\Users\huxuan\.local\bin
manual pages are exposed at C:\Users\huxuan\.local\share\man
   package flit 3.9.0, installed using Python 3.12.3
    - flit.exe
    - keyring.exe
    Injected Packages:
      - keyring 25.2.0
   package pipx 1.5.0, installed using Python 3.12.3
    - pipx.exe
PS C:\Users\huxuan> pipx list --json
{
    "pipx_spec_version": "0.1",
    "venvs": {
        "flit": {
            "metadata": {
                "injected_packages": {
                    "keyring": {
                        "app_paths": [
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\keyring.exe",
                                "__type__": "Path"
                            }
                        ],
                        "app_paths_of_dependencies": {},
                        "apps": [
                            "keyring.exe"
                        ],
                        "apps_of_dependencies": [],
                        "include_apps": true,
                        "include_dependencies": false,
                        "man_pages": [],
                        "man_pages_of_dependencies": [],
                        "man_paths": [],
                        "man_paths_of_dependencies": {},
                        "package": "keyring",
                        "package_or_url": "keyring",
                        "package_version": "25.2.0",
                        "pip_args": [],
                        "suffix": ""
                    }
                },
                "main_package": {
                    "app_paths": [
                        {
                            "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\flit.exe",
                            "__type__": "Path"
                        }
                    ],
                    "app_paths_of_dependencies": {
                        "charset-normalizer": [
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\normalizer.exe",
                                "__type__": "Path"
                            }
                        ],
                        "docutils": [
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\docutils.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2html.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2html4.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2html5.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2latex.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2man.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2odt.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2pseudoxml.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2s5.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2xetex.exe",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\flit\\Scripts\\rst2xml.exe",
                                "__type__": "Path"
                            }
                        ]
                    },
                    "apps": [
                        "flit.exe"
                    ],
                    "apps_of_dependencies": [
                        "normalizer.exe",
                        "docutils.exe",
                        "rst2html.exe",
                        "rst2html4.exe",
                        "rst2html5.exe",
                        "rst2latex.exe",
                        "rst2man.exe",
                        "rst2odt.exe",
                        "rst2pseudoxml.exe",
                        "rst2s5.exe",
                        "rst2xetex.exe",
                        "rst2xml.exe"
                    ],
                    "include_apps": true,
                    "include_dependencies": false,
                    "man_pages": [],
                    "man_pages_of_dependencies": [],
                    "man_paths": [],
                    "man_paths_of_dependencies": {},
                    "package": "flit",
                    "package_or_url": "flit",
                    "package_version": "3.9.0",
                    "pip_args": [],
                    "suffix": ""
                },
                "pipx_metadata_version": "0.4",
                "python_version": "Python 3.12.3",
                "source_interpreter": {
                    "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\pipx\\Scripts\\python.exe",
                    "__type__": "Path"
                },
                "venv_args": []
            }
        },
        "pipx": {
            "metadata": {
                "injected_packages": {},
                "main_package": {
                    "app_paths": [
                        {
                            "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\pipx\\Scripts\\pipx.exe",
                            "__type__": "Path"
                        }
                    ],
                    "app_paths_of_dependencies": {
                        "argcomplete": [
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\pipx\\Scripts\\activate-global-python-argcomplete",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\pipx\\Scripts\\python-argcomplete-check-easy-install-script",
                                "__type__": "Path"
                            },
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\pipx\\Scripts\\register-python-argcomplete",
                                "__type__": "Path"
                            }
                        ],
                        "userpath": [
                            {
                                "__Path__": "C:\\Users\\huxuan\\AppData\\Local\\pipx\\pipx\\venvs\\pipx\\Scripts\\userpath.exe",
                                "__type__": "Path"
                            }
                        ]
                    },
                    "apps": [
                        "pipx.exe"
                    ],
                    "apps_of_dependencies": [
                        "activate-global-python-argcomplete",
                        "python-argcomplete-check-easy-install-script",
                        "register-python-argcomplete",
                        "userpath.exe"
                    ],
                    "include_apps": true,
                    "include_dependencies": false,
                    "man_pages": [],
                    "man_pages_of_dependencies": [],
                    "man_paths": [],
                    "man_paths_of_dependencies": {},
                    "package": "pipx",
                    "package_or_url": "pipx",
                    "package_version": "1.5.0",
                    "pip_args": [],
                    "suffix": ""
                },
                "pipx_metadata_version": "0.4",
                "python_version": "Python 3.12.3",
                "source_interpreter": {
                    "__Path__": "C:\\Program Files\\Python312\\python.exe",
                    "__type__": "Path"
                },
                "venv_args": []
            }
        }
    }
}