Skip to content

Latest commit

 

History

History
123 lines (87 loc) · 7.16 KB

README.MD

File metadata and controls

123 lines (87 loc) · 7.16 KB

Pyxe 🧚

Python Tkinter GUI + PyInstaller = Easy to use auto-compiler for your Python projects ▶️

Table of Contents: 🤖

  • Compatibility
  • Project Folder Structure
  • Installing Requirements.txt List
  • How to Use
  • To-Do List
  • Credits

Compatibility: ✔️

Please review this section to see if you'll be able to use Pyxe on your machine. Because of my current setup, and the fact that PyInstaller only lets you compile executables on the same operating system you run it on which is understandable, I'll go ahead and inform the Mac and Linux users out there that Pyxe isn't yet ready for use, yet. I have a goal to get a CI/CD pipeline set up where I'll be able to spin up Mac, Windows, and Linux machines on the fly in order for me to get Pyxe to be Mac, Windows, and Linux compatible within the next week.

Message from the developers of PyInstaller:

PyInstaller runs on Windows 8 and newer, Mac OS X 10.7 (Lion) and newer, and GNU/Linux requires the ldd terminal application

[PyInstaller] works out-of-the-box with any Python version 3.6-3.9

A list of supported packages that PyInstaller is compatible with can be found here, although most packages will work out of the box with PyInstaller even if it's not listed.

Source: GitHub.com/PyInstaller/PyInstaller

All PyInstaller requirements are located on the official website PyInstaller.ReadTheDocs.io. As far as I know, there should not be any compatibility issues with using Tkinter, although I personally recommend using Python version 3+.

Both Tkinter and PyInstaller do run on Mac and Linux, so if you're interested and would like to jump into this project yourself, then you'll definitely want to start by heading to http://www.pyinstaller.org/ to begin getting familiar with PyInstaller and check out the Tkinter GUI module at https://docs.python.org/3/library/tkinter.html if that interests you as well.


Project Folder Structure: 🐍

(Folder | Filename):    Description:
Pyxe:               Root project folder  
-build\:             Default build directory for PyInstaller  
-ico\:               Favicon.ico that tkinter looks for when Pyxe starts  
-temp\:              Default directory for the temp files PyInstaller creates  
-test_scripts\:      Directory of test scripts you can compile to test Pyxe out  
-requirements.txt:  Python modules required to run Pyxe  
-main.py:           Pyxe auto-compiler program

How to Install Modules and Create Virtual Environment: ✨

After ensuring your using the desired Python installation, use a terminal to install the modules listed in the requirements.txt file provided within the project:

Setting Up Virtual Environment:

  1. Open up a terminal and set the current directory to where you'll be to creating the virtual environment.
  2. Run python3 -m venv pyxe-env ('pyxe-env' can be anything you choose).
  3. On Windows, run:
    pyxe-env\Scripts\activate.bat (again, replace 'pyxe-env' with the name of your virtual environment)
    On Unix or MacOS, run:
    source tutorial-env/bin/activate
  4. pip install -r requirements.txt

Install Modules Without Virtual Environment:

  1. pip install -r requirements.txt

How to Use Pyxe 💫:

  1. Download or clone the Pyxe repository onto a machine.
  2. Set up a virtualenv configuration or use a global Python installation and install the required Python modules listed above.
  3. Run the 'main.py' file in the project root directory and you should see a GUI that looks like the one below:

Pyxe Screenshot:

Screenshot of the Pyxe GUI

  1. Before you begin compiling your Python project, please review the documentation online for PyInstaller to ensure you're bundling data into the executable correctly.

⚠️ IMPORTANT: ⚠️

If you're referencing a file or folder in your Python project and you plan on using the '-onefile' option, please use the following code snippet in your project so that PyInstaller can find the file and package it into the executable file correctly. Failing to do this may lead to your code not being able to run as desired.

Please see: https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile for more details.

# Code Snippet: Grabs the absolute path from the relative path (for packaging external files INTO the executable)  
# Place or import this function in your project and be sure to use it when referencing a filepath. 

import os, sys  
def resource_path(relative_path):  
      """ Get absolute path to resource, works for dev and for PyInstaller """  
      base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))  
      return os.path.join(base_path, relative_path)
  1. You may now begin compiling your Python file/project into an executable. The only required information that Pyxe needs is the filepath to the Python file. The remaining information is optional to input as PyInstaller has default values if no value is retrieved.
  2. You'll either see green text notifying you that Pyxe is compiling the project or that an error occurred. If there's a problem with Pyxe and not PyInstaller itself, and you would like to point it out, then certainly do so by sending me a direct message. My GitHub is DutytoDevelop.
  3. The executable will be placed in the designated 'build' folder located in the project root directory unless provided an alternative directory to place the executable in!
  4. If you're trying to package multiple files into the program, please include all files inside one data folder and ensure that you're using the while I work to implement the feature that'll allow being able to package data from multiple directories. Happy Compiling!

Successful compilation of test Python script I've provided in Pyxe repository:

Successfully compiled PyGame example script _Note: _


To-Do:

  • ✔️ Piping the output of PyInstaller through the GUI itself for real-time updates
  • 🚧 Implement system to be compatible with multiple operating systems
  • 🚧 Fix code to allow importing bundled data from multiple directories instead of just one

Credit:

  • Creators of Python
  • Creators of PyInstaller and Tkinter
  • Google
  • GitHub
  • StackEdit (Great online user interface to write and preview .MD files on the fly)
  • Those on StackOverflow.com that help people every day with troubleshooting programming issues
  • Everyone else who collaborated with me and assisted me ❤️

Happy Compiling! 🎅