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

Cannot create a desktop menu entry when installed using pipx #1465

Open
staceybellerose opened this issue Mar 30, 2024 · 4 comments
Open

Cannot create a desktop menu entry when installed using pipx #1465

staceybellerose opened this issue Mar 30, 2024 · 4 comments

Comments

@staceybellerose
Copy link

I installed Porcupine using pipx, and when checking the box in Settings to show Porcupine in the desktop menu system, I get the error messagebox: "Porcupine must be installed in a virtual environment in order to create a desktop menu entry".

Installation process: pipx install https://github.com/Akuli/porcupine/archive/v2024.03.09.zip

pipx doesn't use the environment variable VIRTUAL_ENV, but instead creates soft links in $HOME/.local/bin that point to its internally-managed venvs. This appears to be why the action fails.

@Akuli
Copy link
Owner

Akuli commented Mar 30, 2024

Thanks for reporting this. I will look into this eventually.

Pipx seems like a good way to install and run Porcupine, if you already have pipx installed, so I want it to be a "just works" experience.

@staceybellerose
Copy link
Author

staceybellerose commented Mar 31, 2024

Here's an idea: using shutil.which(), check to see if porcu is in the path, whether or not a virtual environment is present.

If it's not in the path, then error out with the messagebox.

Otherwise, if a virtual environment exists, use the current logic. If there's no virtual environment, then create the desktop entry with the Exec= line as just "Exec=porcu". (EDIT: my project needed the full location here, not just the command name.)

Some pseudocode:

location = shutil.which('porcu')
if location is None:
    # error out
venv = os.environ.get("VIRTUAL_ENV")
if venv:
    # build exec_line as before
    activate_path = ...
    bash_command = f'source {shlex.quote(str(activate_path))} && {EXECUTABLE} "$@"'
    exec_line = f"Exec=bash -c {shlex.quote(bash_command)} bash %F\n"
else:
    exec_line=f"Exec={location}"
# write file as before

This seems to work for my project when I install it with pipx.

@Akuli
Copy link
Owner

Akuli commented Mar 31, 2024

The problem is that porcu might point at a different installation of Porcupine.

@Akuli
Copy link
Owner

Akuli commented Apr 1, 2024

Related: #1219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants