Compiles Python to an exe
Project description
python-compile
Compile python apps to linux executables
This project will use docker to compile your one file python app into a binary that's runnable on many linux systems. Work in progress remains for building windows apps via the docker system.
To develop software, run . ./activate.sh
Example
python-compile --os debian --input demo_http_server.py --requirements requirements.txt
demo_http_server.py
from http.server import CGIHTTPRequestHandler, SimpleHTTPRequestHandler, ThreadingHTTPServer
import socket
import argparse
import os
from http.server import test
if __name__ == '__main__':
import argparse
import contextlib
parser = argparse.ArgumentParser()
parser.add_argument('--cgi', action='store_true',
help='run as CGI server')
parser.add_argument('--bind', '-b', metavar='ADDRESS',
help='specify alternate bind address '
'(default: all interfaces)')
parser.add_argument('--directory', '-d', default=os.getcwd(),
help='specify alternate directory '
'(default: current directory)')
parser.add_argument('port', action='store', default=8000, type=int,
nargs='?',
help='specify alternate port (default: 8000)')
args = parser.parse_args()
if args.cgi:
handler_class = CGIHTTPRequestHandler
else:
handler_class = SimpleHTTPRequestHandler
# ensure dual-stack is not disabled; ref #38907
class DualStackServer(ThreadingHTTPServer):
def server_bind(self):
# suppress exception when protocol is IPv4
with contextlib.suppress(Exception):
self.socket.setsockopt(
socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
return super().server_bind()
def finish_request(self, request, client_address):
self.RequestHandlerClass(request, client_address, self,
directory=args.directory)
test(
HandlerClass=handler_class,
ServerClass=DualStackServer,
port=args.port,
bind=args.bind,
)
Windows
This environment requires you to use git-bash
.
Linting
Run ./lint.sh
to find linting errors using pylint
, flake8
and mypy
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-compile-1.0.2.tar.gz
(13.8 kB
view hashes)
Built Distribution
Close
Hashes for python_compile-1.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5572f25ad0ba4a3a4f012b35b3ab03ff26db212b41f379de1c0dc8920c4e92ea |
|
MD5 | 3ba2b7fba85b99bb2b877db6e3203c7e |
|
BLAKE2b-256 | 84c383051c91af38d5b37c929b8752d412881b4aa14a3eea44c93fe1705e7fa3 |