Re: Compiling Python Programs for Windows Use

  • From: "Jacob Kruger" <jacobk@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 13 Sep 2011 22:53:49 +0200

Well, for standard python scripts, and seeming to work to a certain extent with the bit of wxPython windows GUI I've been playing around with, if you have the right modules installed on your developer machine, like pywin32, py2exe and python itsself, then the following setup.py script will generate the required executable output:

#---start of script---
from glob import glob
from distutils.core import setup
import py2exe
data_files = [
("Microsoft.VC90.CRT", glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))
]
options = {
   "bundle_files": 1,
   "ascii": 1, # to make a smaller executable, don't include the encodings
   "compressed": 1, # compress the library archive
   }

setup(
   # The first three parameters are not required, if at least a
   # 'version' is given, then a versioninfo resource is built from
   # them and added to the executables.
   version = "1.0.0",
   description = "testing",
   name = "helloTest",
   options = {'py2exe': options},

   # targets to build
   console = ["hello.py"],
data_files=data_files
   )
#---end of script---

From command line, in that folder, where the source and this file would be, if I run the following command, it creates a dist subfolder, with the relevant executable and support files in it:
python setup.py py2exe

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Rich De Steno" <ironrock@xxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, September 13, 2011 10:17 PM
Subject: Re: Compiling Python Programs for Windows Use


I never thought it would be so complicated to make an executable in Python. I assumed there would be a standard compiler that would take care of it in a flash as I used to do in the old C DOS days. I know programs for the blind like the screen-reader, NVDA, and the Skype talking interface, SkypeTalking, are both written in Python and widely distributed as Windows executable. My initial reading on Py2exe is discouraging from any notion that this will be simple.


Rich De Steno


On 9/13/2011 12:34 AM, Jacob Kruger wrote:
I've started playing around with it, and you just need to get the right versions, etc. etc., and have a look at the tutorial material relating to the setup.py scripts, etc.

Only thing haven't really done with it thus far is try out too many target versions of windows to see where it will all run, and the one other thing is it seems to want you to also have something like VS.Net 2008 installed to get copies of the C++ runtime libraries included in outgoing dist folder, but anyway.

http://www.py2exe.org/index.cgi/Tutorial

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Rich De Steno" <ironrock@xxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, September 13, 2011 2:48 AM
Subject: Compiling Python Programs for Windows Use


I am just getting into Python. I have read that to compile a program for distribution, for Windows use you can use a compiler called Py2exe. First, is this the best way to compile a Python program? Second, is easily downloaded from a particular web site? I cannot get Source Forge to download it. If there is abetter way to compile, please let me know. Thanks.


Rich De Steno

--
Rich De Steno

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: