Skip to content

Commit 7897e90

Browse files
committed
0.23
1 parent 16c2043 commit 7897e90

10 files changed

+932
-0
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<h1 align="center" name="binpython">BINPython</h1>
2+
<p align="center">
3+
<em>Lightweight and small portable Python, build with pyinstaller
4+
</em>
5+
</p>
6+
<p align="center">
7+
8+
![Github stars](https://img.shields.io/github/stars/xingyujie/binpython.svg)
9+
![Discord](https://img.shields.io/badge/Discord-https://discord.gg/dz9HwwdSXh-green)
10+
![telegram](https://img.shields.io/badge/Telegram-@binpython-blue)
11+
![pyver](https://img.shields.io/badge/PythonVersion-<3.5-green)
12+
![license](https://img.shields.io/badge/LICENSE-AGPL--3.0-brightgreen)
13+
![author](https://img.shields.io/badge/Author-xingyujie-orange)
14+
### Discord: https://discord.gg/dz9HwwdSXh
15+
### Telegram: @binpython
16+
### Twitter: xyj_offical
17+
# Why BINPython?
18+
19+
Because:
20+
* no edit to registry
21+
* no extra .dlls(only a single executable)
22+
* licensed with AGPL-V3.0
23+
* Easy to integrate into any program, allowing any .py file to run without compiling to an executable
24+
* Built-in portable IDE environment, you can enjoy the highlighted standardized IDE without downloading additional IDE
25+
* Built-in portable http server for fast file transfer
26+
* Built-in tkinter and turtle GUI form application framework to quickly build compile-free form applications
27+
* Built-in dynamic website running framework such as tornado pywebio, the server is carried with you
28+
* Support to encapsulate any library into BINPython, take it with you wherever you go
29+
* The program occupies a small storage space, only about 10mb
30+
* If you need commercial use, please contact us for authorization
31+
# Usage
32+
```
33+
-h --help View this help
34+
-f <filename> --file=<filename> Enter Python Filename and run (*.py)
35+
-s <port> --server=<port> Start a simple web server that supports html and file transfer (http.server)
36+
-v --version View BINPython Version
37+
-g --gui View GUI About and build info
38+
-i --idle Open BINPython IDLE Code Editor
39+
-p --plus Open BINPython IDE Plus Code Editor(beta) with http web server
40+
```
41+
# Build
42+
43+
1. Clone this project
44+
```bash
45+
git clone https://github.com/xingyujie/binpython
46+
cd binpython
47+
```
48+
2. Install Python, pip and the pyinstaller environment
49+
```bash
50+
pip install pyinstaller
51+
```
52+
3. choose BINPython version to build
53+
The standard version is for integration into programs. It is recommended to use the ideplus version for learning
54+
55+
## Build BINPthon Standard version
56+
Compile with basic pyinstaller, e.g.(Only standard version(binpython.py))
57+
```bash
58+
pyinstaller -F binpython.py
59+
```
60+
## Build BINPthon ideplus version
61+
(Only ideplus version (binpython-ideplus.py)
62+
63+
Windows: double-click "buildwin.bat"
64+
65+
Linux: Go to terminal and run "buildlinux.sh" bash script
66+
67+
(You can also use more compilation parameters, see pyinstaller documentation for details)
68+
69+
4. Switch to the dist directory and find the compiled executable file, such as exe or bin file
70+
# Use
71+
Under most Unix-like systems, run "./binpython" to run, double-click to run under Windows

binpython-ideplus.py

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
"""
2+
@header binpython.py
3+
@author xingyujie https://github.com/xingyujie
4+
@abstract BINPython main file
5+
"""
6+
#BINPython By:XINGYUJIE AGPL-V3.0 LICENSE Release
7+
#Please follow the LICENSE AGPL-V3
8+
#ide plus version
9+
####################################
10+
#build configure
11+
12+
ver="0.20-releases"
13+
14+
libs_warning="1"
15+
#1 is ture 0 is false.
16+
#Changing the value to 0 will close the prompt that the library does not exist
17+
18+
releases_ver="offical-with-ideplus"
19+
importlibs="os" #Don't use "import xxx"
20+
#Imported library name, please use "importlibs="<library name>" instead of "import <library name>"
21+
#Please note: The "importlibs" function does not support loading functions (such as from xxxx import xxxx, if necessary, please write it in the following location. However, please note that this operation may have the risk of error reporting, please report issues or solve it yourself
22+
#xxxxxxxxxxxxxx
23+
24+
#from xxxx import xxxx
25+
#xxxxxxxxxxxxxx
26+
####################################
27+
import ctypes
28+
ctypes.windll.kernel32.SetConsoleTitleW("BINPython " + ver)
29+
def self_import(name):
30+
__import__(name)
31+
try:
32+
self_import(importlibs)
33+
except ImportError:
34+
if libs_warning == "1":
35+
print("Warning: Custom import library %s does not exist, please check the source code library configuration and rebuild" % importlibs)
36+
print("")
37+
try:
38+
#base import
39+
import getopt
40+
import sys
41+
import platform
42+
import os
43+
#fix for exit()
44+
from sys import exit
45+
#import for http_server
46+
import http.server
47+
import socketserver
48+
#except ImportError:
49+
except ImportError:
50+
print("Unable to use any library, the program does not work properly, please rebuild")
51+
#gui import
52+
try:
53+
import tkinter
54+
import tkinter as tk
55+
from tkinter import *
56+
import turtle
57+
#warning for gui
58+
except ImportError:
59+
if libs_warning == "1":
60+
print("Warning: Some GUI (graphical) libraries for BINPython do not exist, such as tkinter and turtle. Because they are not built when they are built. If you need to fix this warning, please complete the support libraries imported in the source code at build time (use pip or build it yourself), if your system does not support these libraries, you can remove or change this hint in the source code and rebuild")
61+
print("")
62+
63+
#import math
64+
try:
65+
import fractions
66+
import cmath
67+
except ImportError:
68+
if libs_warning == "1":
69+
print("Warning: Some math or computation libraries for BINPython do not exist, such as fractions and cmath. Because they weren't built when they were built. If you need to fix this warning, please complete the support libraries imported in the source code when building (use pip or build it yourself), if your system does not support these libraries, you can remove or change this prompt in the source code and rebuild")
70+
print("")
71+
#rlcompleter
72+
#import for normal
73+
try:
74+
#str
75+
import rlcompleter
76+
import array
77+
except ImportError:
78+
if libs_warning == "1":
79+
print("Warning: Some libraries for functions, data types, etc. for BINPython do not exist, such as rlcomplter and array. Because they weren't built when they were built. If you need to fix this warning, please complete the support libraries imported in the source code when building (use pip or build it yourself), if your system does not support these libraries, you can remove or change this prompt in the source code and rebuild")
80+
print("")
81+
try:
82+
import filecmp
83+
import tempfile
84+
except ImportError:
85+
if libs_warning == "1":
86+
print("Warning: Some file manipulation libraries for BINPython do not exist, such as filecmp and tempfile. Because they weren't built when they were built. If you need to fix this warning, please complete the support libraries imported in the source code when building (use pip or build it yourself), if your system does not support these libraries, you can remove or change this prompt in the source code and rebuild")
87+
print("")
88+
#def
89+
def help():
90+
print("[*] BINPython Help")
91+
print("""
92+
-h --help View this help
93+
-f <filename> --file=<filename> Enter Python Filename and run (*.py)
94+
-s <port> --server=<port> Start a simple web server that supports html and file transfer (http.server)
95+
-v --version View BINPython Version
96+
-g --gui View GUI About and build info
97+
-i --idle Open BINPython IDLE Code Editor
98+
-p --plus Open BINPython IDE Plus Code Editor(beta) with http web server
99+
""")
100+
about = "BINPython " + ver + "-" + releases_ver + " By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release"
101+
#getopt
102+
try:
103+
opts,args = getopt.getopt(sys.argv[1:],'-h-f:-s:-g-i-p-v',['help','file=','server=','gui','idle','plus','version'])
104+
except:
105+
print("Please check help:")
106+
help()
107+
print("The parameters you use do not exist or are not entered completely, please check help! ! ! ! !")
108+
for opt_name,opt_value in opts:
109+
if opt_name in ('-h','--help'):
110+
help()
111+
sys.exit()
112+
if opt_name in ('-v','--version'):
113+
print("BINPython " + ver + "-" + releases_ver + " By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release")
114+
print("Python " + platform.python_version())
115+
exit()
116+
if opt_name in ('-f','--file'):
117+
file = opt_value
118+
f = open(file,encoding = "utf-8")
119+
exec(f.read())
120+
input("Please enter to continue")
121+
sys.exit()
122+
if opt_name in ('-s','--server'):
123+
server_port = opt_value
124+
print("""
125+
PORT = """ + server_port + """
126+
127+
Handler = http.server.SimpleHTTPRequestHandler
128+
129+
with socketserver.TCPServer(("", PORT), Handler) as httpd:
130+
print("serving at port", PORT)
131+
httpd.serve_forever()
132+
""")
133+
if opt_name in ('-g','--gui'):
134+
from tkinter import *
135+
root = Tk()
136+
root.title("Welcome to BINPython")
137+
root.geometry('600x300')
138+
text =Text(root, width=35, heigh=15)
139+
text.pack()
140+
text.insert("insert", "BINPython" + about)
141+
print(text.get("1.3", "1.end"))
142+
####
143+
text=Label(root,text="Welcome to BINPython" + ver,bg="yellow",fg="red",font=('Times', 20, 'bold italic'))
144+
text.pack()
145+
button=Button(root,text="EXIT",command=root.quit)
146+
button.pack(side="bottom")
147+
root.mainloop()
148+
sys.exit()
149+
def show():
150+
os.system('cls' if os.name == 'nt' else 'clear')
151+
print("<<<<<<<<<<START>>>>>>>>>>")
152+
exec(e1.get(1.0, END))
153+
if opt_name in ('-i','--idle'):
154+
import tkinter as tk
155+
from tkinter import *
156+
import os
157+
master = tk.Tk()
158+
master.title("BINPython IDLE")
159+
160+
161+
tk.Label(master, text="Type Code", height=5).grid(row=0)
162+
163+
e1 = Text(master,
164+
width=150,
165+
height=40,)
166+
167+
e1.grid(row=0, column=1, padx=10, pady=5)
168+
tk.Button(master, text="Run", width=10, command=show).grid(row=3, column=0, sticky="w", padx=10, pady=5)
169+
tk.Button(master, text="EXIT", width=10, command=master.quit).grid(row=3, column=1, sticky="e", padx=10, pady=5)
170+
master.mainloop()
171+
if opt_name in ('-p','--plus'):
172+
serverport = input("Please enter server port(like 8080): ")
173+
import pywebio.input
174+
from pywebio.input import *
175+
from pywebio.output import *
176+
from pywebio import *
177+
from pywebio.session import *
178+
import sys
179+
import subprocess
180+
import os
181+
print("______________________________________")
182+
print("BINPython WEB IDE STARTED")
183+
#IDE Plus main
184+
def main():
185+
set_env(title="BINPython IDE Plus", auto_scroll_bottom=True)
186+
put_html("<h1>BINPython IDE Plus</h1>")
187+
put_text('Welcome to BINPython IDE Plus, Please type code',
188+
sep=' '
189+
)
190+
toast("BINPython IDE Plus is a beta version. May be removed or changed in the future")
191+
put_text('_______________________',
192+
sep=' '
193+
)
194+
res = textarea('BINPython IDE Plus', rows=45, code={
195+
'mode': "python",
196+
'theme': 'darcula'
197+
})
198+
exec(res)
199+
toast("Run finished!")
200+
put_success("Finished, Please see BINPython Window or Terminal")
201+
put_text("Here is the code you wrote")
202+
put_code(res, language='python')
203+
savecodefilename = pywebio.input.input('Do you want to save the code you wrote to a file? Enter a filename and save it')
204+
f = open(savecodefilename, 'wb+')
205+
f.write(res.encode("utf-8"))
206+
toast("Successfully saved")
207+
put_success("The save is successful, and the code is saved to binpython file path" + " \nThe file name is " + '"' + savecodefilename + '"')
208+
if __name__ == '__main__':
209+
start_server(main, debug=True, host='0.0.0.0', port= serverport)
210+
pywebio.session.hold()
211+
212+
213+
#main BINPython
214+
215+
print("BINPython " + ver + "-" + releases_ver + " (Python Version:" + platform.python_version() + ")By:XINGYUJIE https://github.com/xingyujie/binpython[Running on " + platform.platform() + " " + platform.version() + "]")
216+
print('Type "about", "help", "copyright", "credits" or "license" for more information.')
217+
try:
218+
while True:
219+
pycmd=input(">>> ")
220+
if pycmd in globals().keys():
221+
print(globals()[pycmd])
222+
continue
223+
elif pycmd == 'about':
224+
print("BINPython By:XINGYUJIE[https://github.com/xingyujie] AGPL-3.0 LICENSE Release")
225+
elif pycmd == 'help':
226+
print("Type help() for interactive help, or help(object) for help about object.")
227+
elif pycmd == 'copyright':
228+
print("""
229+
Copyright (c) 2001-2022 Python Software Foundation and BINPython xingyujie(https://github.com/xingyujie/binpython).
230+
All Rights Reserved.
231+
232+
Copyright (c) 2000 BeOpen.com.
233+
All Rights Reserved.
234+
235+
Copyright (c) 1995-2001 Corporation for National Research Initiatives.
236+
All Rights Reserved.
237+
238+
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
239+
All Rights Reserved.
240+
""")
241+
elif pycmd == 'credits':
242+
print("""
243+
Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
244+
for supporting Python development. See www.python.org for more information.
245+
""")
246+
elif pycmd == 'license':
247+
print("Type license() to see the full license text")
248+
try:
249+
exec(pycmd)
250+
except Exception as err:
251+
print(err)
252+
except KeyboardInterrupt:
253+
print("EXIT!")
254+
sys.exit()
255+

binpython-ideplus.spec

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
block_cipher = None
5+
from pywebio.utils import pyinstaller_datas
6+
7+
a = Analysis(['binpython-ideplus.py'],
8+
pathex=[],
9+
binaries=[],
10+
datas=pyinstaller_datas(),
11+
hiddenimports=[],
12+
hookspath=[],
13+
hooksconfig={},
14+
runtime_hooks=[],
15+
excludes=[],
16+
win_no_prefer_redirects=False,
17+
win_private_assemblies=False,
18+
cipher=block_cipher,
19+
noarchive=False)
20+
pyz = PYZ(a.pure, a.zipped_data,
21+
cipher=block_cipher)
22+
23+
exe = EXE(pyz,
24+
a.scripts,
25+
a.binaries,
26+
a.zipfiles,
27+
a.datas,
28+
[],
29+
name='binpython-ideplus',
30+
debug=False,
31+
bootloader_ignore_signals=False,
32+
strip=False,
33+
upx=True,
34+
upx_exclude=[],
35+
runtime_tmpdir=None,
36+
console=True,
37+
disable_windowed_traceback=False,
38+
target_arch=None,
39+
codesign_identity=None,
40+
entitlements_file=None,
41+
icon='C:/Users/xingy/Documents/GitHub/binpython/py.ico')

0 commit comments

Comments
 (0)