<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sean Gillies (Posts about shapely)</title><link>https://sgillies.net/</link><description></description><atom:link href="https://sgillies.net/tags/shapely.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sun, 31 Dec 2023 01:26:22 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Shapely 1.8.0</title><link>https://sgillies.net/2021/10/26/shapely-1-8-0.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;From the 1.8.0 &lt;a class="reference external" href="https://github.com/Toblerity/Shapely/releases/tag/1.8.0"&gt;release notes&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Shapely 1.8.0 is a transitional version. There are a few bug fixes and new
features, but it largely exists to warn about the upcoming changes in
2.0.0. See the new migration guide for more details on how to update your
code from Shapely 1.8 to 2.0.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;One of the upcoming changes: the geometry objects of 2.0 will be immutable,
simplifying their implementation, and making it possible to hash them.
Here's an example of the warning you'll see when you set a new attribute on
a version 1.8 geometry object.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code pycon"&gt;&lt;a id="rest_code_6a3f141e2ef04d379b86ee931f93820e-1" name="rest_code_6a3f141e2ef04d379b86ee931f93820e-1" href="https://sgillies.net/2021/10/26/shapely-1-8-0.html#rest_code_6a3f141e2ef04d379b86ee931f93820e-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;shapely.geometry&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Point&lt;/span&gt;
&lt;a id="rest_code_6a3f141e2ef04d379b86ee931f93820e-2" name="rest_code_6a3f141e2ef04d379b86ee931f93820e-2" href="https://sgillies.net/2021/10/26/shapely-1-8-0.html#rest_code_6a3f141e2ef04d379b86ee931f93820e-2"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_6a3f141e2ef04d379b86ee931f93820e-3" name="rest_code_6a3f141e2ef04d379b86ee931f93820e-3" href="https://sgillies.net/2021/10/26/shapely-1-8-0.html#rest_code_6a3f141e2ef04d379b86ee931f93820e-3"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;a id="rest_code_6a3f141e2ef04d379b86ee931f93820e-4" name="rest_code_6a3f141e2ef04d379b86ee931f93820e-4" href="https://sgillies.net/2021/10/26/shapely-1-8-0.html#rest_code_6a3f141e2ef04d379b86ee931f93820e-4"&gt;&lt;/a&gt;&lt;span class="go"&gt;&amp;lt;stdin&amp;gt;:1: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;</description><category>geometry</category><category>geos</category><category>gis</category><category>python</category><category>shapely</category><category>work</category><guid>https://sgillies.net/2021/10/26/shapely-1-8-0.html</guid><pubDate>Tue, 26 Oct 2021 14:29:27 GMT</pubDate></item><item><title>Shapely 2.0 roadmap</title><link>https://sgillies.net/2020/05/02/shapely-2-0-roadmap.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;There's going to be a 2.0 version of shapely. Joris Van den Bossche has written
an &lt;a class="reference external" href="https://github.com/shapely/shapely-rfc/pull/1"&gt;RFC for a roadmap&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Joris is a Pandas and GeoPandas developer. The GeoPandas team has identified
some enhancements to shapely that would allow GeoPandas and shapely to reach
new levels of performance, and we're going to implement them. A &lt;a class="reference external" href="https://numfocus.org/"&gt;NumFOCUS&lt;/a&gt; grant will support some of this work.&lt;/p&gt;
&lt;p&gt;I'm super late in blogging about this and commenting on the RFC, which has lead
to a little confusion about whether I'm in favor of this. I am, 100 percent.
Rewrites aren't easy, but this effort has a lot going for it: serious use
cases, committed stakeholders, clever and pragmatic programmers, funding, and
lots of goodwill. We're going to have a 2.0 version that removes cruft, adds
killer new features, and isn't super difficult to migrate to.&lt;/p&gt;
&lt;p&gt;Please read the RFC pull request and comment if you're into helping shape
the future of Python's #1 open source GIS geometry package.&lt;/p&gt;</description><category>geopandas</category><category>python</category><category>shapely</category><category>work</category><guid>https://sgillies.net/2020/05/02/shapely-2-0-roadmap.html</guid><pubDate>Sat, 02 May 2020 22:25:34 GMT</pubDate></item><item><title>Shapely 1.7.0</title><link>https://sgillies.net/2020/02/04/shapely-1-7-0.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;At long last, Shapely 1.7.0 is done. We have wheels on PyPI, wheels that
include GEOS 3.8.0, &lt;a class="reference external" href="https://pypi.org/project/Shapely/1.7.0/#files"&gt;wheels for Manylinux1, OS X, and Windows&lt;/a&gt;. The changes since 1.6.4 are
all listed in the &lt;a class="reference external" href="https://github.com/Toblerity/Shapely/blob/master/CHANGES.txt#L4-L88"&gt;change log&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are now 96 people named in &lt;a class="reference external" href="https://github.com/Toblerity/Shapely/blob/master/CREDITS.txt"&gt;Shapely's credits&lt;/a&gt;. Special
1.7.0 thanks to Joris Van den Bossche and the GeoPandas project for pre-release
testing and to Mike Taves for putting the finishing touches on the project's
AppVeyor configuration and Windows wheel building infrastructure.&lt;/p&gt;
&lt;p&gt;Stay tuned for more news.&lt;/p&gt;</description><category>geometry</category><category>geos</category><category>gis</category><category>python</category><category>shapely</category><category>work</category><guid>https://sgillies.net/2020/02/04/shapely-1-7-0.html</guid><pubDate>Wed, 05 Feb 2020 02:20:15 GMT</pubDate></item><item><title>Fix for Shapely's GEOS library loading bug in 1.7a2</title><link>https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;Including GDAL and GEOS in binary wheels that go to the Python Package Index
(PyPI) has been good for users of fiona, rasterio, and shapely, but has also
exposed Python GIS programmers on OS X to a perplexing bug. Shapely's issue
&lt;a class="reference external" href="https://github.com/Toblerity/Shapely/issues/553"&gt;#553&lt;/a&gt; has been weighing on
me for a long time. It's been hard to understand, hard to explain, and bites
very hard. The short program below will trigger the bug on any version of OS
X with any version of fiona and any version of shapely before
1.7a2 which is installed using a wheel from PyPI.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-1" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-1" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# crash.py&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-2" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-2" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-3" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-3" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-3"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;fiona&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-4" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-4" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-4"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;shapely.geometry&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Point&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-5" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-5" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-5"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;shapely.ops&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;unary_union&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-6" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-6" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-6"&gt;&lt;/a&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-7" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-7" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-8" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-8" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-8"&gt;&lt;/a&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Buffering points to create polygons"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-9" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-9" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-9"&gt;&lt;/a&gt;&lt;span class="n"&gt;SHAPES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-10" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-10" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-10"&gt;&lt;/a&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-11" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-11" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-11"&gt;&lt;/a&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Computing union of polygons"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-12" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-12" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-12"&gt;&lt;/a&gt;&lt;span class="n"&gt;union&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;unary_union&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SHAPES&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-13" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-13" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-14" name="rest_code_b9b10ee35f2d4fefb89d8134d2c43334-14" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_b9b10ee35f2d4fefb89d8134d2c43334-14"&gt;&lt;/a&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Union: &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;union&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_1013a652070344fab205b1cad20eb23e-1" name="rest_code_1013a652070344fab205b1cad20eb23e-1" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_1013a652070344fab205b1cad20eb23e-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;python crash.py
&lt;a id="rest_code_1013a652070344fab205b1cad20eb23e-2" name="rest_code_1013a652070344fab205b1cad20eb23e-2" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_1013a652070344fab205b1cad20eb23e-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;Buffering points to create polygons&lt;/span&gt;
&lt;a id="rest_code_1013a652070344fab205b1cad20eb23e-3" name="rest_code_1013a652070344fab205b1cad20eb23e-3" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_1013a652070344fab205b1cad20eb23e-3"&gt;&lt;/a&gt;&lt;span class="go"&gt;Computing union of polygons&lt;/span&gt;
&lt;a id="rest_code_1013a652070344fab205b1cad20eb23e-4" name="rest_code_1013a652070344fab205b1cad20eb23e-4" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_1013a652070344fab205b1cad20eb23e-4"&gt;&lt;/a&gt;&lt;span class="go"&gt;Assertion failed: (!static_cast&amp;lt;bool&amp;gt;("should never be reached")), function itemsTree, file AbstractSTRtree.cpp, line 373.&lt;/span&gt;
&lt;a id="rest_code_1013a652070344fab205b1cad20eb23e-5" name="rest_code_1013a652070344fab205b1cad20eb23e-5" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_1013a652070344fab205b1cad20eb23e-5"&gt;&lt;/a&gt;&lt;span class="go"&gt;Abort trap: 6&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The unary_union function uses a GEOS STRtree and an assertion that should
never be reached is in fact reached and the program aborts.&lt;/p&gt;
&lt;p&gt;There has been a work-around – import shapely before importing other modules
that are dynamically linked with GEOS, such as fiona and rasterio – but that's
smelly and hard to ensure in a complex project.&lt;/p&gt;
&lt;p&gt;The problem exists in a small niche: one operating system and one kind of
program, one that that loads GEOS twice in different ways. Once when fiona's
extension modules are loaded and cause the linked GEOS library to be loaded as
with any compiled program, and once again when shapely is imported and it calls
&lt;code class="docutils literal"&gt;dlopen&lt;/code&gt; from python to load GEOS. I've found no diagnosis or solution of
a similar problem on the web. Was the problem in GEOS? Was it in the library
files that I built for the fiona, rasterio, and shapely wheels? Was the bug in
delocate, the program I use to find dependencies and bundle them into the
wheels? I asked GEOS developers and folks at work, to no avail. I was stumped
for a long time.&lt;/p&gt;
&lt;p&gt;I asked Even Rouault about the issue and he suggested a solution might be found
in being more careful about using the correct mode with &lt;code class="docutils literal"&gt;dlopen&lt;/code&gt; and he
offered some example Python code that included this: &lt;code class="docutils literal"&gt;handle = CDLL(None)&lt;/code&gt;.
My first thought was "can we use the ctypes CDLL class like this?" The docs say
that the first argument is a path to a library file and that's how I've been
using it in Shapely.&lt;/p&gt;
&lt;p&gt;While looking for guidance on passing &lt;code class="docutils literal"&gt;None&lt;/code&gt; to the CDLL constructor, I found
some commented code in &lt;a class="reference external" href="https://eli.thegreenplace.net/2013/03/09/python-ffi-with-ctypes-and-cffi"&gt;https://eli.thegreenplace.net/2013/03/09/python-ffi-with-ctypes-and-cffi&lt;/a&gt;.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-1" name="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-1" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_159c7825af8942fc9bacbc71fa3c6e8a-1"&gt;&lt;/a&gt;# CDLL(None) invokes dlopen(NULL), which loads the currently running
&lt;a id="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-2" name="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-2" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_159c7825af8942fc9bacbc71fa3c6e8a-2"&gt;&lt;/a&gt;# process - in our case Python itself. Since Python is linked with
&lt;a id="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-3" name="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-3" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_159c7825af8942fc9bacbc71fa3c6e8a-3"&gt;&lt;/a&gt;# libc, readdir_r will be found there.
&lt;a id="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-4" name="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-4" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_159c7825af8942fc9bacbc71fa3c6e8a-4"&gt;&lt;/a&gt;# Alternatively, we can just explicitly load 'libc.so.6'.
&lt;a id="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-5" name="rest_code_159c7825af8942fc9bacbc71fa3c6e8a-5" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_159c7825af8942fc9bacbc71fa3c6e8a-5"&gt;&lt;/a&gt;lib = CDLL(None)
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The OS X dlopen man page doesn't exactly say that,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;dlopen() examines the mach-o file specified by path.  If the file is
compatible with the current process and has not already been loaded into
the current process, it is loaded and linked.  After being linked, if it
contains any initializer functions, they are called, before dlopen()
returns.  dlopen() can load dynamic libraries and bundles.  It returns
a handle that can be used with dlsym() and dlclose().  A second call to
dlopen() with the same path will return the same handle, but the internal
reference count for the handle will be incremented.  Therefore all dlopen()
calls should be balanced with a dlclose() call.&lt;/p&gt;
&lt;p&gt;If a null pointer is passed in path, dlopen() returns a handle equivalent
to RTLD_DEFAULT.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;but the POSIX spec is clear that &lt;code class="docutils literal"&gt;dlopen(NULL)&lt;/code&gt; returns a handle to a global
symbols object and that's what I observe on my MacBook. Here's an interpreter
session where I import fiona and look in the global symbols object for a GDAL
C API function.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code pycon"&gt;&lt;a id="rest_code_d140df24a4c24f57908d8d1577f53613-1" name="rest_code_d140df24a4c24f57908d8d1577f53613-1" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_d140df24a4c24f57908d8d1577f53613-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;fiona&lt;/span&gt;
&lt;a id="rest_code_d140df24a4c24f57908d8d1577f53613-2" name="rest_code_d140df24a4c24f57908d8d1577f53613-2" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_d140df24a4c24f57908d8d1577f53613-2"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;ctypes&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CDLL&lt;/span&gt;
&lt;a id="rest_code_d140df24a4c24f57908d8d1577f53613-3" name="rest_code_d140df24a4c24f57908d8d1577f53613-3" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_d140df24a4c24f57908d8d1577f53613-3"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;handle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CDLL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d140df24a4c24f57908d8d1577f53613-4" name="rest_code_d140df24a4c24f57908d8d1577f53613-4" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_d140df24a4c24f57908d8d1577f53613-4"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;handle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GDALGetDriverCount&lt;/span&gt;
&lt;a id="rest_code_d140df24a4c24f57908d8d1577f53613-5" name="rest_code_d140df24a4c24f57908d8d1577f53613-5" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_d140df24a4c24f57908d8d1577f53613-5"&gt;&lt;/a&gt;&lt;span class="go"&gt;&amp;lt;_FuncPtr object at 0x111a3eb38&amp;gt;&lt;/span&gt;
&lt;a id="rest_code_d140df24a4c24f57908d8d1577f53613-6" name="rest_code_d140df24a4c24f57908d8d1577f53613-6" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_d140df24a4c24f57908d8d1577f53613-6"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;handle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GDALGetDriverCount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_d140df24a4c24f57908d8d1577f53613-7" name="rest_code_d140df24a4c24f57908d8d1577f53613-7" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_d140df24a4c24f57908d8d1577f53613-7"&gt;&lt;/a&gt;&lt;span class="go"&gt;187&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When fiona is imported, Python calls dlopen with the path to fiona's extension
(.so) modules, and as these are liked with libgdal, the GDAL library is loaded.
Now, libgdal is linked with libgeos_c, so will we find GEOS C API functions in
the global symbols object?&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code pycon"&gt;&lt;a id="rest_code_abbe7aaa20ca464e945b7931bc624d8b-1" name="rest_code_abbe7aaa20ca464e945b7931bc624d8b-1" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_abbe7aaa20ca464e945b7931bc624d8b-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="n"&gt;handle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initGEOS&lt;/span&gt;
&lt;a id="rest_code_abbe7aaa20ca464e945b7931bc624d8b-2" name="rest_code_abbe7aaa20ca464e945b7931bc624d8b-2" href="https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html#rest_code_abbe7aaa20ca464e945b7931bc624d8b-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;&amp;lt;_FuncPtr object at 0x111a3fb38&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yes. This changes everything. The problem that has bedeviled shapely users is
caused by using dlopen to load a library that's already been loaded. We can avoid
the problem by detecting whether libgeos_c has already been loaded and skipping
the troublesome dlopen call. I've done this for shapely and made a new 1.7
pre-release. Please considering running &lt;code class="docutils literal"&gt;pip install &lt;span class="pre"&gt;-U&lt;/span&gt; &lt;span class="pre"&gt;--pre&lt;/span&gt; shapely&lt;/code&gt; to try
it out.&lt;/p&gt;
&lt;p&gt;The OS X man page for dlsym says that looking up functions in the global handle
is the slowest possible approach, but ctypes does cache the addresses of
functions it finds and my test programs don't run measurably slower, so this
just might work out.&lt;/p&gt;
&lt;p&gt;I'd like to understand why this problem doesn't also occur on Linux. Is it
because of differences in the library loaders or the executable file formats
themselves? Is there subtle platform-specific bug in GEOS? I'll write more if
I get to the bottom of this.&lt;/p&gt;</description><category>ctypes</category><category>DLL</category><category>geos</category><category>python</category><category>shapely</category><category>work</category><guid>https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html</guid><pubDate>Sun, 23 Jun 2019 19:54:00 GMT</pubDate></item><item><title>Shapely 1.7a1</title><link>https://sgillies.net/2018/07/30/shapely-1-7-a1.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;The first pre-release for Shapely 1.7 is up on PyPI &lt;a class="reference external" href="https://pypi.org/project/Shapely/1.7a1/#files"&gt;now&lt;/a&gt;. I'd be grateful if you
would &lt;code class="docutils literal"&gt;pip install &lt;span class="pre"&gt;shapely==1.7a1&lt;/span&gt;&lt;/code&gt; and try it out. Since 1.6 there have been
a few significant &lt;a class="reference external" href="https://github.com/Toblerity/Shapely/blob/master/CHANGES.txt#L4"&gt;changes&lt;/a&gt;. Still no
Windows wheels, but we're working on it.&lt;/p&gt;</description><category>python</category><category>shapely</category><category>work</category><guid>https://sgillies.net/2018/07/30/shapely-1-7-a1.html</guid><pubDate>Mon, 30 Jul 2018 16:47:05 GMT</pubDate></item><item><title>Shapely 1.6.3</title><link>https://sgillies.net/2017/12/10/shapely-1-6-3.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;Shapely 1.6.3 is on PyPI and &lt;a class="reference external" href="https://conda-forge.org/"&gt;conda-forge&lt;/a&gt; now. It
fixes 3 bugs involving empty or invalid geometries and adds to the manual
a &lt;a class="reference external" href="https://shapely.readthedocs.io/en/stable/manual.html#geometric-objects"&gt;note about potentially confounding effects of z coordinate values on
topological validity of geometric objects&lt;/a&gt;.&lt;/p&gt;</description><category>python</category><category>shapely</category><category>work</category><guid>https://sgillies.net/2017/12/10/shapely-1-6-3.html</guid><pubDate>Sun, 10 Dec 2017 15:19:53 GMT</pubDate></item><item><title>GIS Stack Exchange at its best</title><link>https://sgillies.net/2017/12/05/gis-se-at-its-best.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;A clear and intriguing question, no overzealous moderation, and an excellent
answer. This is the &lt;a class="reference external" href="https://gis.stackexchange.com/questions/264150/how-to-split-a-shapely-polygon-with-two-linestrings-and-get-the-middle-polygon"&gt;GIS Stack Exchange at its best&lt;/a&gt;.&lt;/p&gt;</description><category>gis</category><category>python</category><category>shapely</category><category>stack exchange</category><category>work</category><guid>https://sgillies.net/2017/12/05/gis-se-at-its-best.html</guid><pubDate>Tue, 05 Dec 2017 17:20:11 GMT</pubDate></item><item><title>Trued Macosx Wheels</title><link>https://sgillies.net/2017/10/31/trued-macosx-wheels.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;I've woken up from my &lt;a class="reference external" href="https://sgillies.net/2017/10/27/wobbly-fiona-and-shapely-wheels.html"&gt;Nightmare on C++ Street&lt;/a&gt; and have uploaded new
Rasterio, Fiona, and Shapely macosx wheels to PyPI. Use the pip requirement
specs below to get the latest and greatest compatible wheels.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;rasterio==1.0a11&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;fiona==1.7.10.post1&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;shapely==1.6.2.post1&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My Xcode command line tools were out of sync with my libraries, libc++abi.dylib
in particular. In the Xcode preferences there's an option to select versions
of the command line tools. On my home computer, I've got Xcode 7.2.1 and have
selected version 7.2.1 of the command line tools.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="https://c1.staticflickr.com/5/4476/38033571472_85c109ff96_b.jpg" src="https://c1.staticflickr.com/5/4476/38033571472_85c109ff96_b.jpg"&gt;
&lt;/figure&gt;
&lt;p&gt;On my work computer, where I've been building the wheels, I somehow ended up
with Xcode 8.2.1 and version 9.0.0 of the command line tools. I've never even
seen this preference before, but do remember accepting a command line tools
upgrade from Apple's App Store a while back. Reverting to command line tools
version 8.2.1 cleared up the segmentation faults reported and studied in
&lt;a class="reference external" href="https://github.com/sgillies/frs-wheel-builds/issues/20"&gt;https://github.com/sgillies/frs-wheel-builds/issues/20&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I hope this blog post finds the next person to trip over this Xcode and command
line tools mis-configuration.&lt;/p&gt;
&lt;p&gt;Now I'm going to go back into PyPI and remove the broken binary wheels for
older versions, leaving only the source distributions.&lt;/p&gt;</description><category>c++</category><category>fiona</category><category>macosx</category><category>python</category><category>rasterio</category><category>shapely</category><category>wheels</category><category>work</category><category>xcode</category><guid>https://sgillies.net/2017/10/31/trued-macosx-wheels.html</guid><pubDate>Tue, 31 Oct 2017 14:02:48 GMT</pubDate></item><item><title>Wobbly Fiona and Shapely Wheels</title><link>https://sgillies.net/2017/10/27/wobbly-fiona-and-shapely-wheels.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;On 2017-06-05 &lt;a class="reference external" href="https://github.com/sgillies/frs-wheel-builds/blob/master/CHANGES.txt#L18-L28"&gt;I began to use GDAL 2.2.0&lt;/a&gt;
in the Fiona binary wheels I upload to the Cheeseshop. I also changed the
&lt;code class="docutils literal"&gt;MACOSX_DEPLOYMENT_TARGET&lt;/code&gt; environment variable from 10.6 to 10.9 in order to
get GDAL 2.2.0 to compile. This seems to be the cause of Shapely and Fiona
wheel compatibility issues. Have I mentioned that I'm not completely competent
at C++ on OS X? I'm not.&lt;/p&gt;
&lt;p&gt;My co-worker Matt Perry provided a script that exposed this issue clearly and
I bisected in Fiona and Shapely version space until I found the root of the
problem.&lt;/p&gt;
&lt;p&gt;Until I get new wheels on PyPI, here are the three coping strategies.&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;Avoid the wheels entirely:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_43f0295f01334b49897e870e65f33141-1" name="rest_code_43f0295f01334b49897e870e65f33141-1" href="https://sgillies.net/2017/10/27/wobbly-fiona-and-shapely-wheels.html#rest_code_43f0295f01334b49897e870e65f33141-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;pip install -I --no-binary fiona,shapely fiona==1.7.10 shapely==1.6.2&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is what I do in my Dockerfiles at work. This strategy requires the GDAL
and GEOS libraries and headers to be pre-installed on your system, and also
Numpy and Cython.&lt;/p&gt;
&lt;ol class="arabic simple" start="2"&gt;
&lt;li&gt;&lt;p&gt;Downgrade Fiona, using wheels:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_6d0fcd4d3d67456992033ae8555d01d7-1" name="rest_code_6d0fcd4d3d67456992033ae8555d01d7-1" href="https://sgillies.net/2017/10/27/wobbly-fiona-and-shapely-wheels.html#rest_code_6d0fcd4d3d67456992033ae8555d01d7-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;pip install -I fiona==1.7.6&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;ol class="arabic simple" start="3"&gt;
&lt;li&gt;&lt;p&gt;Downgrade Shapely, using wheels:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_48f9e3f165744eee91a1feebc927ea41-1" name="rest_code_48f9e3f165744eee91a1feebc927ea41-1" href="https://sgillies.net/2017/10/27/wobbly-fiona-and-shapely-wheels.html#rest_code_48f9e3f165744eee91a1feebc927ea41-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;pip install -I shapely==1.6b4&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The issue affects Rasterio, too. Rasterio version 1.0a9 wheels should be safe
with any version of Shapely.&lt;/p&gt;
&lt;p&gt;I'll have an announcement about new wheels soon.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; (2017-10-31): the nightmare is &lt;a class="reference external" href="https://sgillies.net/2017/10/31/trued-macosx-wheels.html"&gt;over&lt;/a&gt;.&lt;/p&gt;</description><category>fiona</category><category>macosx</category><category>pypi</category><category>python</category><category>shapely</category><category>wheels</category><category>work</category><guid>https://sgillies.net/2017/10/27/wobbly-fiona-and-shapely-wheels.html</guid><pubDate>Fri, 27 Oct 2017 18:54:47 GMT</pubDate></item><item><title>Current status</title><link>https://sgillies.net/2017/08/30/current-status.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;I've been neglecting my open source projects this summer due to time
constraints. At Mapbox we've been onboarding a new President and COO and a raft
of new employees, plus a manager for my team at Mapbox. These are hugely
positive developments, but have also been a big lift.  Moving back to Colorado
and bringing our lives here out of suspension has similarly taken all of my
personal time. I've been the blocker for new releases of Fiona, Rasterio, and
Shapely all summer long and have been feeling rather guilty about it.&lt;/p&gt;
&lt;p&gt;Things are looking up now. My kids are back in school and have seen their
doctor and dentist. Their schedule of soccer practices and other activities for
the season is getting settled quickly. I'm resuming weekly yoga and gym
workouts along with my existing running schedule. I like having a weekly
routine; it helps me stay relaxed and gives me time for personal projects like
writing and computering.&lt;/p&gt;
&lt;p&gt;Open source continues to be a big part of my job and as my share of the
onboarding lift eases I've been able to increase my time on Fiona, Rasterio,
and Shapely. I released the long overdue Shapely 1.6.0 and have supported the
GeoPandas team on getting 0.3.0 out. Fiona 1.7.9 was the first bug fix release
of that project since June and I'm happy to have that in user hands. This week
I'm working on coding and writing about the upcoming Rasterio release. I feel
like I'm doing a good job as an open source maintainer and mentor again and am
excited about what I'll be able to do in the next few months.&lt;/p&gt;
&lt;p&gt;None of these projects would be viable without the help of other developers.
To my open source collaborators: thanks for hanging in there and being patient
with me!&lt;/p&gt;</description><category>fiona</category><category>open source</category><category>python</category><category>rasterio</category><category>shapely</category><category>work</category><guid>https://sgillies.net/2017/08/30/current-status.html</guid><pubDate>Wed, 30 Aug 2017 13:29:08 GMT</pubDate></item></channel></rss>