469,909 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

Using a package like PyInstaller

Is it possible when using packages like PyInstaller to create an .exe for
distribution that parts of the package can bleed out and be left on a system
when the .exe is executed?

Thx
May 27 '06 #1
8 2239
LittlePython wrote:
Is it possible when using packages like PyInstaller to create an .exe for
distribution that parts of the package can bleed out and be left on a system
when the .exe is executed?

Thx


Look at innosetup.

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
May 27 '06 #2
Thx for the tip.

I am referring more to the use of PyInstaller or py2exe. Packages that
create exe files that basically have your py script and a small py
interpreter all rolled up into one. This way py does not need to be
installed on a system to execute a py script. I am being advised that python
is installed onto systems (windows) it should not be on. I am new to python
and these types of packages and am not too sure how dumb a question this
really is.. but can these packages bleed out files, dll, exe ect. to systems
they are run on?

"James Stroud" <js*****@ucla.edu> wrote in message
news:e5**********@daisy.noc.ucla.edu...
LittlePython wrote:
Is it possible when using packages like PyInstaller to create an .exe for distribution that parts of the package can bleed out and be left on a system when the .exe is executed?

Thx


Look at innosetup.

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/

May 27 '06 #3
LittlePython wrote:
Thx for the tip.

I am referring more to the use of PyInstaller or py2exe. Packages that
create exe files that basically have your py script and a small py
interpreter all rolled up into one. This way py does not need to be
installed on a system to execute a py script. I am being advised that python
is installed onto systems (windows) it should not be on. I am new to python
and these types of packages and am not too sure how dumb a question this
really is.. but can these packages bleed out files, dll, exe ect. to systems
they are run on?


They don't have to "bleed" anything. Everything, including the python
interpreter, and 3rd party libraries can be included in a single
executable. Here is an example script for pyinstaller that rolls
evertyhing into one file (this is what I use to roll up my passerby
program at passerby.souceforge.net):
setenv TEMP temp

set pythonexe='c:/Python23-Enthought/python'
set pbydir='z:/Code/pby/current/'

rm *.pyc

rm -rf ./temp/ ./passerby/
mkdir temp

$pythonexe Configure.py
$pythonexe Makespec.py --onefile --tk --noconsole \
--icon $pbydir/../icons/passerby.ico \
$pbydir/passerby.py passerby/passerby.spec
$pythonexe Build.py passerby/passerby.spec
You can control installation with innosetup.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
May 27 '06 #4
That is very close to what I have being doing, however I was unable to
enclose a bmp or another file for that matter in the exe. I used both DATA
and BINARY key words with no luck. I checked what was in the package and
there were there. I guess for some reason it could not locate then when
executed. I used snap 274 if I remember correctly.

I am not too sure I am explaining my question correctly though. I have not
problem creating and distributing my python/wxpython scripts in exe
(stand-a-lone) except for what I have described above. I am worrying that
when the py script is run I am leaving behind files. That the components of
my stand-alone exe is somehow coming out of the exe (PyInstaller) and being
installed.

My setup exe is not what's is bothering me although I do like the your
suggestion and have just been tinkering with it. It is cool stuff and much
better then what I have been using.

Thx

"James Stroud" <js*****@ucla.edu> wrote in message
news:e5**********@daisy.noc.ucla.edu...
LittlePython wrote:
Thx for the tip.

I am referring more to the use of PyInstaller or py2exe. Packages that
create exe files that basically have your py script and a small py
interpreter all rolled up into one. This way py does not need to be
installed on a system to execute a py script. I am being advised that python is installed onto systems (windows) it should not be on. I am new to python and these types of packages and am not too sure how dumb a question this
really is.. but can these packages bleed out files, dll, exe ect. to systems they are run on?


They don't have to "bleed" anything. Everything, including the python
interpreter, and 3rd party libraries can be included in a single
executable. Here is an example script for pyinstaller that rolls
evertyhing into one file (this is what I use to roll up my passerby
program at passerby.souceforge.net):
setenv TEMP temp

set pythonexe='c:/Python23-Enthought/python'
set pbydir='z:/Code/pby/current/'

rm *.pyc

rm -rf ./temp/ ./passerby/
mkdir temp

$pythonexe Configure.py
$pythonexe Makespec.py --onefile --tk --noconsole \
--icon $pbydir/../icons/passerby.ico \
$pbydir/passerby.py passerby/passerby.spec
$pythonexe Build.py passerby/passerby.spec
You can control installation with innosetup.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/

May 28 '06 #5
LittlePython wrote:
That is very close to what I have being doing, however I was unable to
enclose a bmp or another file for that matter in the exe. I used both DATA
and BINARY key words with no luck. I checked what was in the package and
there were there. I guess for some reason it could not locate then when
executed. I used snap 274 if I remember correctly.
You can include files with innosetup under the [FILES] section. The docs
show how. You can then code absolute paths to these resources in your
code according to the results of 'sys.platform'. If you use the
"--onedir" option, then you may want to look here:

http://pyinstaller.hpcf.upr.edu/docs...ing-data-files

I am worrying that
when the py script is run I am leaving behind files. That the components of
my stand-alone exe is somehow coming out of the exe (PyInstaller) and being
installed.


Im 99.999% confident that this will not happen from the .exe file
generated by pyinstaller (unless you specify--see link above).

However, innosetup will put files in the 'Program Files' directory or
wherever you specify. This would be similar to just about every other
application out there for windows.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
May 28 '06 #6
"Im 99.999% confident that this will not happen from the .exe file
generated by pyinstaller (unless you specify--see link above)."

Well I guess that's about as close as any one can get in this business. I
have been trying to introduce py into our environment, and have opened a few
eyes, however I have been given one restriction. I can not install anything,
leave behind anything or alter anything on a systems ...... period, and as
the saying goes "To error is human but to forgive is not company policy!"

thx for your comments!

"James Stroud" <js*****@ucla.edu> wrote in message
news:e5**********@daisy.noc.ucla.edu...
LittlePython wrote:
That is very close to what I have being doing, however I was unable to
enclose a bmp or another file for that matter in the exe. I used both DATA and BINARY key words with no luck. I checked what was in the package and
there were there. I guess for some reason it could not locate then when
executed. I used snap 274 if I remember correctly.


You can include files with innosetup under the [FILES] section. The docs
show how. You can then code absolute paths to these resources in your
code according to the results of 'sys.platform'. If you use the
"--onedir" option, then you may want to look here:

http://pyinstaller.hpcf.upr.edu/docs...ing-data-files

I am worrying that
when the py script is run I am leaving behind files. That the components of my stand-alone exe is somehow coming out of the exe (PyInstaller) and being installed.


Im 99.999% confident that this will not happen from the .exe file
generated by pyinstaller (unless you specify--see link above).

However, innosetup will put files in the 'Program Files' directory or
wherever you specify. This would be similar to just about every other
application out there for windows.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/

May 28 '06 #7
LittlePython wrote:
"Im 99.999% confident that this will not happen from the .exe file
generated by pyinstaller (unless you specify--see link above)."

Well I guess that's about as close as any one can get in this business. I
have been trying to introduce py into our environment, and have opened a few
eyes, however I have been given one restriction. I can not install anything,
leave behind anything or alter anything on a systems ...... period,

You can always hard-code external resources. For example, first write a
script that makes a module out of one or several jpegs (assuming jpeg
extension is consitently 'jpg':

import binascii

def append_to_jpeg_module(modulename, jpegs):
myjpegs = open('%s.py' % modulename, 'wa')
for jpegname in jpegs:
afile = open('%s.jpg' % jpegname, 'rb')
ajpeg = afile.read()
afile.close()
jpegascii = binascii.b2a_base64(ajpeg)
print jpegascii
myjpegs.write('%s = """%s"""\n\n' % (jpegname, jpegascii))
myjpegs.close()

append_to_jpeg_module('myjpegs', ['logo_sm'])

#heres how you use it
append_to_jpeg_module('myjpegs', ['coolpik1', 'coolpik2', 'anotherpik'])

Now, in your file that needs the jpegs, you can pretend these strings
are files with the cStringIO module, e.g. (pretending 'modulename' above
is 'myjpegs'):

import binascii
import myjpegs
import cStringIO

def get_jpeg_as_opened_file(jpegname, module):
jpegascii = module.__dict__[jpegname]
jpegbin = binascii.a2b_base64(jpegascii)
return cStringIO.StringIO(jpegbin)

# getting that pik
get_jpeg_as_opened_file('coolpik1', myjpegs)
And your company can go on making widgets feeling secure in the fact
that you have not required any extra entries in their file allocation
tables.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
May 28 '06 #8
Thx for the tip ... I'll give it a go
"James Stroud" <js*****@ucla.edu> wrote in message
news:e5**********@daisy.noc.ucla.edu...
LittlePython wrote:
"Im 99.999% confident that this will not happen from the .exe file
generated by pyinstaller (unless you specify--see link above)."

Well I guess that's about as close as any one can get in this business. I have been trying to introduce py into our environment, and have opened a few eyes, however I have been given one restriction. I can not install anything, leave behind anything or alter anything on a systems ...... period,

You can always hard-code external resources. For example, first write a
script that makes a module out of one or several jpegs (assuming jpeg
extension is consitently 'jpg':

import binascii

def append_to_jpeg_module(modulename, jpegs):
myjpegs = open('%s.py' % modulename, 'wa')
for jpegname in jpegs:
afile = open('%s.jpg' % jpegname, 'rb')
ajpeg = afile.read()
afile.close()
jpegascii = binascii.b2a_base64(ajpeg)
print jpegascii
myjpegs.write('%s = """%s"""\n\n' % (jpegname, jpegascii))
myjpegs.close()

append_to_jpeg_module('myjpegs', ['logo_sm'])

#heres how you use it
append_to_jpeg_module('myjpegs', ['coolpik1', 'coolpik2', 'anotherpik'])

Now, in your file that needs the jpegs, you can pretend these strings
are files with the cStringIO module, e.g. (pretending 'modulename' above
is 'myjpegs'):

import binascii
import myjpegs
import cStringIO

def get_jpeg_as_opened_file(jpegname, module):
jpegascii = module.__dict__[jpegname]
jpegbin = binascii.a2b_base64(jpegascii)
return cStringIO.StringIO(jpegbin)

# getting that pik
get_jpeg_as_opened_file('coolpik1', myjpegs)
And your company can go on making widgets feeling secure in the fact
that you have not required any extra entries in their file allocation
tables.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/

May 28 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Marcus | last post: by
reply views Thread by Thin Myrna | last post: by
1 post views Thread by Mark Delon | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.