Porting to python3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
looo
Posts: 2616
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Sat Jul 28, 2018 6:33 am

For your information: PySide2/ pyqt5 wheels from pypi include qt. So theoretically it should be possible to use them in freecad but I don't know if everything we need is included. For conda qt5 and PySide2 are separated packages.
triplus
Posts: 8364
Joined: Mon Dec 12, 2011 4:45 pm

Re: Porting to python3

Postby triplus » Sun Jul 29, 2018 12:50 am

looo wrote:
Sat Jul 28, 2018 6:33 am
For your information: PySide2/ pyqt5 wheels from pypi include qt. So theoretically it should be possible to use them in freecad but I don't know if everything we need is included. For conda qt5 and PySide2 are separated packages.
I used the pip wheel install option when testing for availability of some methods. Available in PySide but got removed and after issue report got reintroduced in PySide2. I didn't do any tests but did wonder if things like header files are provided. And on how to persuade FreeCAD to find everything it needs when compiling. Quick look indicated things like header files are not available. But i didn't look in depth.

P.S. Waiting to test some delta updates:
Updating.png
Updating.png (41.47 KiB) Viewed 536 times
User avatar
kkremitzki
Posts: 1598
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: Porting to python3

Postby kkremitzki » Sun Jul 29, 2018 4:46 am

A bit ahead of schedule, PySide 2 was uploaded to the Debian NEW queue and approved by the FTP masters today. Things are accelerating for Python 3 support...

https://tracker.debian.org/pkg/pyside2
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Porting to python3

Postby NormandC » Sun Jul 29, 2018 6:14 am

kkremitzki wrote:
Thu Jul 26, 2018 10:19 pm
Indeed, hopefully it's OK to say that again we have Aleph Objects to thank and that if anyone reading this is considering a 3D printer purchase in the US, to consider a LulzBot! :)
I was wondering which company could fund this, I should have known! They already funded early development of TechDraw when Ian was working on it. They also contribute to Yorik's Patreon. They use Debian on their computers, so yeah, they're interested in FreeCAD's continued availability in Debian.

I sure wish more companies (apart from the well-known big software companies) were as committed to open source as Aleph Objects are. And I think it's perfectly OK to thank them and to advertise their awesome 3D printers now and then!

Full disclosure: back in December 2012/January 2013, I helped them convert SketchUp files of their TK-0 prototype (which became the TAZ v1.0) into FreeCAD files (I remodelled the parts from scratch actually). I would have been happy with mere thanks and maybe a t-shirt... Jeff Moe (the founder) gave me an AO-100!
looo
Posts: 2616
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Sun Jul 29, 2018 6:41 am

triplus wrote:I didn't do any tests but did wonder if things like header files are provided. And on how to persuade FreeCAD to find everything it needs when compiling.
True, I didn't think about headers. Maybe there will be a qt-package from pypi available in the future. I guess conda and pypi will merge at some point into one project. There are some efforts to make pypi packages install-able with conda directly and pypi with wheels theoretically is able to replace conda...
kkremitzki wrote:A bit ahead of schedule, PySide 2 was uploaded to the Debian NEW queue and approved by the FTP masters today. Things are accelerating for Python 3 support...
good news!
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Porting to python3

Postby ian.rees » Sun Jul 29, 2018 7:05 am

Code: Select all

pip3 install PySide2
does install a bunch of PySide2 and Shiboken2 headers. The Qt folks are still adjusting the packaging though - https://bugreports.qt.io/browse/PYSIDE-749 in particular seems like a good ticket to keep an eye on.
looo
Posts: 2616
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Sun Jul 29, 2018 12:39 pm

ian.rees wrote:does install a bunch of PySide2 and Shiboken2 headers.
That is true but the qt-headers are missing.
triplus
Posts: 8364
Joined: Mon Dec 12, 2011 4:45 pm

Re: Porting to python3

Postby triplus » Wed Aug 01, 2018 12:51 am

Good to hear Py3 and PySide2 efforts are advancing on the Debian front. Likely once we get over this obstacle things will settle a bit again. Conda effort in addition will likely provide an opportunity to be more on the "rolling" side of things (including the Conda based AppImage option). Note that there was a glitch involved. When it comes to zsync filename and url information and AppImage delta updates. When i tested a few days back there was no data to test the whole update procedure and as after @looo provided an updated FreeCAD Conda package. This exposed some issues that should be fixed now.

https://forum.freecadweb.org/viewtopic. ... 18#p247818

All in all it i guess comes down to a few MB of data on a daily basis (when no big package included in the AppImage gets updated).

P.S. I guess not that bad at all! ;)
User avatar
sgrogan
Posts: 5158
Joined: Wed Oct 22, 2014 5:02 pm

Re: Porting to python3

Postby sgrogan » Sun Aug 12, 2018 5:08 pm

I get a single Python syntax error.

Code: Select all

Traceback (most recent call last):
  File "C:\Users\Chris\Downloads\conda-win-py3-qt5-x64\bin\lib\unittest\case.py", line 59, in testPartExecutor
    yield
  File "C:\Users\Chris\Downloads\conda-win-py3-qt5-x64\bin\lib\unittest\case.py", line 605, in run
    testMethod()
  File "C:\Users\Chris\Downloads\conda-win-py3-qt5-x64\Mod\Test\TestPythonSyntax.py", line 44, in testAll
    test_python_syntax(mod_dir, self.whitelist)
  File "C:\Users\Chris\Downloads\conda-win-py3-qt5-x64\Mod\Test\TestPythonSyntax.py", line 19, in test_python_syntax
    ast.parse(py_file.read())
  File "C:\Users\Chris\Downloads\conda-win-py3-qt5-x64\bin\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 30760: character maps to <undefined>
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14315 (Git)
Build type: Release
Branch: master
Hash: 5f8f26824486b55b2bf72c579e95f0f6d4a19284
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)

Test build here (Download Link): https://github.com/FreeCAD/FreeCAD/rele ... 015_x64.7z
bartus
Posts: 1
Joined: Sun Aug 12, 2018 8:42 pm

Re: Porting to python3

Postby bartus » Sun Aug 12, 2018 8:48 pm

Have some issue after latest update of python (3.6 > 3.7) on my Arch-Linux machine.

Code: Select all

 42     cmake -DCMAKE_BUILD_TYPE=Release \
 43           -DCMAKE_INSTALL_PREFIX="/opt/${_appname}" \
 44           -DFREECAD_USE_OCC_VARIANT="Community Edition" \
 45           -DPYTHON_EXECUTABLE="/usr/bin/python3" \
 46           -DBUILD_QT5=ON
 47     make
make error log:

Code: Select all

[ 32%] Built target StdMeshers
/home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp: In constructor ‘App::Application::Application(std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&)’:
/home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:233:49: error: too few arguments to function ‘int _PyImport_FixupBuiltin(PyObject*, const char*, PyObject*)’
     _PyImport_FixupBuiltin(pAppModule, "FreeCAD");
                                                 ^
In file included from /usr/include/python3.7m/Python.h:126,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/Base/PyObjectBase.h:38,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.h:32,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:56:
/usr/include/python3.7m/import.h:115:17: note: declared here
 PyAPI_FUNC(int) _PyImport_FixupBuiltin(
                 ^~~~~~~~~~~~~~~~~~~~~~
/home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:274:58: error: too few arguments to function ‘int _PyImport_FixupBuiltin(PyObject*, const char*, PyObject*)’
     _PyImport_FixupBuiltin(pBaseModule, "__FreeCADBase__");
                                                          ^
In file included from /usr/include/python3.7m/Python.h:126,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/Base/PyObjectBase.h:38,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.h:32,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:56:
/usr/include/python3.7m/import.h:115:17: note: declared here
 PyAPI_FUNC(int) _PyImport_FixupBuiltin(
                 ^~~~~~~~~~~~~~~~~~~~~~
Current python implementation call `_PyImport_FixupBuiltin` which is an interal function, correct way of handling this could be found in gdb bugtracker https://sourceware.org/bugzilla/show_bug.cgi?id=23252