Using a package like PyInstaller

L

LittlePython

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
 
J

James Stroud

LittlePython said:
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/
 
L

LittlePython

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?
 
J

James Stroud

LittlePython said:
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/
 
L

LittlePython

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
 
J

James Stroud

LittlePython said:
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/Manual_v1.1.html#accessing-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/
 
L

LittlePython

"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 said:
LittlePython said:
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/Manual_v1.1.html#accessing-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/
 
J

James Stroud

LittlePython said:
"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/
 
L

LittlePython

Thx for the tip ... I'll give it a go


James Stroud said:
LittlePython said:
"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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,296
Messages
2,571,535
Members
48,281
Latest member
DaneLxa72

Latest Threads

Top