If you intend on distributing your application to other people, you have several ways to go about sharing your program. You can either:
- Distribute Python code
- Use a tool to transform your code into a binary executable
Sharing Source Code Using "pip"
Pip is well-known in the Python community for distributing Python packages, but what's not well-known is that it can also be used to distribute applications. Distributing your application in a way that's pip-installable will make installing and using your application much more user-friendly.
The most straight-forward way to share your code is to share it as Python code. The advantage is that other Python programmers can not only use your application, but can learn how it was written and extend it.
Even if your users are not Python programmers, they can still use your application's source code. Python is very easy to install. It's a single file that's downloaded, executed, and a few dialog boxes to click through.
If your application is shared so that it's pip installable, then the user experience is nicer. Your users can type 1 command to install your application:
> python -m pip install your_application
Then to run your application, they can type a command on the command line that will start your program.
When you upload your application for distribution, you can specify the command your users type to run your application. You can have multiple commands specified in a single application. PySimpleGUI uses this capability and has commands such as psgmain, psghelp, psgver, psgupgrade, etc.
Your code can be located in a couple of locations if you want to use pip installs:
For your users that are accustomed to a non-command-line-environment (i.e. Windows), you can transform any of the PySimpleGUI supplied applications as well as the applications you write, into user-friendly icons that can be double-clicked or pinned to the Windows taskbar. Your users will never know they're using Python. Your PySimpleGUI applications will launch, look and feel like any other Windows application.
PyShare Application (COMING SOON!)
PyShare is an application that was authored and used to release the PySimpleGUI 5 applications. Some additional work is needed to complete making this a robust application ready for end-users to use to release their applications.
GitHub Repo Sharing
You can structure your GitHub Repo for your project so and provide a single command that will pip install your application in the same way as if you had posted it to PyPI.
Instruct your users to run this command to install your program.
YOUR_USERNAME with the GitHub user name for the repo and replace
YOUR_REPO with the name of the repository. For example, to pip install the
psgresizer utility from the PySimpleGUI repo you would enter the command:
If you want to keep your code private, but still enable your users access to install it using
pip, you can use a private GitHub repo and provide access using a security token that you give to users.
Distributing Using PyPI
There are multiple ways to upload to PyPI currently. These instructions use the older twice uploader.
The same folder structure described above can be used to distribute via PyPI. Instead of posting to GitHub, you'll upload to PyPI. Then your users can pip install using only the name of your application. There's no need to provide a URL like you would using using GitHub.
Be sure to run these from the folder your
setup.py file is located.
If you want to distribute your application to users that do not have Python installed on their machine, then you'll need to convert your application into an executable.
psgcompiler is a front-end for the popular
PyInstaller program that will transform your PySimpleGUI (or any Python project) into a binary distributable application. If you're on a PC, the output will be an EXE file and if on a Mac an APP file is created.
You can run PyInstaller directly, or you can use
psgcompiler to have it build and execute the PyInstaller command for you.
To install the
psgcompiler on your system, use pip to install it and then run
psgcompiler from the command line. You can also create a shortcut using the utility
psgshortcut so that you can run using a double-click instead of the command line.
Malware & Virus False Positives
EXE files created using PyInstaller are sometimes flagged as having a virus or malware. This is not a PySimpleGUI specific problem.
Try running a test that has only a print statement to see if you've got a problem that is this generalized false-positive problem. The PyInstaller project is a good place to look for the latest information for fixes or workarounds.