How to generate a "exe" file with py2exe supporting gettext.
What Objects are Involved
py2exe can be obtained from this site.
Just see how little is needed
The following are sample setup files for py2exe, they are located in your application directory. Should you use Boa Constructor you will then get additional options in the File menu when editing the setup.py file, e.g. if you select File/setup.py py2exe your "exe" will be generated in a "dist" directory.
setup.cfg code sample
Create a file "setup.cfg" in your program directory along the lines of the following example.
- The package "encodings" is included below to prevent some errors when trying to run the "exe" on Python 2.3
- The package "kinterbasdb" is what I use for database access.
1 #distutils config file for a little application 2 3 [py2exe] 4 packages = encodings, kinterbasdb 5 force_imports = encodings 6 7 # we don't use docstrings at runtime, so we may as well prune them... 8 optimize=2 9 10 # version information 11 version_companyname = which ever 12 version_filedescription = the little application name 13 version_fileversion = 0.1.0 14 version_legalcopyright = Hmm... 15 version_legaltrademarks = blah blah 16 version_productname = the little applications product name 17 version_productversion = 0.1.0
setup.py code sample
Create a file "setup.py" in your program directory along the lines of the following example.
- The translation files (.mo) have to be defined in the "data_files" section, one entry for each language. I used the "ivcm" name for the domain as has been done on the other I18n pages.
1 # -*- coding: iso-8859-1 -*-# 2 from distutils.core import setup 3 import py2exe 4 5 setup(name="the application name", 6 scripts=["ivcm.py"], 7 data_files=[("locale\\fr\\LC_MESSAGES", 8 ["c:\\dev\\ivcm\\program\\locale\\fr\\LC_MESSAGES\\ivcm.mo"]), 9 ("locale\\en\\LC_MESSAGES", 10 ["c:\\dev\\ivcm\\program\\locale\\en\\LC_MESSAGES\\ivcm.mo"])], 11 )
Please feel free to provide any type of feedback on this page to me at [email@example.com]