poe-api icon indicating copy to clipboard operation
poe-api copied to clipboard

0.4.13 seems to break Python 3.11 compatibility

Open claell opened this issue 1 year ago • 10 comments

          note that quickjs package is not compatible with Python 3.11, so you may face an issue while trying to upgrade poe-api 0.4.13 :D

Originally posted by @asce0 in https://github.com/ading2210/poe-api/issues/184#issuecomment-1646871946

See comment above. Creating as separate issue to keep track of the problem.

claell avatar Jul 23 '23 16:07 claell

I put a note in the README about this. You need the python-dev package installed if you're on Linux.

ading2210 avatar Jul 23 '23 17:07 ading2210

Hopefully, in the future, Python 3.11 compatibility can be restored, though?

claell avatar Jul 23 '23 18:07 claell

I am on Windows, BTW.

claell avatar Jul 23 '23 18:07 claell

I am on Windows, BTW.

So how did you install quickjs 🤔

asce0 avatar Jul 23 '23 18:07 asce0

I didn't install it, I used an older Python version for now.

claell avatar Jul 23 '23 18:07 claell

Oh, my bad, I thought you did install it 😅

asce0 avatar Jul 23 '23 18:07 asce0

@ading2210 You can use js2py instead of quickjs. js2py works fine for Python 3.11

import js2py

def extract_formkey(self, html):
    script_regex = r'<script>(.+?)</script>'
    script_text = "window = {};"
    script_text += "".join(re.findall(script_regex, html))

    function_regex = r'(window\.[a-zA-Z0-9]{17})=function'
    function_text = re.search(function_regex, script_text).group(1)
    script_text += f"{function_text}();"

    formkey = js2py.eval_js(script_text)
    return formkey

ichuixue avatar Jul 24 '23 02:07 ichuixue

js2py is not sandboxed, and it's possible for a script to call Python functions.

ading2210 avatar Jul 24 '23 04:07 ading2210

I just found that someone has compiled quickjs for python3.11, and it seems worked for windows

https://github.com/PetterS/quickjs/issues/127

2-3-5-7 avatar Jul 28 '23 01:07 2-3-5-7

I put a note in the README about this. You need the python-dev package installed if you're on Linux.

I still can't install quickjs

> apt-get install python3-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-dev is already the newest version (3.11.2-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> pip install quickjs
...
ERROR: Could not build wheels for quickjs, which is required to install pyproject.toml-based projects

UchihaYuki avatar Sep 10 '23 03:09 UchihaYuki