flexxui / flexx

Write desktop and web apps in pure Python
http://flexx.readthedocs.io
BSD 2-Clause "Simplified" License
3.26k stars 257 forks source link

Support for Python 3.9 #674

Open MuuNU opened 4 years ago

MuuNU commented 4 years ago

I tried to run example file and got this

Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\flexxamples\demos\demo.py", line 7, in <module>
    from flexx import flx
ImportError: cannot import name 'flx' from 'flexx' (C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\flexx\__init__.py)

$ pip list

Package                Version    
---------------------- ---------  
astroid                2.4.2      
autopep8               1.5.4      
certifi                2020.6.20  
chardet                3.0.4      
colorama               0.4.4      
dialite                0.5.3      
flake8                 3.8.4      
flexx                  0.8.1      
idna                   2.10       
isort                  5.6.4      
jedi                   0.17.2     
lazy-object-proxy      1.4.3      
mccabe                 0.6.1      
parso                  0.7.1      
pip                    20.2.4     
pluggy                 0.13.1     
pscript                0.7.4      
pycodestyle            2.6.0      
pydocstyle             5.1.1      
pyflakes               2.2.0      
pylint                 2.6.0      
PySide2                5.15.1     
PySimpleGUI            4.30.0     
python-jsonrpc-server  0.4.0      
python-language-server 0.35.1     
requests               2.24.0     
rocket-python          1.2.15     
rocketchat-API         1.9.1      
rope                   0.18.0     
setuptools             50.3.2     
shiboken2              5.15.1     
six                    1.15.0     
snowballstemmer        2.0.0      
toml                   0.10.1     
tornado                6.0.4      
ujson                  4.0.1      
urllib3                1.25.11    
webruntime             0.5.8      
wrapt                  1.12.1     
yapf                   0.30.0     

$ python --version Python 3.9.0

MuuNU commented 4 years ago

In files:

\flexx\app\_app.py
\pscript\commonast.py

I found this lines:

from base64 import encodestring as encodebytes
from base64 import encodestring as encodebytes, decodestring as decodebytes

But in base64.py no encodestring/decodestring functions, because they was deleted in 3,9 branch of python

Please fix it, or add to documentation attention about flexx don`t work with 3,9 python

jrversteegh commented 4 years ago

Looks like python 2.7 compatibility imports maybe. I guess they can just be replaced by

from base64 import encodebytes, decodebytes

edit: Just tried that, but looks like there is a little bit more work to do...

almarklein commented 4 years ago

I renamed the title to reflect the bigger picture.

diego-rapoport commented 3 years ago

Looks like python 2.7 compatibility imports maybe. I guess they can just be replaced by

from base64 import encodebytes, decodebytes

edit: Just tried that, but looks like there is a little bit more work to do...

I did:

from base64 import encodebytes

and it worked with python 3.9.2 and flexx 0.8.1

almarklein commented 3 years ago

Thanks! Yeah replacing these imports might be enough. We should also update CI to make sure the tests pass for py39 too.

mschroen commented 3 years ago

I just installed flexx and the simplest example does not run because of this dusty bug. Can you please fix it in the next release? I'd like to use flexx for code that should run for many different users. We cannot expect everyone to change that line of code in the flexx package themselves ;-)

almarklein commented 3 years ago

It has been fixed in master. But I have not created a new release yet. In part because I'd like to be sure that everything works on py3.9 (in CI). Ideally we'd also move CI from Travis to GH Actions ...

Anyway, you can pip install -U https://github.com/flexxui/flexx/archive/master.zip to get the latest version

tticknor commented 2 years ago

Not a proficient user of Flexx, but following some recent updates it seems to not work properly for me on Windows10 with conda-managed python 3.9(.10 or .12).

Similar results on several similarly-configured machines. Running the basic demo.py from flexxamples, it renders the "Starting Flexx App" title, but nothing else. First error reported in the browser console is:

Uncaught SyntaxError: missing ) after argument list flexx-core.js:1658

which appears to be a malformed call to the JS function $Loop._process_actions

In order to isolate, I started a fresh Windows Sandbox Win10 VM, installed a fresh mini-conda environment (Python 3.9.10) and created several child environments for various versions of Flexx.

I have not had time to investigate in further detail, for my limited purposes sticking with 0.8.2 is probably fine.

Thank you for the work you have been putting into this.

almarklein commented 2 years ago

@tticknor Could you try updating pscript? The latest version is 0.7.7

almarklein commented 2 years ago

This looks like #711, where the new pscript caused an error in Flexx, which needed a fix. Maybe a similar error is triggered with the new Flexx, but an old pscript ...

tticknor commented 2 years ago

Using pscript 0.7.7 resolves the problem I noted above, all seems to work as expected.

Thank you for the suggestion and feedback.

almarklein commented 2 years ago

Ah, that makes sense. I've stopped actively maintaining my conda recipes since binary wheels have become ubiquitous.