Porting to python3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Porting to python3

Post by triplus »

Some issues will for sure emerge, when it comes to FreeCAD 0.18 Py3 builds. But i don't know if it makes sense to worry about that too much for now.
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Porting to python3

Post by reox »

kkremitzki wrote: Mon Jun 12, 2017 12:17 am
zaleksf wrote: Sun Jun 11, 2017 11:46 pm I'm attempting to build the py3-27 version, but no-luck. It fails when attempting to link the libSMESH.so library (see below). I was able ot compile the py3-26 version.
You need to use mpic++ as your CXX compiler, so e.g. add this flag to cmake:

-DCMAKE_CXX_COMPILER=/usr/bin/mpic++
Is it really necessary to use a MPI compiler? I usually compile with a normal gcc and it seems to work.
Would the MPI compiler just add the parallelism?

sorry to excavate the thread here, but I did not wanted to create a new one ;)
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Porting to python3

Post by vocx »

reox wrote: Thu Jan 30, 2020 7:09 pm ...
sorry to excavate the thread here, but I did not wanted to create a new one ;)
You are reading old information.

This flag is not needed. If you have all requisites you only need this line to configure the build.

Code: Select all

cmake -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 freecad-source
CompileOnUnix
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Porting to python3

Post by reox »

vocx wrote: Thu Jan 30, 2020 9:40 pm CompileOnUnix
okay thanks for the clarification! I was just consolidating old buildscripts and saw that some used mpic++
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: Porting to python3

Post by iplayfast »

I'm trying to build, and was successful when I didn't worry about python3, Now trying with python 3 using the following cmake

Code: Select all

 cmake .. -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_VERSION=3.6 -DFREECAD_USE_PCL=ON 
I'm getting a lot of errors related to PyString which google says is python2 only.
The errors thus far are in cxx_extensions.cxx

Is there a workaround for this?

*edit*
I just added #error codes and it shows that it is definitely trying to compile for python2, when I asked for python3. So how to I insist on python3?
Attachments
out.txt
(23.02 KiB) Downloaded 39 times
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Porting to python3

Post by PrzemoF »

What system? Clean directory build? Source repository updated recently? Can you post full cmake output (configuration stage)?
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: Porting to python3

Post by iplayfast »

clean directory build (mkdir build, cd build, cmake .. style) , linux.

I just did a

Code: Select all

make VERBOSE=1 >out.txt
and it shows the following:

Code: Select all

cd /home/chris/github/freecad-source/build/src/Base && /usr/bin/c++  -DFreeCADBase_EXPORTS -DHAVE_CONFIG_H -DHAVE_SWIG=1 -DQT_CORE_LIB -DQT_NO_DEBUG -D_OCC64 -DvtkFiltersFlowPaths_AUTOINIT="1(vtkFiltersParallelFlowPaths)" -DvtkIOExodus_AUTOINIT="1(vtkIOParallelExodus)" -DvtkIOGeometry_AUTOINIT="1(vtkIOMPIParallel)" -DvtkIOImage_AUTOINIT="1(vtkIOMPIImage)" -DvtkIOParallel_AUTOINIT="1(vtkIOMPIParallel)" -DvtkIOSQL_AUTOINIT="2(vtkIOMySQL,vtkIOPostgreSQL)" -DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL)" -DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL)" -DvtkRenderingFreeType_AUTOINIT="2(vtkRenderingFreeTypeFontConfig,vtkRenderingMatplotlib)" -DvtkRenderingLIC_AUTOINIT="1(vtkRenderingParallelLIC)" -DvtkRenderingVolume_AUTOINIT="1(vtkRenderingVolumeOpenGL)" -I/home/chris/github/freecad-source/build -I/usr/include/vtk-6.3 -I/usr/include/freetype2 -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/lib/x86_64-linux-gnu/openmpi/include -I/usr/include/python2.7 -I/usr/include/hdf5/openmpi -I/usr/include/libxml2 -I/usr/include/jsoncpp -I/usr/include/tcl -I/home/chris/github/freecad-source/build/src -I/home/chris/github/freecad-source/src -I/home/chris/github/freecad-source/build/src/Base -I/home/chris/github/freecad-source/src/Base -I/usr/include/python3.6m -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++  -Wall -Wextra -Wno-write-strings  -fPIC   -I/usr/include/openmpi -I/usr/include/hdf5/openmpi -pthread -I/usr/lib/x86_64-linux-gnu/openmpi/include -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -fPIC -std=gnu++11 -o CMakeFiles/FreeCADBase.dir/__/CXX/cxx_extensions.cxx.o -c /home/chris/github/freecad-source/src/CXX/cxx_extensions.cxx
src/Base/CMakeFiles/FreeCADBase.dir/build.make:213: recipe for target 'src/Base/CMakeFiles/FreeCADBase.dir/__/CXX/cxx_extensions.cxx.o' failed
Note -I/usr/include/python2.7 AND -I/usr/include/python3.6m
I think this is where the problem lies. where is the python2.7 coming from?
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: Porting to python3

Post by iplayfast »

PrzemoF wrote: Wed Jun 17, 2020 3:20 pm What system? Clean directory build? Source repository updated recently? Can you post full cmake output (configuration stage)?
cmake output attached
Attachments
out.txt
(5.84 KiB) Downloaded 35 times
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Porting to python3

Post by wmayer »

Looks like it's pulled in by a third party library -- possibly by the vtkPython component. What's the content of vtkPython.cmake (you may find it under /usr/lib/cmake/vtk-6.3/Modules)?

In case you don't need the python2.7-dev package for anything else then it's best to uninstall it.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Porting to python3

Post by PrzemoF »

Shiboken2Config: Using default python: -python2.7.x86_64-linux

What shiboken do you have installed?
Post Reply