Skip to content

Commit bb250bd

Browse files
Merge pull request #32 from pythonlover02/next
Update the build scripts and add make-release.sh
2 parents b2b9eb8 + 3d11991 commit bb250bd

File tree

6 files changed

+135
-27
lines changed

6 files changed

+135
-27
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ __pycache__/
1010
.Python
1111
build/
1212
py_env/
13-
release/
13+
bin/
14+
releases/
1415
develop-eggs/
1516
dist/
1617
downloads/

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ If this software is not provided, its options will be locked.
136136

137137
Using Pyinstaller:
138138
```bash
139-
./build-pyinstaller.sh
139+
./make-pyinstaller.sh
140140
```
141141

142142
Using Nuitka:
143143
```bash
144-
./build-nuitka.sh
144+
./make-nuitka.sh
145145
```
146146

147147
*Note: Both use a Python virtual environment to avoid system wide package installation using pip*
@@ -220,8 +220,8 @@ volt flatpak run net.pcsx2.PCSX2
220220

221221
## Render Selector explained:
222222

223-
- `Select OpenGL Renderer (Mesa)` Selects the GPU/Renderer that will be used to render OpenGL programs. Those GPUs are obtained trough `glxinfo`.
224-
- `Select Vulkan Renderer` Selects the GPU/Renderer that will be used to render Vulkan programs. Those GPUs are obtained trough `vulkaninfo`, also for this to work on some distros you might need to install some additional dependencies like `vulkan-mesa-layers` on Arch Linux.
223+
- `Select OpenGL Renderer` Selects the GPU/Renderer that will be used to render OpenGL programs. Those GPUs are obtained trough `glxinfo`.
224+
- `Select Vulkan Renderer` Selects the GPU/Renderer that will be used to render Vulkan programs. Those GPUs are obtained trough `vulkaninfo`, also for this to work on some distros you might need to install some additional dependencies like `vulkan-mesa-layers` on Arch Linux. More info its provided on the Welcome Window that opens once you open volt-gui.
225225

226226
## Technical References:
227227

install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ fi
1111

1212
# Configuration
1313
INSTALL_DIR="/usr/local/bin"
14-
RELEASE_DIR="release"
15-
EXECUTABLE="$RELEASE_DIR/volt-gui"
14+
BIN_DIR="bin"
15+
EXECUTABLE="$BIN_DIR/volt-gui"
1616
HELPER_SCRIPT="scripts/volt-helper"
1717
DESKTOP_FILE="/usr/share/applications/volt-gui.desktop"
1818

19-
# Check release directory
20-
if [[ ! -d "$RELEASE_DIR" ]]; then
21-
echo -e "\033[31mError: Release directory not found. Run build.sh first.\033[0m" >&2
19+
# Check bin directory
20+
if [[ ! -d "$BIN_DIR" ]]; then
21+
echo -e "\033[31mError: bin directory not found. Run make-pyinstaller.sh or make-nuitka.sh first.\033[0m" >&2
2222
exit 1
2323
fi
2424

2525
# Check main executable
2626
if [[ ! -f "$EXECUTABLE" ]]; then
27-
echo -e "\033[31mError: Executable 'volt-gui' not found in release directory. Run build.sh first.\033[0m" >&2
27+
echo -e "\033[31mError: Executable 'volt-gui' not found in bin directory. Run make-pyinstaller.sh or make-nuitka.sh first.\033[0m" >&2
2828
exit 1
2929
fi
3030

build-nuitka.sh renamed to make-nuitka.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ VENV_DIR="py_env"
1515
REQ_FILE="requirements.txt"
1616
REQ_HASH_FILE="$VENV_DIR/requirements.sha256"
1717
SRC_FILE="src/volt-gui.py"
18-
RELEASE_DIR="release"
18+
BIN_DIR="bin"
1919
BASE_FILENAME=$(basename "$SRC_FILE" .py)
2020

2121
# Nuitka options for the application
@@ -83,10 +83,10 @@ build_executable() {
8383
fi
8484
}
8585

86-
# Move to release directory
87-
move_to_release() {
88-
mkdir -p "$RELEASE_DIR"
89-
mv "$BASE_FILENAME" "$RELEASE_DIR/" 2>/dev/null || true
86+
# Move to bin directory
87+
move_to_bin() {
88+
mkdir -p "$BIN_DIR"
89+
mv "$BASE_FILENAME" "$BIN_DIR/" 2>/dev/null || true
9090
}
9191

9292
# Main execution
@@ -102,14 +102,14 @@ main() {
102102

103103
update_dependencies
104104
build_executable
105-
move_to_release
105+
move_to_bin
106106

107107
echo -e "\n${GREEN}Build successful!${NC}"
108-
echo -e "Executable: ${YELLOW}$RELEASE_DIR/$(basename "$BASE_FILENAME")${NC}"
108+
echo -e "Executable: ${YELLOW}$BIN_DIR/$(basename "$BASE_FILENAME")${NC}"
109109

110110
# Show file size
111111
if command -v du &> /dev/null; then
112-
local size=$(du -h "$RELEASE_DIR"/* 2>/dev/null | cut -f1 || echo "Unknown")
112+
local size=$(du -h "$BIN_DIR"/* 2>/dev/null | cut -f1 || echo "Unknown")
113113
echo -e "File size: ${YELLOW}$size${NC}"
114114
fi
115115
}

build-pyinstaller.sh renamed to make-pyinstaller.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ VENV_DIR="py_env"
1515
REQ_FILE="requirements.txt"
1616
REQ_HASH_FILE="$VENV_DIR/requirements.sha256"
1717
SRC_FILE="src/volt-gui.py"
18-
RELEASE_DIR="release"
18+
BIN_DIR="bin"
1919
BASE_FILENAME=$(basename "$SRC_FILE" .py)
2020
SPEC_FILE="$BASE_FILENAME.spec"
2121

@@ -82,10 +82,10 @@ build_executable() {
8282
fi
8383
}
8484

85-
# Move to release directory
86-
move_to_release() {
87-
mkdir -p "$RELEASE_DIR"
88-
mv "dist/$BASE_FILENAME" "$RELEASE_DIR/" 2>/dev/null || true
85+
# Move to bin directory
86+
move_to_bin() {
87+
mkdir -p "$BIN_DIR"
88+
mv "dist/$BASE_FILENAME" "$BIN_DIR/" 2>/dev/null || true
8989
}
9090

9191
# Main execution
@@ -101,14 +101,14 @@ main() {
101101

102102
update_dependencies
103103
build_executable
104-
move_to_release
104+
move_to_bin
105105

106106
echo -e "\n${GREEN}Build successful!${NC}"
107-
echo -e "Executable: ${YELLOW}$RELEASE_DIR/$BASE_FILENAME${NC}"
107+
echo -e "Executable: ${YELLOW}$BIN_DIR/$BASE_FILENAME${NC}"
108108

109109
# Show file size
110110
if command -v du &> /dev/null; then
111-
local size=$(du -h "$RELEASE_DIR"/* 2>/dev/null | cut -f1 || echo "Unknown")
111+
local size=$(du -h "$BIN_DIR"/* 2>/dev/null | cut -f1 || echo "Unknown")
112112
echo -e "File size: ${YELLOW}$size${NC}"
113113
fi
114114
}

make-release.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
# Exit immediately on errors, unset variables, and pipe failures
3+
set -euo pipefail
4+
5+
# Color definitions
6+
RED='\033[0;31m'
7+
GREEN='\033[0;32m'
8+
YELLOW='\033[1;33m'
9+
CYAN='\033[0;36m'
10+
NC='\033[0m' # No Color
11+
12+
# Configuration
13+
RELEASE_DIR="releases"
14+
PYINSTALLER_BUILD="volt-gui-pyinstaller"
15+
NUITKA_BUILD="volt-gui-nuitka"
16+
BUILD_SCRIPTS=("make-pyinstaller.sh" "make-nuitka.sh")
17+
18+
# Cleanup function
19+
cleanup() {
20+
# Remove any temporary files if needed
21+
true
22+
}
23+
24+
# Check for required commands
25+
check_commands() {
26+
local commands=("tar" "cp" "mkdir")
27+
for cmd in "${commands[@]}"; do
28+
if ! command -v "$cmd" &> /dev/null; then
29+
echo -e "${RED}Error: Required command '$cmd' not found${NC}" >&2
30+
exit 1
31+
fi
32+
done
33+
}
34+
35+
# Execute build script and copy artifacts
36+
build_and_copy() {
37+
local build_script=$1
38+
local target_dir=$2
39+
40+
echo -e "${CYAN}Executing build script: $build_script${NC}"
41+
# Run build script from the project root directory
42+
if ! (cd .. && ./"$build_script"); then
43+
echo -e "${RED}Error: Build script $build_script failed${NC}" >&2
44+
exit 1
45+
fi
46+
47+
echo -e "${CYAN}Copying artifacts to $target_dir${NC}"
48+
mkdir -p "$target_dir"
49+
50+
# Copy required files and directories from project root
51+
for item in bin install.sh remove.sh scripts; do
52+
if [[ -e "../$item" ]]; then
53+
cp -r "../$item" "$target_dir/"
54+
else
55+
echo -e "${YELLOW}Warning: $item not found, skipping${NC}"
56+
fi
57+
done
58+
}
59+
60+
# Compress directory
61+
compress_release() {
62+
local dir_name=$1
63+
echo -e "${CYAN}Compressing $dir_name to ${dir_name}.tar.gz${NC}"
64+
tar -czf "${dir_name}.tar.gz" "$dir_name"
65+
}
66+
67+
# Main execution
68+
main() {
69+
trap cleanup EXIT
70+
check_commands
71+
72+
# Store the original directory
73+
ORIGINAL_DIR=$(pwd)
74+
75+
# Remove and recreate release directory
76+
echo -e "${CYAN}Preparing release directory...${NC}"
77+
rm -rf "$RELEASE_DIR"
78+
mkdir -p "$RELEASE_DIR"
79+
cd "$RELEASE_DIR"
80+
81+
# Process PyInstaller build
82+
echo -e "\n${YELLOW}=== Processing PyInstaller Build ===${NC}"
83+
build_and_copy "${BUILD_SCRIPTS[0]}" "$PYINSTALLER_BUILD"
84+
compress_release "$PYINSTALLER_BUILD"
85+
86+
# Process Nuitka build
87+
echo -e "\n${YELLOW}=== Processing Nuitka Build ===${NC}"
88+
build_and_copy "${BUILD_SCRIPTS[1]}" "$NUITKA_BUILD"
89+
compress_release "$NUITKA_BUILD"
90+
91+
# Return to original directory
92+
cd "$ORIGINAL_DIR"
93+
94+
echo -e "\n${GREEN}Release build completed successfully!${NC}"
95+
echo -e "Created archives in ${YELLOW}$RELEASE_DIR${NC}:"
96+
echo -e " ${YELLOW}${PYINSTALLER_BUILD}.tar.gz${NC}"
97+
echo -e " ${YELLOW}${NUITKA_BUILD}.tar.gz${NC}"
98+
99+
# Show archive sizes
100+
if command -v du &> /dev/null; then
101+
echo -e "\nArchive sizes:"
102+
du -h "$RELEASE_DIR"/*.tar.gz | sed 's/^/ /'
103+
fi
104+
}
105+
106+
# Run main function
107+
main

0 commit comments

Comments
 (0)