cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://quodlibet.duckdns.org/irc/pypy/latest.log.html#irc-end ) | use cffi for calling C | if a pep adds a mere 25-30 [C-API] functions or so, it's a drop in the ocean (cough) - Armin
<kenaan>
stevie_92 cpyext-gc-cycle a3a571806246 /rpython/memory/gc/: Implemented working set for linked objects during rrc marking Removed debug output
jvesely has quit [Quit: jvesely]
buration has joined #pypy
buration has left #pypy [#pypy]
lritter has joined #pypy
<_aegis_>
cffi question. I use `lib = ffi.dlopen(None)` not to get access to libc, but to get automatic symbol resolving for stuff already imported by my main executable
<_aegis_>
this works great on mac and linux because of how dlsym works
<_aegis_>
but doesn't work on windows
<_aegis_>
I already tried to turn my application into a dll and dlopen() that, but it doesn't quite capture the previous behavior
<_aegis_>
so now I'm entering horrible hacks land where I will implement ffi.dlopen myself from inside python
<_aegis_>
if I implement a workable ffi.dlopen(None) that just loads optimistically from the global module namespace on windows to kinda match the linux/mac behavior, would cffi integrate that?
<_aegis_>
as right now ffi.dlopen(None) on windows just throws an error
antocuni has quit [Ping timeout: 265 seconds]
CrazyPython has joined #pypy
CrazyPython has quit [Read error: Connection reset by peer]
<_aegis_>
(I had that floating around because I used it in a single file project I called "crossldso" that loaded a linux library on a mac using just cffi and an ELF parser)
CrazyPython has quit [Read error: Connection reset by peer]
CrazyPython has joined #pypy
tsaka_ has quit [Ping timeout: 246 seconds]
<arigato>
_aegis_: that looks like a hack. I think it's best if it stays outside cffi, but maybe it can be mentioned in the docs
<arigato>
it only makes sense if you start with the linux/osx mindset and want to port it forcefully to windows
CrazyPython has quit [Read error: Connection reset by peer]
<arigato>
in general, "search all opened DLLs for a symbol that would be correctly named and use that" looks like a disaster waiting to happen (more than on linux/osx because there people know of the problem and are more careful about naming their functions)
<kenaan>
rlamy default 8330eedbb70c /pypy/conftest.py: Prevent all -A tests from being skipped
<_aegis_>
arigato: it's been really annoying to port to windows without this, cffi at least needs "import from a small list of named libraries as well as the executable" to come close without a hack
<_aegis_>
like dlopen(None, "lib1", "lib2") and to resolve symbols from the ffi in the order of executable's module -> lib1 -> lib2
<_aegis_>
I'd even be a little happier with "instantiate this FFI or CompiledFFI using an arbitrary symbol loader"
<_aegis_>
than the current situation where the only way to use CFFI for my case on windows is to use a non-CompiledFFI and manually jam the integer consts and functions onto an object
kingsley has quit [Remote host closed the connection]
<_aegis_>
what's the closest thing you'd accept as a PR that would make this less gross on my end?
ronan__ has quit [Ping timeout: 246 seconds]
<_aegis_>
I still think doing it with dlopen(None) is better than the current state of dlopen(None) throwing an error
<_aegis_>
one way to get around collisions would be to refuse to dlsym anything that was defined in more than one module
<_aegis_>
so you walk the whole module list and only return an address if only one module defined the symbol, otherwise it's up to the user to disambiguate
<_aegis_>
that prevents the footgun from doing anything too unexplainable but still improves my case significantly
<_aegis_>
(if it's not clear, I'm not proposing to polyfill this from python like my current code, I'd special case having a NULL module handle in misc_win32.h)