Didn’t get any replies to my query, but I got it working after much fiddling.

 

I had to:

   a) give the COLLECT a name to work around of the original reason for build failing (the collect object is given a bad name if one isn’t provided, around line 590-ish of build.py, see below)

   b) get the syntax for the collect line right :-o

   c) remove a.binaries from the EXE and replace it with collect.toc.

 

The working spec-file looks like this:

 

a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'synpy.py'],

             pathex=['C:\\ian\\mine\\synpy'])

gvp = 'graphviz/' #so I can change the directory where the binaries are stored easily

collect = COLLECT(a.binaries+

    [

        ('dot.exe',gvp+'dot.exe','BINARY')

        ,('z.dll',gvp+'z.dll','BINARY')

        ,('zlib1.dll',gvp+'zlib1.dll','BINARY')

        ,('freetype6.dll',gvp+'freetype6.dll','BINARY')

        ,('jpeg.dll',gvp+'jpeg.dll','BINARY')

        ,('libexpat.dll',gvp+'libexpat.dll','BINARY')

        ,('libexpatw.dll',gvp+'libexpatw.dll','BINARY')

        ,('png.dll',gvp+'png.dll','BINARY')

    ],name='hi.1')   # the name is needed to workaround a bug in build.py

pyz = PYZ(a.pure)

exe = EXE( pyz,

          a.scripts,

          collect.toc,

          name='synpy.exe',

          debug=0,

          strip=0,

          console=1 )

 

The dodgy bit of Build.py is around like 590:

 

        self.name = kws.get('name',None)

        if self.name is None:

            self.name = 'dist_' + self.out[:-4]            # ???? what is this supposed to do ????

 

which means that if you don’t provide an explicit name in the COLLECT line, you get an error like:

OSError: [Errno 22] Invalid argument: 'C:\\ian\\mine\\synpy\\dist_C:\\ian\\mine\\synpy\\buildsynpy\\out4'

Because self.out contains something like C:\\ian\\mine\\synpy\\buildsynpy\\out4.toc, and the ‘.toc’ is removed and dist_ is put on the front of it.

 

Hopefully this will help anyone else who has the same problem.

 

Regards

Ian

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Barnard
Sent: 01 November 2005 11:05
To: [email protected]
Subject: [PyInstaller] How to adding binaries to a onefile setup

 

Hi

 

I’m trying to build a onefile distribution on Windows XP, for Activestate Python 2.4.1, using the excellent PyInstaller 1.0.

 

I want to include some binaries with the installation so my users don’t have to install other applications.

 

My initial spec file looks like this:

 

a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'synpy.py'],

             pathex=['C:\\ian\\mine\\synpy'])

pyz = PYZ(a.pure)

exe = EXE( pyz,

          a.scripts,

          a.binaries,

          name='synpy.exe',

          debug=0,

          strip=0,

          console=1 )

 

Which was generated by Makespec, and works fine, and I can run the generated synpy.exe, although I obviously have to provide the additional binaries separately.

 

I’m probably being particularly thick, but I find the description of spec files has lots of detail of the syntax of the implementation but is very opaque on its application.  In particular some explicit examples for onefile setup or how to add binaries would be useful (to me, at least).

 

So, when I try to add one of the binaries, I add a collect line on the end (although I’m not the least confident if/why this is right even though the syntax is correct):

 

collect = COLLECT(a.binaries+['dot.exe','c:\\program files\\att\\graphviz\\bin\\dot.exe','BINARY'])

 

but now doing a build fails with this output:

 

C:\ian\mine\synpy>c:\Python24\lib\site-packages\pyinstaller_1.0\Build.py synpy.spec

checking Analysis

checking PYZ

checking PKG

checking ELFEXE

checking COLLECT

building out4.toc because out4.toc missing

building COLLECT out4.toc

Traceback (most recent call last):

  File "c:\Python24\lib\site-packages\pyinstaller_1.0\Build.py", line 816, in ?

    build(sys.argv[1])

  File "c:\Python24\lib\site-packages\pyinstaller_1.0\Build.py", line 62, in build

    exec open(spec, 'r').read()+'\n'

  File "<string>", line 11, in ?

  File "c:\Python24\lib\site-packages\pyinstaller_1.0\Build.py", line 606, in __init__

    self.__postinit__()

  File "c:\Python24\lib\site-packages\pyinstaller_1.0\Build.py", line 80, in __postinit__

    self.assemble()

  File "c:\Python24\lib\site-packages\pyinstaller_1.0\Build.py", line 642, in assemble

    os.mkdir(self.name)

OSError: [Errno 22] Invalid argument: 'C:\\ian\\mine\\synpy\\dist_C:\\ian\\mine\\synpy\\buildsynpy\\out4'

 

Which doesn’t seem to have much correlation to the change I made to the spec file.

 

I’ve tried different paths to the binary, and putting the collect line in different places, but the result was the same.

 

Can anyone help?

 

Regards

Ian Barnard

 

 

 

-------------------------------------------------------------------------------------
Don’t miss out! Join us at this year’s User Group Conference.
9 – 10 November, Marlow, Buckinghamshire, UK.
http://www.telelogic.com/UKugc

Ian Barnard
Principal Consultant
Telelogic UK Ltd, Northbrook House
Robert Robinson Ave

Oxford Science Park, Oxford, OX4 4GA, United Kingdom
Phone: +44 (1865) 784 285
Fax: +44 (1865) 784 286
Mobile phone: +44 (798) 0798 813

[EMAIL PROTECTED]
http://www.telelogic.com

Telelogic - Requirements-Driven Innovation!
-------------------------------------------------------------

 

 

The information contained in this e-mail, including any attachment or enclosure, is intended only for the person or entity to which it is addressed and may contain confidential material. Any unauthorized use, review, retransmissions, dissemination, copying or other use of this information by persons or entities other than the intended recipient is prohibited.

 

_______________________________________________
PyInstaller mailing list
[email protected]
http://lists.hpcf.upr.edu/mailman/listinfo/pyinstaller

Reply via email to