473,545 Members | 1,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2202
wa********@comc ast.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********@comc ast.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_c onfig.db_host, my_config.db_us er...)

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_ho st = "localhost" # default config...

def read_config():
execfile("my_co nfig.py", globals(), my_config.__dic t__)
...
DB.Connect(my_c onfig.db_host, my_config.db_us er...)

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
3955
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 problems. I want to be able to distribute this program using py2exe, but I am having some problems. I am using a simple setup.py like in the...
2
3530
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 call last): File "dbmod.py", line 2, in ? File "odbc.pyo", line 9, in ?
2
2681
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
1208
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 saw it include. These invariably are modules that have been imported using from <modulenameimport * Apparently this confuses py2exe. Well I tried...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.