Oh, and the alternative hackaround I wondered about - manually trying to 
include ctypes_declarations.py in the output of py2exe, but outside of 
library.zip - does not work.

Obviously Shapely is looking for this file in a particular location, and 
the path it is looking at is inside the zipfile. Trying to open a file 
with this path fails as you might expect.


Jonathan Hartley wrote:
> I don't really know what I'm doing here, but I have a patch that fixes 
> my problem (attached.) I'm groping my way through this, so presumably 
> I need to do a bunch of other things before this is actually done.
>
> I don't know whether the Shapely source code repositories are public. 
> Or should I be using the PyPI 'setup.py develop' to get the source and 
> tests? For now, I'm working on the source download I got from 
> http://pypi.python.org/pypi/Shapely
>
> The source changes I made in the attached patch are:
> Instead of geos.py running ctypes_declarations.py using execfile, it 
> now calls a function defined in that module, passing the lgeos object 
> upon which attributes should be defined. I don't pretend to understand 
> why it used execfile in the first place, so I may have made an 
> atrocious mistake here.
>
> This change makes py2exe work happily with Shapely, using only the 
> 'data_files' entry in setup.py that I described earlier. My program 
> still appears to execute correctly on Windows XP. This is the only 
> testing I have done. Does Shapely have tests suites somewhere that I 
> could run?
>
> I created the patch using:
>    diff -crB Shapely-1.0.12 Shapely-1.0.12-new > no_more_execfile.patch
> Is there a more appropriate way I should have done this?
>
> Thanks for any guidance,
>
>    Jonathan
>
>
> Jonathan Hartley wrote:
>> Fair enough. I don't know how Shapely works - so I can only vaguely 
>> infer what you mean. However, with that caveat I'll take a look at 
>> the code and get back to the list when I understand enough to have 
>> questions.
>>
>> It crosses my mind that if you are doing what I think you're doing 
>> (ie. manually reading the contents of ctypes_declarations.py and 
>> eval'ing it) then a hackaround solution might be for me to copy 
>> ctypes_declarations.py into my py2exe output without putting it into 
>> library.zip. I'll try that out too.
>>
>> Thanks,
>>
>>    Jonathan
>>
>> Sean Gillies wrote:
>>> Hi Jonathan,
>>>
>>> I've no experience with py2exe, but I'm not surprised that the  
>>> declarations are causing you problems. A better way might be to 
>>> write  a function, that when passed _lgeos, does the prototyping. 
>>> We'd then  call that function instead of eval'ing 
>>> ctypes_declarations.py. Is a  working patch along these lines 
>>> something you might be interested in  contributing? If so, I'd be 
>>> happy to push for a Shapely 1.0.13 release.
>>>
>>> Cheers,
>>> Sean
>>>
>>> On Aug 26, 2009, at 12:35 PM, Jonathan Hartley wrote:
>>>
>>>  
>>>> Hi all,
>>>>
>>>> I'm trying to package my Python program up into an executable using
>>>> py2exe, so that users can run the exe without having to install 
>>>> (or  know
>>>> anything about) Python.
>>>>
>>>> I'm stumbling over shapely\ctypes_declarations.py, which just isn't
>>>> included in the py2exe distribution, causing a runtime error when I
>>>> execute my .exe:
>>>>
>>>> IOError: [Errno 2] No such file or directory: 'C:\\Documents and
>>>> Settings\\jhartley\\My
>>>> Dropbox\\projects\\solescion\\dist\\SoleScion-win-binary-0.2.6-svn\ 
>>>> \exe\\library.zip\\shapely\\ctypes_declarations.py'
>>>> Traceback (most recent call last):
>>>>  File "main.py", line 5, in <module>
>>>>  File "solescion\controller\application.pyo", line 6, in <module>
>>>>  File "solescion\controller\gameloop.pyo", line 10, in <module>
>>>>  File "solescion\controller\graphics.pyo", line 5, in <module>
>>>>  File "solescion\geom\svgload\svg_parser.pyo", line 4, in <module>
>>>>  File "shapely\geometry\__init__.pyo", line 1, in <module>
>>>>  File "shapely\geometry\geo.pyo", line 5, in <module>
>>>>  File "shapely\geometry\point.pyo", line 10, in <module>
>>>>  File "shapely\geos.pyo", line 56, in <module>
>>>> IOError: [Errno 2] No such file or directory: 'C:\\Documents and
>>>> Settings\\jhartley\\My
>>>> Dropbox\\projects\\solescion\\dist\\SoleScion-win-binary-0.2.6-svn\ 
>>>> \exe\\library.zip\\shapely\\ctypes_declarations.py'
>>>>
>>>> I tried manually copying /ctypes_declaration.py/ from Shapely  
>>>> directory
>>>> into py2exe's library.zip, but I still get the same error on running,
>>>> much to my puzzlement. Presumably I could tweak my /setup.py/ to  
>>>> include
>>>> ctypes_declaration.py automatically, (and I will try this) but I don't
>>>> see how that will help if the manual copy has had no effect.
>>>>
>>>> Am I doing it very wrong? Does anyone have a recipe or working example
>>>> of using Shapely with py2exe?
>>>>
>>>> Sorry if this is covered somewhere, I've been Googling but to no  
>>>> avail.
>>>>
>>>> Shapely is installed in a virtualenv (which is active) and the
>>>> libgeos.dll is included in the py2exe executable by adding the  
>>>> following
>>>> to my setup.py:
>>>>
>>>>        data_files = [
>>>>            ('', ['solescion/lib/geos.dll']),
>>>>            ('', ['solescion/lib/libgeos-3-0-0.dll']),
>>>>        ],
>>>>
>>>> Thanks for any pointers,
>>>>
>>>>    Jonathan
>>>>
>>>> -- 
>>>> Jonathan Hartley      Made of meat.      http://tartley.com
>>>> [email protected]   +44 7737 062 225   twitter/skype: tartley
>>>>
>>>>
>>>> _______________________________________________
>>>> Community mailing list
>>>> [email protected]
>>>> http://lists.gispython.org/mailman/listinfo/community
>>>>     
>>>
>>> -- 
>>> Sean
>>>
>>> _______________________________________________
>>> Community mailing list
>>> [email protected]
>>> http://lists.gispython.org/mailman/listinfo/community
>>>
>>>   
>>
>

-- 
Jonathan Hartley      Made of meat.      http://tartley.com
[email protected]   +44 7737 062 225   twitter/skype: tartley


_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to