[Arch] fix network, delete bar_scripts
[dotfiles_afify.git] / .scripts / py_exe.sh
blobefa90942beeaeb0ebbeb57c51fb80db03aa9b28b
1 #!/usr/bin/env bash
2 # This script encode a python script with base64 and generate exe file
4 random_string1=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 128 ; echo '')
5 random_string2=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 128 ; echo '')
6 random_string3=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12 ; echo '')
8 icon_path='final_wolf_tzh_icon.ico'
9 version_file='spec.txt'
11 python_src_without_extention='hello_world'
12 python_src_file=$python_src_without_extention.py
13 python_src_file_content=$(cat $python_src_file | base64)
15 decoder_template="import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('$python_src_file_content')))"
17 tmp_file_name=/tmp/$random_string3.py
18 final_file=$python_src_without_extention.exe
20 # echo $python_src_file_content
21 # echo $decoder_template
22 # echo
23 # python -c "$decoder_template"
24 echo "#$random_string1
25 $decoder_template
26 #$random_string2
27 " > $tmp_file_name
29 pyinstaller --onefile --nowindowed --noconsole --icon=$icon_path --version-file=$version_file $tmp_file_name