472,343 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,343 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 2135
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...
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...
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...
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,...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.