Hi Sean, Ken,

I've just tested that combining my changes with Ken's suggestion
works. Attached is a full patch.

Regards,
  Jaakko

On 2.11.2010 18:05, Sean Gillies wrote:
> Ken,
> 
> Jaakko Salli has been making the Windows installers with the following
> diff to setup.py:
> 
> diff --git a/setup.py b/setup.py
> index 0ed51f1..a2371d2 100644
> --- a/setup.py
> +++ b/setup.py
> @@ -44,8 +44,14 @@ setup_args = dict(
> 
>  # Add DLLs for Windows
>  if sys.platform == 'win32':
> -    setup_args.update(
> -        data_files=[('DLLs', ['DLLs/geos.dll', 'DLLs/libgeos-3-0-0.dll']),]
> -        )
> +    import glob
> +    if '64 bit (AMD64)' in sys.version:
> +        setup_args.update(
> +            data_files=[('DLLs', glob.glob('DLLs_AMD64/*.dll'))]
> +            )
> +    else:
> +        setup_args.update(
> +            data_files=[('DLLs', glob.glob('DLLs_x86/*.dll'))]
> +            )
> 
> setup(**setup_args)
> 
> I believe he's using a GEOS 3.2 DLL now. The diff above is from July.
> 
> On Tue, Nov 2, 2010 at 8:59 AM, Ken Watford <[email protected]> wrote:
>> I don't normally work in Windows (this request was for my own Windows
>> users), but I'll see what I can come up with when I can get around to
>> it.
>>
>> Just to be sure, what (if any) modifications do you make to the
>> distribution (wrt your github repo) when building the windows
>> installer, other than adding the DLLs?
>>
>> On Fri, Oct 29, 2010 at 4:55 PM, Sean Gillies <[email protected]> wrote:
>>> Ken,
>>>
>>> I have no Windows machine to test this on, so I'll have to rely on you
>>> for something that works. I like the idea of modifying the DLL search
>>> strategy in shapely.geos. Any changes to setup.py and shapely/geos.py
>>> that you need to make to get this to work I will be happy to commit
>>> and release right away.
>>>
>>> Cheers,
>>>
>>> On Tue, Oct 26, 2010 at 7:40 AM, Ken Watford <[email protected]> wrote:
>>>> I'm not experienced with it either, but I'll take a shot in the dark
>>>> here. There is probably a more setuptools-ish way to do this, but this
>>>> seems to work.
>>>>
>>>> Without really changing anything, bdist_egg works (once you fix
>>>> setup.py - the git repo is still referencing libgeos-3-0-0), but since
>>>> there are no extension modules, distutils doesn't know it has to use
>>>> the platform-specific filename.
>>>>
>>>> An easy_install on the egg then works, but the DLLs are now installed
>>>> relative to the egg itself. I don't personally consider this a bad
>>>> thing, but geos.py needs to be updated to get the PATH set correctly:
>>>>
>>>>  elif sys.platform == 'win32':
>>>>     try:
>>>> -        local_dlls = os.path.abspath(os.__file__ + "../../../DLLs")
>>>> +        local_dlls =
>>>> os.path.abspath(os.path.join(os.path.dirname(__file__), "..\\DLLs"))
>>>>         original_path = os.environ['PATH']
>>>>         os.environ['PATH'] = "%s;%s" % (local_dlls, original_path)
>>>>         _lgeos = CDLL("geos.dll")
>>>>
>>>> Of course, this would now be the wrong path for users of the exe installer.
>>>>
>>>> It might be simpler all around to just include the DLLs in the package
>>>> directory itself, maybe in a (platform-specific) subdirectory. I think
>>>> the egg and the installer would probably put them in the same place
>>>> then.
>>>>
>>>> On Thu, Oct 21, 2010 at 3:18 PM, Sean Gillies <[email protected]> 
>>>> wrote:
>>>>> I've no experience at all with easy_install of extension modules on
>>>>> Windows. If anybody's got a working solution, I'll be happy to merge
>>>>> it.
>>>>>
>>>>> On Wed, Oct 20, 2010 at 11:19 AM, Ken Watford <[email protected]> wrote:
>>>>>> While running the executable win32 installer directly works fine,
>>>>>> easy_install (in distribute 0.6.14) doesn't seem to like it. It seems
>>>>>> to have trouble with the DLLs (they don't get installed). So if
>>>>>> Shapely were installed automatically as a requirement of something
>>>>>> else, it would appear to succeed but not work properly. Here's what
>>>>>> easy_install says:
>>>>>>
>>>>>> install_dir C:\Python26\Lib\site-packages\
>>>>>> Searching for Shapely
>>>>>> Reading http://pypi.python.org/simple/Shapely/
>>>>>> Reading http://trac.gispython.org/projects/PCL/wiki/Shapely
>>>>>> Reading http://trac.gispython.org/projects/PCL/wiki/ShapeLy
>>>>>> Best match: Shapely 1.2.5
>>>>>> Downloading 
>>>>>> http://pypi.python.org/packages/any/S/Shapely/Shapely-1.2.5.win32.exe#md5=ca21552a8e99ae167e869ab1e03f7559
>>>>>> Processing Shapely-1.2.5.win32.exe
>>>>>> WARNING: can't process DATA/DLLs/geos.dll
>>>>>> WARNING: can't process DATA/DLLs/libgeos-3-2-2.dll
>>>>>> shapely.geos: module references __file__
>>>>>> creating 
>>>>>> 'c:\users\kwatford\temp\easy_install-b1lnet\Shapely-1.2.5-py2.6-win32.egg'
>>>>>> and adding 
>>>>>> 'c:\users\kwatford\temp\easy_install-b1lnet\Shapely-1.2.5-py2.6-win32.egg.tmp'
>>>>>> to it
>>>>>> creating C:\python26\lib\site-packages\Shapely-1.2.5-py2.6-win32.egg
>>>>>> Extracting Shapely-1.2.5-py2.6-win32.egg to C:\python26\lib\site-packages
>>>>>> Adding Shapely 1.2.5 to easy-install.pth file
>>>>>> Installing intersect.pyc script to C:\Python26\Scripts
>>>>>> Installing dissolve.pyc script to C:\Python26\Scripts
>>>>>> Installing dissolve.py script to C:\Python26\Scripts
>>>>>> Installing intersect.py script to C:\Python26\Scripts
>>>>>>
>>>>>> Installed c:\python26\lib\site-packages\shapely-1.2.5-py2.6-win32.egg
>>>>>> Processing dependencies for Shapely
>>>>>> Finished processing dependencies for Shapely
>>>>>>
>>>>>>
>>>>>> I haven't tried this in Win64 yet, but I imagine it probably fails to
>>>>>> work in a similar fashion.
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community
> 

diff --git a/setup.py b/setup.py
index 171e053..6cc6fd6 100644
--- a/setup.py
+++ b/setup.py
@@ -44,8 +44,14 @@ setup_args = dict(
 
 # Add DLLs for Windows
 if sys.platform == 'win32':
-    setup_args.update(
-        data_files=[('DLLs', ['DLLs/geos.dll', 'DLLs/libgeos-3-0-0.dll']),]
-        )
+    import glob
+    if '(AMD64)' in sys.version:
+        setup_args.update(
+            data_files=[('DLLs', glob.glob('DLLs_AMD64/*.dll'))]
+            )
+    else:
+        setup_args.update(
+            data_files=[('DLLs', glob.glob('DLLs_x86/*.dll'))]
+            )
 
 setup(**setup_args)
diff --git a/shapely/geos.py b/shapely/geos.py
index bad1491..8807589 100644
--- a/shapely/geos.py
+++ b/shapely/geos.py
@@ -62,7 +62,8 @@ elif sys.platform == 'darwin':
 
 elif sys.platform == 'win32':
     try:
-        local_dlls = os.path.abspath(os.__file__ + "../../../DLLs")
+        local_dlls = os.path.abspath(os.path.join(os.path.dirname(__file__),
+                                     "..\\DLLs"))
         original_path = os.environ['PATH']
         os.environ['PATH'] = "%s;%s" % (local_dlls, original_path)
         _lgeos = CDLL("geos.dll")
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to