jamescampbell has quit [Quit: Leaving...]
sms has joined #pypy
<sms> How do I pass a string into some embedded Python?
<sms> I keep getting Need 11 character video id or the URL of the video. Got //<cdata 'char *' 0x4006d8>
<sms> So I guess all I'm really doing is passing it a pointer
zware has quit [Ping timeout: 258 seconds]
zware has joined #pypy
ceridwen has joined #pypy
ceridwen has joined #pypy
ceridwen has quit [Changing host]
asmeurer_ has joined #pypy
tbodt has joined #pypy
yuyichao has quit [Ping timeout: 240 seconds]
jcea has quit [Quit: jcea]
tbodt has quit [Read error: Connection reset by peer]
_whitelogger has joined #pypy
lritter_ has joined #pypy
tbodt has joined #pypy
yuyichao has joined #pypy
lritter has quit [Ping timeout: 255 seconds]
ArneBab has joined #pypy
ArneBab_ has quit [Ping timeout: 240 seconds]
tbodt has quit [Ping timeout: 240 seconds]
tbodt has joined #pypy
tbodt has quit [Client Quit]
sophiya has joined #pypy
<sms> How the heck
gclawes_ has quit [Ping timeout: 245 seconds]
gclawes has joined #pypy
<sms> I'm so fed up
jamadden has quit [Quit: Leaving.]
pilne has quit [Quit: Quitting!]
oberstet2 has joined #pypy
jamesaxl has joined #pypy
plan_rich_ has quit [Ping timeout: 255 seconds]
arigato has joined #pypy
<arigato> sms: try ffi.string()
<sms> I tried that
<arigato> well, it would solve the only problem you pasted here, namely "//<cdata 'char *'>"
<sms> ffi.string(url) just gives me TypeError: initializer for ctype 'char *' must be a cdata pointer, not unicode
kbtr_ has quit [Ping timeout: 255 seconds]
plan_rich has joined #pypy
kbtr has joined #pypy
<arigato> no, I mean: ffi.string(some_cdata_object) => real_string
<sms> Yes
<sms> Did you check out the Gist?
<arigato> you did no paste any gist in the last 24 hours, or I'm missing it
<sms> Oh here
<arigato> well, yes
<arigato> rawURL() receives as argument a <char *>
<arigato> not a pythn string
<arigato> you need to add this as first line of 'def rawURL(url):'
<arigato> url = ffi.string(url)
<arigato> moreover, there is a more fundamental issue with the return type
<sms> Yeah my bad, that's what I tried
<arigato> I bet it fixed the problem but then you ran into a problem with the return type
<arigato> in C, you can't easily write functions that return "char *"
<sms> That's the error I had when I tried the url = ffi.string(url) solution
<arigato> ok, then I have no clue what you exactly mean, sorry
<arigato> if you add url=ffi.string(url) here, then I would bet that whatever error you got, you got from a different line
<arigato> can you check again?
<sms> Yeah I can try again
<arigato> in fact it looks like the error you'd get from the "return audio.url"
<arigato> a 'char *'-returning function cannot return a Python string (or unicode)
<arigato> in C, as I said, you can't easily write 'char *'-returning functions at all
<arigato> you need instead to write your function as receiving a buffer and a size, and fill it
<arigato> so in C you would write:
<arigato> char output[256];
<arigato> getRawURL(url, output, 256);
<sms> Oh alright this is what I get
<arigato> printf("%s\n", output);
<arigato> yes, that's the error about the return value
<sms> Ohhh okay
<sms> Hmm
<sms> So how do I use the data that way?
<arigato> in Python?
<sms> Nono in C
<arigato> just like I pasted?
<arigato> I pasted three lines that should replace the single line "printf("%s\n", rawURL(url));"
<arigato> in Python, the code is:
<arigato> def getRawURL(url, output, size):
<arigato> ...
<arigato> result = result[:size-1] # or error if too long, or something
<arigato> output[0:len(result)] = result
<arigato> output[len(result)] = '\x00'
<arigato> likely, you need before: result = result.encode('some_encoding')
<arigato> if 'result' is a unicode string
<arigato> (welcome to C! :-)
<sms> Ooooh that makes sense
<sms> I was sort of thinking that
<sms> What I figured would happen though is that
<sms> The characters would be located like a C style string and that at most I'd have to just iterate through the array of chars
<arigato> yes, you can also write for i in range(len(result)): output[i] = result[i]
<arigato> that's equivalent to output[0:len(result)] = result
<sms> Hm
<sms> arigato I really wish you were in here about...8 hrs ago haha
<arigato> :_)
oberstet3 has joined #pypy
<sms> So hey, I have a general question
oberstet2 has quit [Ping timeout: 268 seconds]
nanonyme has joined #pypy
<sms> Currently I'm using a virtualenv with an installed library, but of course the program no longer runs if I deactivate my virtualenv
<sms> Is it possible to build the project so that it's bundled together
<nanonyme> Hmm, is it possible to use API-mode for CFFI for Windows for eg CreateFileW? I'm trying to write something like https://github.com/nanonyme/win32cffi/blob/master/kernel32_builder.py
<nanonyme> It looks like it's creating empty lib so I should probably be adding libraries
<sms> And I don't have to either activate my virtualenv or install the library on my system to run the program
<arigato> sms: yes, but it's messy and operating-system-dependent
<sms> Hmm
<sms> How so?
<arigato> if you can recompile the library, there's an easier way
<sms> How so
<arigato> the first question is, are you using cffi embedding mode?
<arigato> I think so, if the main() is written in C
<sms> Yeah I'm embedding the Python in C using CFFI, but the Python library I'm using is installed with Pip and written in pure Cython
<arigato> this paragraph describes all I know:
<arigato> (note that, if you really meant Cython, then it's another unknown factor: I never tried using Cython with cffi)
<nanonyme> Also it's still not clear to me from documentation where I can use "..."
<arigato> the declarations of functions don't go into set_source()
tilgovi has joined #pypy
<arigato> paste them inside cdef(), and read the paragraph about _In_ on http://cffi.readthedocs.io/en/latest/cdef.html
<arigato> as well as the next paragraph about set_unicode(), likely
<nanonyme> Ahhh
<nanonyme> I somehow misread that as one function call >.<
marr has joined #pypy
asmeurer_ has quit [Quit: asmeurer_]
<arigato> nanonyme: about "...": you can ignore that in your case, because the Windows API is designed to be ABI-stable
<nanonyme> arigato, yeah, I was mainly wondering if I can be lazy when declaring the functions
<arigato> not the functions, but you can be lazy when declaring a large struct when you don't need most of the fields
<nanonyme> arigato, also, does set_unicode take care of defining UNICODE constant so compiler will consider CreateFile to be CreateFileW?
<arigato> yes
<nanonyme> Cool
<nanonyme> I should really write some test suite for at least some of this so it won't publish to PyPI even if the functions aren't actually accessible
<arigato> do you know about e.g. https://github.com/opalmer/pywincffi ?
<nanonyme> Crap, no
<nanonyme> Thanks a lot
* njs coughs
<njs> nanonyme: I suggested it in #twisted earlier :-)
<arigato> I just googled "cffi windows api"
<arigato> I wouldn't be surprized if there is already more than one
<njs> it's extremely easy to forget that step :-(
<nanonyme> njs, I somehow missed it
<nanonyme> arigato, yeah, my bad. It was the fifth hit after CFFI docs
<njs> I suspect it's not a simple replacement for what you want anyway, but it's a useful reference if nothing else
<nanonyme> I just want access to the WinAPI functions from Python in a way that I don't have to declare everything with ctypes. That's exhausting
<nanonyme> That's actually less thin of a layer I was thinking of, he apparently even bothered writing Python-side code
<nanonyme> Ugh, I'll delete the stuff from PyPI once I reboot back to Linux
<arigato> maybe there isn't a cffi project doing *just* the layer over the windows API, in that case your project is useful :-)
<arigato> I wonder if large parts of that API are not available somewhere in some preprocessed format (instead of .h files)
<njs> when I looked at it there was a lot of... stuff there, I wanted like 10% of it plus another 20% that wasn't there, so it seemed simplest to just do my own thing. cffi does make it pretty easy to do.
<arigato> ...or, well: I believe there is likely already one of the binding generators for cffi that can input Windows.h
<arigato> I mean I *guess* there is
<arigato> binding generators are tools written on top of cffi that input real .h files and turn them into cdef()
<njs> there's probably some awkward copyright issue there too
<arigato> heh, right
_whitelogger has joined #pypy
arigato has quit [Quit: Leaving]
girish946 has joined #pypy
sms has quit [Quit: WeeChat 1.8]
<nanonyme> What binding generators?
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
<nanonyme> njs, are you referring with copyright problems that you're statically linking against various Microsoft libraries?
<nanonyme> And then shipping resultant binary
<njs> nanonyme: no, I was talking about sucking in Windows.h and converting it into a chunk of cffi code
<nanonyme> Ah
<njs> nanonyme: obviously in practice no-one is going to complain about copying some prototypes off MSDN but there is some IP question there probably
<nanonyme> Yeah, I started wondering about that while writing my bindings
<nanonyme> As in, yes, *my* parts are under MIT but my parts were by far inferior parts of the bindings
<nanonyme> What is the rest licensed under?
<nanonyme> But yeah, on API-level you also have the issue that you statically link against other libraries. Using MIT might be fine, maybe. I'm pretty sure using GPL and shipping the result would violate the license Microsoft licenses their static libraries under though
<njs> what static linking are you referring to?
<nanonyme> Eg Kernel32.lib
<njs> you're not statically linking against e.g. kernel32.dll
<nanonyme> If you're using API-level, you use Kernel32.lib, not Kernel32.dll
<njs> eh, kernel32.lib is just a big table listing all the functions in kernel32.dll
<nanonyme> Right. Anyway, it's static linkage and license concerns apply
<njs> GPL says you can use proprietary stuff if it's part of the platform you're targeting, so linking against kernel32.dll is fine
<njs> and linking against kernel32.lib is just the windows linker's weird mechanism for dynamically linking against kernel32.dll, there's no actual code in kernel32.lib
<nanonyme> njs, where? I've never heard of that
aboudreault has quit [Excess Flood]
<nanonyme> As in, the GPL bit
<nanonyme> For the latter I find that totally believable
girish946 has quit [Ping timeout: 255 seconds]
<njs> nanonyme: for the gplv2 it's this clause: "However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs [...]"
aboudreault has joined #pypy
<nanonyme> Ah
<nanonyme> But yeah, the lib->dll sounds totally plausible as anything else would be a maintenance hell
<nanonyme> Microsoft probably wants to be capable of fixing bugs for everyone by just shipping a new kernel32.dll
<njs> (and in v3 there's a similar bit about "system libraries" being allowed to be closed source)
<njs> yeah, windows has no stable syscall abi
<njs> the stable abi is the first layer of dll's on top, like kernel32.dll
<nanonyme> Anyway, all in all, it seems like I should mostly just contribute to pywincffi to make sure it has the parts I need if it's missing something
girish946 has joined #pypy
tilgovi has quit [Ping timeout: 260 seconds]
<nanonyme> We need occasionally some slightly exotic parts of WinAPI
vkirilichev has joined #pypy
<fijal> hi
marr has quit [Ping timeout: 240 seconds]
nimaje is now known as Guest83209
Guest83209 has quit [Killed (card.freenode.net (Nickname regained by services))]
nimaje has joined #pypy
<nanonyme> njs, and yeah, I can't really just target those specific ones easily since what's needed might often change so it's best to just have as complete bindings as possible. win32api was one but it has a lot of downsides
girish946 has quit [Read error: Connection reset by peer]
vkirilichev has quit [Remote host closed the connection]
vkirilichev has joined #pypy
vkirilichev has quit [Remote host closed the connection]
_whitelogger has joined #pypy
girish946 has joined #pypy
girish946 has quit [Quit: Leaving]
jcea has joined #pypy
pilne has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
vkirilichev has joined #pypy
vkirilichev has quit [Remote host closed the connection]
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
amaury has joined #pypy
vkirilichev has joined #pypy
<Cheery> Hi
<Cheery> I'm implementing some of the RPython for translating Lever programs into SPIR-V or webassembly
<Cheery> And I got my bytecode converting to this so far: http://codepad.org/8X8HK52z
<Cheery> I feel I'm stressing a bit for the next step.
vkirilichev has quit [Remote host closed the connection]
jacob22_ has joined #pypy
asmeurer_ has joined #pypy
asmeurer_ has quit [Client Quit]
Arfrever has joined #pypy
oberstet3 has quit [Ping timeout: 255 seconds]
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
tormoz has joined #pypy
<nanonyme> njs, you don't happen to know the person behind pywincffi?
mattip has joined #pypy
<mattip> LarstiQ: I updated https://bitbucket.org/pypy/pypy/wiki/cpyext_2_-_cython_and_pandas, but there isn't much difference,
<mattip> just now the changes have been merged to HEAD on pandas, numpy
amaury has quit [Ping timeout: 240 seconds]
<mattip> plan_rich: ping
<kenaan> rlamy release-pypy3.5-5.x 9d7a5438be1d /: Let OrderedDict.__init__ behave like CPython wrt. subclasses overridding __setitem__ (grafted from c13a...
<kenaan> mattip default fd9441d99cc0 /pypy/doc/release-v5.8.0.rst: document graft of c13ae2a7e07a to release 3.5
<mattip> what to do about _vmprof.disable() hanging pypy?
<mattip> mess. Apparently PyPy needs antocuni's vmprof fix https://github.com/vmprof/vmprof-python/pull/142
<mattip> which was merged to vmprof but not uploaded to PyPI yet
<mattip> choices:
<mattip> 1) wait for the dust to settle and vmprof to work
<mattip> 2) release PyPY 5.8.0 without vmprof
<mattip> 3) give up and release a bugfix 5.7.2
<Arfrever> Or use unreleased version of vmprof?
<mattip> unfortunately there is still a bug with vmprof, even the released version AFAICT
<mattip> s/releases/unreleased/
amaury has joined #pypy
asmeurer_ has joined #pypy
asmeurer_ has quit [Client Quit]
ronan has quit [Ping timeout: 255 seconds]
ronan has joined #pypy
vkirilichev has joined #pypy
amaury has quit [Ping timeout: 255 seconds]
<LarstiQ> mattip: thanks
<LarstiQ> many more skipped
vkirilichev has quit [Remote host closed the connection]
yuyichao has quit [Quit: Konversation terminated!]
yuyichao has joined #pypy
amaury has joined #pypy
ansichart has joined #pypy
aboudreault has quit [Excess Flood]
tilgovi has joined #pypy
<ansichart> Hello, I am building pypy from source and finished packaging it to a .tar.bz2 package... When I unpack it, everything is under the "pypy-VER-PLATFORM" directory. Is it recommended to do a "mv pypy-VER-PLATFORM/* ./" so that /usr/local/ is the base, so I don't need to reconfigure my PATH variable?
<ansichart> since I originally unpacked it in /usr/local
<ansichart> My only concern is that if I do that, it might get mixed up with other things I install under /usr/local/
aboudreault has joined #pypy
<mattip> ansichart: in typical use, you will not add pypy-VER-platform to your path, rather simply run pypy with its full path as an executable
<mattip> plan_rich: I tried tracking down the line that hangs, it seems to be in the call to vmp_scan_profile (or rather the call to dump_native_signals which calls the former)
<mattip> will try to play more tomorrow
mattip has left #pypy ["bye"]
vkirilichev has joined #pypy
vkirilichev has quit [Remote host closed the connection]
vkirilichev has joined #pypy
<ansichart> I need to rebuild pypy from source with the "--shared" option, in order to get mod_wsgi to work. Do I need to clear anything out if rebuilding with the rpython scrip?
<ansichart> script*
marr has joined #pypy
<njs> nanonyme: no, haven't interacted with them at all
oberstet3 has joined #pypy
amaury has quit [Ping timeout: 255 seconds]
tilgovi has quit [Ping timeout: 246 seconds]
asmeurer_ has joined #pypy
tilgovi has joined #pypy
asmeurer_ has quit [Quit: asmeurer_]
Taggnostr2 has quit [Ping timeout: 240 seconds]
tbodt has joined #pypy
vkirilichev has quit [Remote host closed the connection]
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Taggnostr has joined #pypy
rubdos has quit [Ping timeout: 246 seconds]
tbodt has joined #pypy
Samureus has joined #pypy
Samureus has quit [Quit: Leaving]
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rubdos has joined #pypy