• Python3 for MPY

    From xqtr@77:2/102 to g00r00 on Sun Dec 20 10:07:18 2020
    I compiled python3.8 with the --shared option enabled and tried to use it with MPY scripts, but no lack. I get mixed results.

    - For sure the -y parameter of mystic, uses only the 2.7 version, cause when i use it, it doesn't find functions from the mystic_bbs module

    - When i use the GZ command from a menu, in one script it can't find also, mystic_bbs functions and on the included testpy3.mpy crashes after the sqlite3 import.

    Also i am not sure what value i have to enter in the configuration > general settings > python2/3 Library input box.

    Some enlightenment on the subject would be much appreciated :)

    :: XQTR :: Another Droid BBS :: andr01d.zapto.org:9999 :: xqtr@gmx.com

    --- Mystic BBS v1.12 A47 2020/11/23 (Raspberry Pi/32)
    * Origin: Another Droid BBS # andr01d.zapto.org:9999 (77:2/102)
  • From g00r00@77:1/138 to xqtr on Mon Jan 4 13:46:30 2021
    I compiled python3.8 with the --shared option enabled and tried to use
    it with MPY scripts, but no lack. I get mixed results.

    Same, it really only seems to work under Windows for me and I haven't been able to find the solution yet.

    - For sure the -y parameter of mystic, uses only the 2.7 version, cause when i use it, it doesn't find functions from the mystic_bbs module

    The existing engine is untouched, so -Y will only execute the old engine as you noted.

    The temporary/experimental menu commands for Python in the alpha are for the dual 2.7/3.x engine and they are the only way to test this engine. If we can get this working, then it will replace the old engine.

    Also i am not sure what value i have to enter in the configuration > general settings > python2/3 Library input box.

    By default the new engine looks for "libpython2.7.so.1.0" and "libpython3.8.so.1.0" in Linux. If you want it to attempt to load some other library, you would put the location/name of the library in those settings. This is for new engine only and its just for experimentation.

    Some enlightenment on the subject would be much appreciated :)

    Let me know if you have any more questions! Thanks for trying to test this!

    I haven't worked on it in weeks but I will try to get some time to try to work on it sometime soon.

    --- Mystic BBS v1.12 A47 2020/12/21 (Windows/64)
    * Origin: Sector 7 | Mystic WHQ (77:1/138)
  • From xqtr@77:2/102 to g00r00 on Wed Jan 6 10:37:53 2021
    Same, it really only seems to work under Windows for me and I haven't been to find the solution yet.

    Which unit/library you use for incorporating python into FPC? Is it Python4Delphi or this:
    https://wiki.freepascal.org/Using_Python_in_Lazarus_on_Windows/Linux

    I may dig it to find a solution... perhaps other developers have the same issues?

    By default the new engine looks for "libpython2.7.so.1.0" and "libpython3.8.so.1.0" in Linux. If you want it to attempt to load some ot library, you would put the location/name of the library in those settings. This is for new engine only and its just for experimentation.

    I'll try it, make some tests and report back.

    :: XQTR :: Another Droid BBS :: andr01d.zapto.org:9999 :: xqtr@gmx.com

    --- Mystic BBS v1.12 A47 2020/11/23 (Raspberry Pi/32)
    * Origin: Another Droid BBS # andr01d.zapto.org:9999 (77:2/102)
  • From g00r00@77:1/138 to xqtr on Wed Jan 6 08:57:19 2021
    Which unit/library you use for incorporating python into FPC? Is it Python4Delphi or this: https://wiki.freepascal.org/Using_Python_in_Lazarus_on_Windows/Linux

    Neither, its my own code. Mystic doesn't use any Pascal libraries.

    It looks like the second thing is a fork of Python4Delphi specifically for Lazarus.

    I'd be open to using Python4Delphi if its capable of dynamic embedding assuming we could get it working. It looks like they are planning to remove Python 2 support so Mystic would be Python 3 only.

    --- Mystic BBS v1.12 A47 2021/01/05 (Windows/64)
    * Origin: Sector 7 | Mystic WHQ (77:1/138)
  • From g00r00@77:1/138 to xqtr on Wed Jan 13 13:49:50 2021
    Same, it really only seems to work under Windows for me and I haven't to find the solution yet.

    Which unit/library you use for incorporating python into FPC? Is it Python4Delphi or this:

    Hey wanted to follow up with you on this.

    I installed a fresh copy of Ubuntu 20.04 and the latest Free Pascal last weekend and installed the latest Python4Delphi.

    I was able to get it to run a test script that loads SQLITE3 without any environment changes. This means that I could potentially switch to using Python4Delphi wrappers instead of my own, but they did already remove support for Python 2 so doing this would probably break every existing Python mod for Mystic. As a Python modder what are your thoughts on this? You would be forced to upgrade your code to Python 3.

    It also means that I can stop messing around with environment settings and look at my own code to figure out what I did wrong, so I could also potentially fix the Python 2 and Python 3 engine that I built on my own.

    --- Mystic BBS v1.12 A47 2021/01/05 (Windows/32)
    * Origin: Sector 7 | Mystic WHQ (77:1/138)
  • From xqtr@77:2/102 to g00r00 on Thu Jan 14 15:32:34 2021
    I was able to get it to run a test script that loads SQLITE3 without any environment changes. This means that I could potentially switch to using Python4Delphi wrappers instead of my own, but they did already remove supp for Python 2 so doing this would probably break every existing Python mod Mystic. As a Python modder what are your thoughts on this? You would be forced to upgrade your code to Python 3.

    As much as it hurts :) i think that Python3 is a must have for Mystic. All ready python2 support is dropping and it's getting harder to find help on the net... or Google is preferring to show Python3 results first.

    My mods would be easy to convert, even for a sysop, as the most common difference between python2 and 3, that i had to use, is clearing/deleting a list. So with just a search/replace it could be easy to fix. At least, i don't mind.

    Also, now days, linux distros don't have python2 pre-installed and also windows users, should have two versions of python on their systems. But if you drop support on Python2, there is no need for it at all. ;)

    You should only check and be sure, that P4D is compatible with your code and don't find in the future that causes you more trouble than it should be and have to revert back to python2 etc.

    It also means that I can stop messing around with environment settings and at my own code to figure out what I did wrong, so I could also potentially the Python 2 and Python 3 engine that I built on my own.

    Support on both versions should be great, so if this helps you, go for it.

    For me it's OK to go with Python3 ;)

    :: XQTR :: Another Droid BBS :: andr01d.zapto.org:9999 :: xqtr@gmx.com

    --- Mystic BBS v1.12 A47 2020/11/23 (Raspberry Pi/32)
    * Origin: Another Droid BBS # andr01d.zapto.org:9999 (77:2/102)
  • From g00r00@77:1/138 to xqtr on Thu Jan 14 14:10:12 2021
    My mods would be easy to convert, even for a sysop, as the most common difference between python2 and 3, that i had to use, is
    clearing/deleting alist. So with just a search/replace it could be easy
    to fix. At least, i don'tmind.

    Thats good to know. I don't really have any experience converting any significant code from Python 2 to 3.

    I do have some good news though. I was able to get the new engine working! I installed a fresh Ubuntu 20.04 then did "sudo apt install libpython2.7" and that was all I had to do to have a fully working Python 2 and 3 with Mystic's new engine.

    I have to re-introduce each of the Python functions from the old engine and test each one with Python 2 and 3 to be safe. I still have to test on macOS and ARM-based Linux before I can call it "ready".

    This example script now runs on Ubuntu 20.04 using both Python 2 and 3 out of the box with no configuration or environment changes required. Works fine in Windows too:

    import mystic_bbs as bbs
    import sqlite3
    import sys

    bbs.writeln("Hello from Mystic Python (Python Version " + sys.version)"

    x,y = bbs.termsize()

    bbs.writeln("Terminal size: " + str(x) + ", " + str(y))

    if bbs.shutdown():
    bbs.writeln("BBS is requesting script to shutdown")
    else:
    bbs.writeln("BBS is not asking for shutdown")

    bbs.writeln("|PA")

    --- Mystic BBS v1.12 A47 2021/01/14 (Windows/32)
    * Origin: Sector 7 | Mystic WHQ (77:1/138)