*Newbie Question* --> Is it viable to distribute Python apps over the Internet?
Dennis Reinhardt
DennisR at dair.com
Thu Apr 24 16:51:30 EDT 2003
> Yes, I read your post. You said you did some kind of manual hack to
> package your app,
I have posted a 390 KB starter Python Hello World that runs on a Windows
computer without Python at: http://www.spamai.com/hello/hello.zip.
Decompress to a directory and click on runmain.bat. The runmain.bat file
contains:
bin\python.exe bin\main.py
exit
The main.py program is not too complicated either:
import sys
sys.path = [".", ".\\bin", ".\\bin\\libstd", ".\\bin\\libxtra"]
import os
def write_file_basic (filepath, filecontents):
emfile_open_flags = os.O_WRONLY+os.O_CREAT+os.O_TRUNC+os.O_BINARY
emf = os.open(filepath, emfile_open_flags)
os.write(emf, filecontents)
os.close(emf)
html= """<html>
<head><title>Hello from Python</title></head>
<body bgcolor=#e8fbfe>
<h1>Sss...</h1>(how Pythons say "hello")<p>
current directory: %s
</body></html>
""" % os.getcwd()
write_file_basic("hello.html", html)
os.startfile("hello.html")
sys.exit(0)
The path bin/libstd contains the library files needed to import os. If you
call more functions, add to path bin/libstd or bin/libxtra.
Writing an html file and then shelling to it is just to get started. For my
own app, I wrote a socket-level http server and call that.
Maintaining this "manual hack" is far less effort than you would guess. I
have not had to revise the library files I use for months now. It is very
clear when one is missing and what needs to be added.
> but clearly you have some system for your web page
> packager (neat, BTW :-), which you didn't specify.
Errr..., that's right, I didn't specify how I did it. I have abandoned this
particular approach myself and describing what is going on is tough There
is lots of non-portable stuff in there.
Instead, I have posted code for the approach I am actually using above.
The general approach for the web page is that I coded a stub in my own
compiler language (www.pld2.com) which embedded python and library code. At
run time, this is extracted from the exe and run. The exe file has internal
pointers which the online Perl code can use to patch the stub code to
produce a custom exe. Cross-program dependencies abound.
> So, does your thing work better on space than the alternatives? Maybe
> it's worth making it available if so...
Yes 390 KB is smaller than any other solution I am aware of. I just have
made it available. Thanks for you interest.
Oh, btw, I made a zip file available above because lots of people can access
this format. The same file compressed with WinRar in rar format is about 80
KB smaller. WinRar provides a self-extracting format also.
--
Dennis Reinhardt
DennisR at dair.com http://www.spamai.com?ng_clp
More information about the Python-list
mailing list