pythonwindowsvisual-studiopackagemsix

How to package a Python project into MSIX package?


I currently work on a Python project, which I'd like to upload to the Microsoft Store in the future.

As far as I am aware, in order to upload applications to the Microsoft Store, it is necessary that the application will be packed into the MSIX format.

Now the question is - is it possible to pack a Python project into the MSIX format?

I already tried two possible approaches


I assumed that it will be much easier to pack an .exe file into an MSIX package. Since .py files require an interpreter in order to run, I managed to freeze the Python project into a standalone .exe runnable file - and it works pretty good. I found a useful tool made by Microsoft, which is supposed to pack .exe files under the MSIX format. The tool is MSIX Packaging Tool which is available at the Microsoft Store. I did manage to create an .msix file but I can't run in since Windows says that I have to sign the .exe first.


I found out that it is possible to pack a project into an MSIX package, by using built-in tools inside Visual Studio 2019. So I managed to move my whole python project into Visual Studio, and follow the next steps in order to pack my project. The problem is that already in the early stages, when adding the reference to my python project, the next error occurs:

Stage number 5


I'd love to know if you have any other possible approaches for packing a Python project into an MSIX package.


Solution

    1. Use PyInstaller or a similar tool to package your Python application. You can find more information on how to do this in the PyInstaller documentation.

    2. Once you have the output from PyInstaller (either a single .exe file or the "dist" folder), you can use a program like AdvancedInstaller to create .msix files.

    3. Note: If you're using the "dist" folder, don't add the folder itself to AdvancedInstaller. Instead, you'll find a folder inside the "dist" folder with the same name as your Python package or script. Add that folder to AdvancedInstaller.

    4. In AdvancedInstaller, you can create shortcuts that point to the .exe file inside the folder.

    5. PyInstaller: https://pyinstaller.org/en/stable/

    6. AdvancedInstaller: https://www.advancedinstaller.com/

    7. Creating an MSIX package using AdvancedInstaller: https://www.advancedinstaller.com/user-guide/tutorial-create-msix-package.html

    Edit:
    You first approach actually works, you have to sign the exe indeed, I found this guide for signing the exe gratis https://adangel.org/2021/09/16/code-signing-lets-encrypt-github-pages/

    Edit 2:
    Here's a useful link from Microsoft https://learn.microsoft.com/en-us/windows/apps/publish/publish-your-app/overview?pivots=store-installer-msi-exe