<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 11 May 2016 at 10:58, Matthew Brett <span dir="ltr"><<a href="mailto:matthew.brett@gmail.com" target="_blank">matthew.brett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div>On Tue, May 10, 2016 at 6:38 PM, Nathaniel Smith <<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>> wrote:<br>
> On Tue, May 10, 2016 at 3:09 PM, Leonardo Rochael Almeida<br>
> <<a href="mailto:leorochael@gmail.com" target="_blank">leorochael@gmail.com</a>> wrote:<br>
>> On 10 May 2016 at 18:52, Matthew Brett <<a href="mailto:matthew.brett@gmail.com" target="_blank">matthew.brett@gmail.com</a>> wrote:<br>
>>><br>
>>> On Tue, May 10, 2016 at 5:26 PM, Matthew Brett <<a href="mailto:matthew.brett@gmail.com" target="_blank">matthew.brett@gmail.com</a>><br>
>>> wrote:<br>
>>> >> [...]<br>
>>> >><br>
>>> >> This would probably look like:<br>
>>> >><br>
>>> >> _tkagg.so has a DT_NEEDED entry naming tkinter.so (or whatever Python<br>
>>> >> calls<br>
>>> >> this module)<br>
>>> >><br>
>>> >> Before loading _tkagg.so, we use Python level introspection figure out<br>
>>> >> where<br>
>>> >> tkinter.so lives<br>
>>> >><br>
>>> >> We add its directory to LD_LIBRARY_PATH<br>
>>> >><br>
>>> >> we import _tkagg.so<br>
>>> >><br>
>>> >> We take its directory back off of LD_LIBRARY_PATH<br>
>>> >><br>
>>> >> Very weird, but I can't see why it wouldn't work, and probably more<br>
>>> >> reliable<br>
>>> >> than anything where we try to reimplement the dynamic loader's search<br>
>>> >> logic<br>
>>> >> ourselves.<br>
>>> ><br>
>>> > Nice - yes - it does work in a first-pass test - I'll look into<br>
>>> > automating that.<br>
>>><br>
>>> Ah - except I do not believe it is possible to change the linker path<br>
>>> for Python modules, within the Python process:<br>
>>><br>
>>> <a href="http://www.gossamer-threads.com/lists/python/python/393770#393770" rel="noreferrer" target="_blank">http://www.gossamer-threads.com/lists/python/python/393770#393770</a><br>
><br>
> Doh :-(<br>
<br>
</div></div>Any other suggestions?<br></blockquote><div><br></div><div class="gmail_extra"><div class="gmail_quote"><div>Calling `patchelf` at runtime with the result of introspecting the `_tkinter.so` module? :-)</div><div><br></div><div>On a more serious note, even though it would be dangerous to call `sys.setdlopenflags()` with `RTLD_GLOBAL`, we could perhaps manually call:</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><ul><li>ctypes.CDLL("/path/to/introspected/libtk.so", DLFCN.RTLD_GLOBAL)<br></li><li>ctypes.CDLL("/path/to/introspected/libtcl.so", DLFCN.RTLD_GLOBAL)<br></li></ul></div><div>before importing a `_tkagg.so` with `libtk` and `libtcl` patchelf-removed (but not re-added).</div><div><br></div><div>We would be dumping only libtcl/tk's symbols in the namespace of other python extension modules.</div></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
I guess this will be a problem for the external library PEP?<br></blockquote><div><br></div><div>Likely, yes.</div><div><br></div></div></div></div>