newville / pyshortcuts

create desktop shortcuts to python scripts on Windows, Mac, or Linux
MIT License
103 stars 15 forks source link

Relative path for shortcut target #43

Open acreegan opened 2 years ago

acreegan commented 2 years ago

I would like the option to set the shortcut target to a relative path so that I can create a distributable folder with the shortcut and its target. (For me this would be as part of a pyinstaller bundle). This would obviously require the ability to set the location of the shortcut too.

Does this sound like something that would be possible/ people would be open to?

newville commented 2 years ago

@acreegan I would not be opposed to trying that, but I'm not sure it is actually feasible.

I think the shortcut links on Windows, desktop files on Linux, and macOS apps are really meant to use absolute paths.
But, if you have any insights on that, please let us know.

What I do is run a "make desktop icons" command after the installation. Does pyinstaller support a "post-install" process?

acreegan commented 2 years ago

I wondered that too, but I'm not sure. I'll investigate.

You can run a post-install process with pyinstaller if you call pyinstaller as part of an overall installation script, and this is fine if the user is running the script, but would not work to make a distributable bundle. The reason why I'm using pyshortcuts is because pyinstaller puts its .exe in the middle of a file full of other stuff, so I'd like to automatically create a shortcut to that in a directory one level up, then distribute the whole thing.

newville commented 2 years ago

@acreegan yeah, that all makes sense.

I have to admit I don't know very much about pyinstaller. I wonder if maybe it would be worth coming up with a pyinstaller-specific hook for combing pyinstaller and pyshortcuts? I'm not sure what that would look like, but if pyinstaller is making a bundle with a hard-to-find-and-run executable, maybe your use case would be a common one?