Open mneirynck opened 4 years ago
I have a patch to compile python for python 3... I asked brian if he want a seperate mod_python3 or not... Still waiting for his answer. I'll provide you a mod_python3 pull request soon
Any update on this in the meantime?
Any news on Python3 support for mod_python? Since Python 2 is EOL...
I always have hope to work on it but I don't ! :( I made python 3 ESL work (But the way I made it mean you have to clean and recompile if you want python 2 & python 3! As for mod_python3 itself, I got it so it compile if I remember correctly, but it is not working... I don't have a lot of knowledge in python integration... Or any type of sub language integration, but I know the patch I made doesn't work ! I hope for someone more knowledgeable than me to look it over and find what missing. It on my todo list to put more time on it in hope I can still figure out, but I don't know when that would be... It probably going to take a 40h+ for me to figure out when someone else that know more about language integration could do it in 1h!
Too bad that signalwire itself is not willing to dedicated time on it. We already indicated that we would even be willing to sponsor the work but they don't care.
I'm working on it right now. I've done some progress (few things needed tweak from my previous attempt). Will keep posted on how it goes !
UPDATE: I've got it to work I think ! Doing some test with an app of mine and will update my pull request.
Note, you cannot run Python2 and Python3 at the same time !
You cannot have python2 and python3 loaded at the same time within freeswitch ! I've spend lot of time on this for what was super easy, barely an inconvenience in the end ! Donation are welcome !
Test it out and let me know how it goes !
Hello,
Tested this issue with Python3.7 & Python3.8 and worked well, read below what i did the past hours
OS: Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-121-generic x86_64) on Proxmox
Python: Installed python3.8 and python3.8-dev from ppa (sudo add-apt-repository ppa:deadsnakes/ppa)
root@FS-1-10-5:/usr/local/freeswitch# sudo update-alternatives --config python
There are 4 choices for the alternative python (providing /usr/bin/python).
0 /usr/bin/python3.8 10 auto mode 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.6 2 manual mode 3 /usr/bin/python3.7 3 manual mode
Press
Above set the correct version to 4 = Python 3.8
Check if Python.h is available don't forget to install it! (sudo apt-get install python3.8-dev):
root@FS-1-10-5:/usr/local/freeswitch# updatedb root@FS-1-10-5:/usr/local/freeswitch# locate Python.h /usr/include/python2.7/Python.h /usr/include/python3.6m/Python.h /usr/include/python3.8/Python.h /usr/local/include/python3.7m/Python.h
Final check: root@FS-1-10-5:/usr/local/freeswitch# python Python 3.8.6 (default, Oct 6 2020, 03:22:36) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information.
Freeswitch:
Build FS 1.10.5 from source with the following settings
Change modules.conf, uncomment languages/mod_python3
languages/mod_lua
languages/mod_python3
make clean ./configure -C --with-python=/usr/bin/python3.8 make install sudo service freeswitch restart
Use fs_cli with the status command to take a you're work:
Type /help
+OK log level [7] freeswitch@FS-1-10-5> status UP 0 years, 0 days, 0 hours, 10 minutes, 21 seconds, 237 milliseconds, 485 microseconds FreeSWITCH (Version 1.10.5-release git 25569c1 2020-08-18 18:51:21Z 64bit) is ready 0 session(s) since startup 0 session(s) - peak 0, last 5min 0 0 session(s) per Sec out of max 30, peak 0, last 5min 0 1000 session(s) max min idle cpu 0.00/100.00 Current Stack Size/Max 240K/8192K
Now test python3.8 Install the ESL module for python
pip install python-ESL
Use the tes.py file from https://freeswitch.org/confluence/display/FREESWITCH/Python+ESL
''' single_command.py - execute a single command over ESL ''' from optparse import OptionParser import sys
import ESL
def main(argv): parser = OptionParser() parser.add_option('-a', '--auth', dest='auth', default='secret', help='ESL password') parser.add_option('-s', '--server', dest='server', default='127.0.0.1', help='FreeSWITCH server IP address') parser.add_option('-p', '--port', dest='port', default='8021', help='FreeSWITCH server event socket port') parser.add_option('-c', '--command', dest='command', default='status', help='command to run, surround multi-word commands in ""s')
(options, args) = parser.parse_args()
con = ESL.ESLconnection(options.server, options.port, options.auth)
if not con.connected():
print('Not Connected')
sys.exit(2)
# Run command
e = con.api(options.command)
if e:
print(e.getBody())
if name == 'main': main(sys.argv[1:])
When you run test.py is will give you the fs server status, the same as fs_cli:
webnext@FS-1-10-5:~$ /usr/bin/python /home/webnext/fs-test/test.py UP 0 years, 0 days, 0 hours, 15 minutes, 34 seconds, 831 milliseconds, 111 microseconds FreeSWITCH (Version 1.10.5-release git 25569c1 2020-08-18 18:51:21Z 64bit) is ready 0 session(s) since startup 0 session(s) - peak 0, last 5min 0 0 session(s) per Sec out of max 30, peak 0, last 5min 0 1000 session(s) max min idle cpu 0.00/91.67 Current Stack Size/Max 240K/8192K
or change default='status' in the line parser.add_option('-c', '--command', dest='command', default='status',
TO
parser.add_option('-c', '--command', dest='command', default='callcenter_config',
and rerun the scripts, you will receive the callcenter command set from FS
webnext@FS-1-10-5:~$ /usr/bin/python /home/webnext/fs-test/test.py
-USAGE:
callcenter_config
It was Fun to test it, keep on doing the good FS work!
Regards, Marcel from webnex.nl the Netherlands
Hello,
Tested this issue with Python3.7 & Python3.8 and worked well, read below what i did the past hours Regards, Marcel from webnex.nl the Netherlands
What did you test exactly ?
My latest patch doesn't have a mod_python3 module, I've merged it inside the mod_python module since they are mostly exactly the same for python3.
Also for ESL, my patch require you to build it for python 3.x.
All of what you tested here seem to be Python 2.7.
No, i was confused about compiling with option mod_python versus mod_python3. Successfully compiled FS with mod_python3 and tested with ESL. Needed this test for Qpanel (https://github.com/roramirez/qpanel) for FS Callcenter running with Python3.8.
@mochouinard I see that someone of Signalwire looked at your PR but that it has conflicts. https://github.com/signalwire/freeswitch/pull/191
Would you be willing to spend a little more time on it to get it through, it would be great to see Python3 support after all these years :) :)
+1
It seems mod_python is still not compiling properly on python3 (more specifically 3.8 in my case). I have been able to fix mod_python.c so it can compile (only changed the deprecated functions and ended with a pyFinalizeEx() instead of pyFinalize()), but i'm still getting fatal errors (an entire list of these recompile messages):
CXXLD mod_python.la /usr/bin/ld: /usr/local/lib/libpython3.8.a(abstract.o): relocation R_X86_64_PC32 against symbol
_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC`Any idea how i can recompile with -fPIC or how I can try and fix this? Or if there is a timeframe on python3 support, which is especially important with 2.7 getting EOL.
FreeSWITCH1.10 compiling from source on Debian10 with Python3.8 configure command used: ./configure --with-python=/usr/local/bin/python3.8 --enable-shared