I've noticed that if I run Build.py with a non-modified spec file, and it
succeeds, and then I add the a.datas line to the spec file and then re-run
Build.py, it does not appear to actually incorporate the change I just made
to the spec file.  When I make changes to the spec file, do I also have to
remove the dist & build subdirectories that Build.py creates before running
Build.py again?

Peter

On Wed, Mar 31, 2010 at 2:16 PM, Peter Scheie <[email protected]> wrote:

> Setback: It appears that Build.py only succeeds if I don't add
> a.datas += [('C:\\fdu\\zeus.p12','DATA','zeus.p12')]
> to it; I think my previous successes in building were with unmodified
> versions of the spec file.  So, I'm back where I started in that if I modify
> the spec file by hand, adding the a.datas line, then it doesn't build.  And,
> of course, if I leave that out and it does build, and then I run the
> executable, it spits out an error about not finding the zeus.p12 file
> because it was never included in the spec file.
>
>
> On Wed, Mar 31, 2010 at 1:56 PM, Peter Scheie <[email protected]> wrote:
>
>> Update: Following the suggestion from Build.py (hey, there's a novel
>> idea), I installed pywin32, and now Build.py runs successfully, and I get
>> copyfile.exe.  That's the good news.  The bad news is that when I run
>> copyfile.exe I still get the error about it not being able to find the file
>> I added in as data ("zeus.p12"):
>>
>> C:\fdu\dist>copyfile
>> Enter a letter: d
>>
>> Traceback (most recent call last):
>>   File "<string>", line 13, in <module>
>>   File "C:\fdu\build\pyi.win32\copyfile\outPYZ1.pyz/shutil", line 85, in
>> copy
>>   File "C:\fdu\build\pyi.win32\copyfile\outPYZ1.pyz/shutil", line 51, in
>> copyfil
>> e
>> IOError: [Errno 2] No such file or directory:
>> 'C:/DOCUME~1/PSCHEI~1.VSI/LOCALS~1
>> /Temp/_MEI13162/zeus.p12'
>>
>> The temporary directory IS being created, and there are some files in
>> there, but my zeus.p12 file is not in there.  Here are the files that are in
>> there
>>
>> 03/31/2010  01:38 PM    <DIR>          .
>> 03/31/2010  01:38 PM    <DIR>          ..
>> 03/31/2010  01:38 PM            32,768 bz2.pyd
>> 03/31/2010  01:38 PM           155,648 MSVCR71.dll
>> 03/31/2010  01:38 PM            13,312 POWRPROF.dll
>> 03/31/2010  01:38 PM           750,592 python25.dll
>> 03/31/2010  01:38 PM            51,712 pywintypes25.dll
>> 03/31/2010  01:38 PM           142,848 unicodedata.pyd
>> 03/31/2010  01:38 PM            31,744 win32api.pyd
>>                7 File(s)      1,178,624 bytes
>>
>> The spec file, with the added a.datas is listed in my previous message.
>> So, I'm closer, but not quite there yet.  Anything obvious that I'm missing?
>>
>>
>> On Wed, Mar 31, 2010 at 11:39 AM, Peter Scheie <[email protected]> wrote:
>>
>>> Short answer: The directory is there (I was mistaken about it being
>>> missing), but the file my script uses is not.
>>>
>>> Long answer: I wonder if I've somehow got something weird in my
>>> environments.  As mentioned in my other topic, I was able to run the
>>> Build.py script with my real project and with a test script called
>>> copyfile.py if I had the files on the C: drive in the Windows XP VM
>>> (VirtualBox) on my Ubuntu 9.04 laptop at home; if the files were on a
>>> network mapped drive, I got "No such file or directory: 'DATA'" errors, and
>>> I am getting those same errors on the XP VM on Ubuntu 9.10 on my machine at
>>> the office.  Today, I brought my laptop from home into the office, and now
>>> I'm getting the same "No such file or directory: 'DATA'" error, where it had
>>> been working fine just last night.  So, here's my simple script, called
>>> copyfile.py:
>>>
>>> #!/usr/bin/python
>>> # Copy a file.  The file is included in the --onefile output of
>>> pyinstaller.
>>> import os
>>> import shutil
>>> # prompts for input are so I can see what is happening
>>> ans = raw_input("Enter a letter: ")
>>> src = os.path.join(os.environ['_MEIPASS2'], 'zeus.p12')
>>> dest = "./Bzeus.p12"
>>> shutil.copy(src,dest)
>>> ans = raw_input("Enter a number: ")
>>>
>>> The script sits in c:\fdu, so then, while I'm in the c:\fdu directory I
>>> run
>>> c:\python25\python.exe c:\pyinstaller\Makespec.py -X --onefile
>>> copyfile.py
>>>
>>> and it responds
>>> wrote C:\fdu\copyfile.spec
>>> now run Build.py to build the executable
>>>
>>> Then I edit the spec file, adding the a.datas line, so that it looks like
>>> this:
>>> # -*- mode: python -*-
>>> a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'),
>>> os.path.join(HOMEPATH,'support\\useUnicode.py'), 'copyfile.py'],
>>>              pathex=['C:\\fdu'])
>>> a.datas += [('C:\\fdu\\zeus.p12','DATA','zeus.p12')]
>>> pyz = PYZ(a.pure)
>>> exe = EXE( pyz,
>>>           a.scripts,
>>>           a.binaries,
>>>           a.zipfiles,
>>>           a.datas,
>>>           name=os.path.join('dist', 'copyfile.exe'),
>>>           debug=False,
>>>           strip=False,
>>>           upx=True,
>>>           console=True )
>>>
>>> Then I run
>>> c:\python25\python.exe c:\pyinstaller\Build.py copyfile.spec
>>>
>>> At home on my laptop it worked,  (I don't have the output handy)
>>> producing copyfile.exe, but which then gave an error about not being able to
>>> find the zeus.p12 file.  But now on that same laptop but in the office, as
>>> well as on my office machine, it gives me this:
>>>
>>> checking Analysis
>>> building because copyfile.py changed
>>> running Analysis outAnalysis0.toc
>>> Analyzing: c:\pyinstaller\support\_mountzlib.py
>>> Analyzing: c:\pyinstaller\support\useUnicode.py
>>> Analyzing: copyfile.py
>>> W: Cannot determine your Windows or System directories
>>> W: Please add them to your PATH if .dlls are not found
>>> W: or install http://sourceforge.net/projects/pywin32/
>>> C:\fdu\build\pyi.win32\copyfile\outAnalysis0.toc no change!
>>> checking PYZ
>>> checking PKG
>>> building because copyfile.py changed
>>> building PKG outPKG3.pkg
>>> Cannot find ('C:\fdu\zeus.p12', 'DATA', 0, 'b')
>>> Traceback (most recent call last):
>>>   File "c:\pyinstaller\Build.py", line 1160, in <module>
>>>     main(args[0], configfilename=opts.configfile)
>>>   File "c:\pyinstaller\Build.py", line 1148, in main
>>>     build(specfile)
>>>   File "c:\pyinstaller\Build.py", line 1111, in build
>>>     execfile(spec)
>>>   File "copyfile.spec", line 15, in <module>
>>>     console=True )
>>>   File "c:\pyinstaller\Build.py", line 661, in __init__
>>>     strip_binaries=self.strip, upx_binaries=self.upx, crypt=self.crypt)
>>>   File "c:\pyinstaller\Build.py", line 561, in __init__
>>>     self.__postinit__()
>>>   File "c:\pyinstaller\Build.py", line 196, in __postinit__
>>>     self.assemble()
>>>   File "c:\pyinstaller\Build.py", line 618, in assemble
>>>     archive.build(self.name, mytoc)
>>>   File "c:\pyinstaller\archive.py", line 229, in build
>>>     self.add(tocentry)   # the guts of the archive
>>>   File "c:\pyinstaller\carchive.py", line 235, in add
>>>     s = open(pathnm, 'rb').read()
>>> IOError: [Errno 2] No such file or directory: 'DATA'
>>>
>>> I must be doing something incorrectly, but I can't see what it is.
>>> Perhaps it's related to the warning about it not being able to determine the
>>> Windows or System directories (?).
>>>
>>> Peter
>>>
>>>
>>>
>>> On Wed, Mar 31, 2010 at 4:34 AM, Giovanni Bajo <[email protected]>wrote:
>>>
>>>> On Tue, 2010-03-30 at 20:08 -0600, Peter Scheie wrote:
>>>> > In my python script, I'm trying to copy a file from
>>>> > os.environ['_MEIPASS2'], which appears to point to
>>>> > C:/DOCUME~1/PETER/LOCALS~1/Temp/_MEI5322/. The file is supposed to be
>>>> > placed there by the a.datas method in the spec file. However, the
>>>> > directory doesn't exist.  Is this something I have to create in my
>>>> > script so that the script can place the file (included in the .exe)
>>>> > there at run time?  I was under the impression that it was created
>>>> > automatically/dynamically.
>>>>
>>>> The directory is created at startup and removed after the application
>>>> exits. I am not aware of any bug where _MEIPASS2 at runtime points to a
>>>> directory which it does not exist, and it sounds very weird to me.
>>>>
>>>> Can you reproduce your problem with a working program that you can
>>>> share?
>>>>
>>>>
>>>> --
>>>> Giovanni Bajo   ::  [email protected]
>>>> Develer S.r.l.  ::  http://www.develer.com
>>>>
>>>> My Blog: http://giovanni.bajo.it
>>>> Last post: C++ and copy-on-write data structures
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "PyInstaller" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected]<pyinstaller%[email protected]>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/pyinstaller?hl=en.
>>>>
>>>>
>>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

Reply via email to