Pyloid-HTML-Boilerplate
Pyloid-Html-Boilerplate is a template for projects combining a HTML/CSS/JS frontend with a Python backend. Here, we'll explain in detail the project setup, development, and build process.
Prerequisites
1. Project Initialization
Before starting the project, you need to install all necessary dependencies.
This command performs the following tasks:
Install npm packages
Create a Python virtual environment (venv-pyloid)
Install Python dependencies (based on requirements.txt)
The appropriate script is executed depending on the operating system.
2. Running the Development Server
During development, you can run both frontend and backend servers simultaneously with the following command:
This command performs the following tasks:
Run the React frontend development server using Vite
Run the Python backend server (src-pyloid/main.py)
The concurrently package is used to run both processes in parallel.
3. Building the Project
To build the project for production deployment, use the following command:
This command performs the following tasks:
TypeScript compilation (tsc -b)
Frontend build using Vite
Package the Python backend into an executable using PyInstaller
Backend Packaging with PyInstaller
PyInstaller is a tool that converts Python applications into standalone executables. Pyloid Boilerplate uses different spec files for each operating system:
Windows:
build-windows.spec
Linux:
build-linux.spec
MacOS:
build-macos.spec
These spec files specify which files to include and what options to use for PyInstaller.
How PyInstaller Works
Dependency Analysis: PyInstaller analyzes the Python script and its dependencies.
File Collection: It collects all necessary Python modules, libraries, and data files.
Binary Generation: It packages the collected files into a single directory or a single executable file.
Custom Build Process
You can modify the build process to meet your project's specific requirements:
Modify the scripts section in
package.json
Modify PyInstaller spec files (e.g.,
build-windows.spec
,build-linux.spec
,build-macos.spec
)Write additional build scripts if necessary
Important Notes
Cross-platform Builds: You need to perform the build for each platform on the respective operating system.
Environment Variables: You may need to set environment variables appropriately depending on the production environment.
This guide should help you understand the process of initializing, developing, and building a project using the Pyloid Boilerplate. Backend packaging with PyInstaller simplifies deployment and facilitates dependency management.
Last updated