Skip to content
Advertisement

Cross-Platform Installer paths

I’m writing an installer for a Python app I’m making, and needed to have paths for different file locations. These are what I have so far, and so wondered if these were correct of if I should change any of them (particularly the Linux/macOS ones)

I have a path for:

  • the actual binary
  • for the config file
  • the README
  • the start menu, should the user want to add a shortcut (this will create the .desktop file on Linux/macOS, a shortcut on Windows)
  • the desktop, should the user want to add a shortcut

Can anyone let me know if there should be changes to these to make them work on all devices etc

Windows

JavaScript

Linux

JavaScript

macOS

JavaScript

Thanks in advance

EDIT: I have added the option for the user to change the paths anyway so it doesn’t have to be perfect but I would like the best ‘normal’ paths

Advertisement

Answer

My recommendation is to use sysconfig as much as possible. For example on a POSIX system get_paths() returns:

JavaScript

Note that sysconfig supports different schemes:

JavaScript

The home or user schemes are handy when the installer doesn’t have root or administrator privileges.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement