473,322 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Import PY file not included in py2exe executable

I am using py2exe to generate an executable so that I can deliver my
scripts as a EXE. I have a couple of file that are needed by the
program that I do not want to include in the EXE because they are used
for program configuration (similar to the way an INI file is used.)
These file may change per installation, so I may need to edit them.
Having them wrapped up in the EXE just won't work for my needs.

I've used the 'exclude' option to keep them from being included in the
EXE. I'm also using 'zipfile=None' so that all of the other pys are
included in the EXE. So, when I deliver the EXE all I should have in
my installation directory is:

MyProgram.exe
config1.py
config2.py
<misc Python pyds>

Is this possible? What is the setup.py configuration for this?

Oct 4 '07 #1
2 2189
wa********@comcast.net wrote:
I am using py2exe to generate an executable so that I can deliver my
scripts as a EXE. I have a couple of file that are needed by the
program that I do not want to include in the EXE because they are used
for program configuration (similar to the way an INI file is used.)
These file may change per installation, so I may need to edit them.
Having them wrapped up in the EXE just won't work for my needs.

I've used the 'exclude' option to keep them from being included in the
EXE. I'm also using 'zipfile=None' so that all of the other pys are
included in the EXE. So, when I deliver the EXE all I should have in
my installation directory is:

MyProgram.exe
config1.py
config2.py
<misc Python pyds>

Is this possible? What is the setup.py configuration for this?
I've found that using Inno Installer to package all the "other" stuff that I
need works EXTREMELY well. I almost always need .INI file, HISTORY.TXT,
README.TXT, icons, etc. Inno also allows me to ship a single setup.exe file
that can install my program, make registry entries (if needed), create
shortcuts, etc. The time I spend installing and learning Inno has paid for
itself many times over.

FYI, Larry
Oct 4 '07 #2
On Thu, Oct 04, 2007 at 10:15:59AM -0700, wa********@comcast.net wrote:
... because they are used for program configuration ...
not sure if i completely understood but i guess you do something like
that:

my_config.py:
db_host = "mydbserver"
db_user = "root"
...

and in your program.py you have:
import my_config
...
DB.Connect(my_config.db_host, my_config.db_user...)

and your problem is that py2exe will package that my_config.py so that
"noone" can change it afterwards...

one possibility i often use is execfile:
same my_config as above, but:
program.py:
class config_class:
pass
my_config = config_class()
my_config.db_host = "localhost" # default config...

def read_config():
execfile("my_config.py", globals(), my_config.__dict__)
...
DB.Connect(my_config.db_host, my_config.db_user...)

so you can always call read_config() to re-read the configuration and have
all python features in that config file. (additionally you can catch
exceptions and check the config files' mtime if it has changed...)

that way py2exe won't care about your config file...

hope it helps...

--

Florian Schmidt
Oct 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brian Hlubocky | last post by:
I'm have a fairly simple (in terms of COM) python program that pulls info from an Access database and creates Outlook contacts from that information. It uses wxPython for gui and works without...
2
by: Marc Ederis | last post by:
Hello, I'm trying to create an executable with py2exe, and it uses the odbc module. The script runs fine until I use py2exe on it and run the ..exe. Then I get: -- Traceback (most recent...
2
by: flupke | last post by:
Hi, i have a program with is built like this: startup.py dir1/__init__.py dir1/file1.py dir2/__init__.py dir2/file2.py dir3/__init__.py dir3/file3.py
1
by: Paul Sijben | last post by:
I am trying to turn my application into a WinXP exe. Py2exe has packaged all my files up into one humongous executable. When trying to run the app, it complains that it can not find modules I just...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.