index.py
#!/usr/local/bin/python3
# Auther: 碳酸氢钠
# Changed by: laman28(LMFS)
# For linux
import os
import time
import sys
def pack(clearVenv=False):
if clearVenv:
os.system("rm -rf pyvenv-easypack")
os.system("rm -rf build")
os.system("rm *.spec")
if(not os.path.isdir("./pyvenv-easypack")):
start_time = time.time()
print('creating pyvenv...')
if os.system('python -m venv ./pyvenv-easypack'):
raise Exception("something wrong happend.")
print(f'pyvenv created successful[{time.time()-start_time}s]')
else:
print("[\033[92;1mINFO\033[0m] Python virtual environment was already in the directory")
if(os.path.exists("./.PYI.insd")):
if(os.path.isfile("./.PYI.insd")):
f=open("./.PYI.insd")
has_pyi=f.read()
if(has_pyi=="1"): has_pyi=True
else: has_pyi=False
else:
os.system("rm -rf ./.PYI.insd")
f=open("./.PYI.insd","w")
has_pyi=False
else:
f=open("./.PYI.insd","w")
has_pyi=False
if(not has_pyi):
start_time = time.time()
print('installing pyinstaller...')
if os.system('pyvenv-easypack/bin/pip install pyinstaller'):
raise Exception("something wrong happend.")
print(f'pyinstaller indtalled successful[{time.time()-start_time}s]')
f.write("1")
f.close()
has_pyi=True
else:
print("[\033[92;1mINFO\033[0m] Pyinstaller was already in pyvenv_easypack/lib")
start_time = time.time()
print("installing other moudels...")
for i in modules:
print("installing:"+i)
if os.system('pyvenv-easypack/bin/pip install '+i):
raise Exception("something wrong happend.")
start_time = time.time()
print('packing '+pyFileName+"...")
pack_command = 'pyvenv-easypack/bin/pyinstaller -F '
if needConsole!="1":pack_command += '-w '
if iconURL!='':pack_command += '-i '+iconURL+' '
if os.system(pack_command+pyFileName):
raise Exception("something wrong happend.")
clearVenv = False
if input("do you want to rebuild pyvenv? yes[1] no[Enter] ") == "1":clearVenv = True
pyFileName = input("input .py file ")
iconURL = input("do you need icon? yes[1] no[Enter] ")
needConsole = input("do you need console? yes[1] no[Enter] ")
haveModules = input("Is there any other moudels? yes[1] no[Enter] ")
modules = []
if(haveModules=="1"):
way_to_pack_modules = input("How do you want to install moudels? manual[1] needn't[Enter] ")
if(way_to_pack_modules == "1"):
i=-1
while True:
modules.append(input("type moudel name. [end] to end."))
i+=1
if modules[i] == '[end]':
break
modules.pop()
else:
print('sorry... But you can\'t use it now.')
start_time = time.time()
pack(clearVenv)
print(f"pack .py file successful\n\
[{time.time()-start_time}s]\n")
README.md
# python-easy-pack For Linux/Unix, Changed by laman28
Original version of windows:
https://github.com/shr-NaHCO3/python-easy-pack
make pack up python files easier.
# How to use it?
1. Install: Download the .zip archive then decompress or use 'git clone https://github.com/Lone-Air/Python-easy-pack-Linux.git' in your terminal
1. open yourterminal
3. cd to your project folder and run `index.py.`
4. input according to requirement.
> attention! If your progmming has other moudels, maybe you need to install them manual.
6. you can find things you wanted in `./dist/`.
# New
1. Program won't always create the python virtual environment
2. Program won't always check for pyinstaller
preview: README.md
python-easy-pack For Linux/Unix, Changed by laman28
Original version of windows:
https://github.com/shr-NaHCO3/python-easy-pack
make pack up python files easier.
How to use it?
- Install: Download the .zip archive then decompress or use 'git clone https://github.com/Lone-Air/Python-easy-pack-Linux.git' in your terminal
- open yourterminal
- cd to your project folder and run
index.py.
- input according to requirement.
attention! If your progmming has other moudels, maybe you need to install them manual.
- you can find things you wanted in
./dist/
.
New
- Program won't always create the python virtual environment
- Program won't always check for pyinstaller