damian-666 / b-tk

Automatically exported from code.google.com/p/b-tk
0 stars 0 forks source link

Python 3.X support #82

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What should be the improvement?
Support the usage of python 3 for the btk bindings, in all supported OS's and 
architectures.

Could you detail it by giving examples (code, files)?

The issue is quite self-explanatory. I have all my code already working on 
python 3.4, and I just came across this really nice piece of software called 
btk, but it seems I'll have to stick to the matlab version for the time being 
(at least for the preprocessing), because mixing python versions in my code is 
a no-go.

I'm not an expert in SWIG, but I guess that the most difficult part is to 
generate the initial compatibility layer between C++ and SWIG. Once this is 
done, it should not involve much overhead to produce python 3.X bindings.

Anyway, thanks in advance for this great software!

Jorge

Original issue reported on code.google.com by yosoymic...@gmail.com on 1 Jul 2014 at 7:57

GoogleCodeExporter commented 8 years ago
+1 from me. Swig does support python 3, so it should be very easy to to build a 
btk for python 3. 
http://www.swig.org/Doc3.0/SWIGDocumentation.html#Python_python3support

Original comment by mel...@gmail.com on 17 Sep 2014 at 6:44

GoogleCodeExporter commented 8 years ago
Hi,
it is very easy indeed. I just compiled python 3 compatible bindings for linux 
by simply adding the string -py3 to the swig flags variable in the swig config 
file. I tried to compile it for windows but finally gave up because I had no 64 
bit compiler. In sum, if the build environment is properly configured to 
produce python 2 bindings, producing python 3 binding is straightforward.

Original comment by yosoymic...@gmail.com on 17 Sep 2014 at 7:55

GoogleCodeExporter commented 8 years ago
Hi again,
just to clarify, because it took some minutes to remember what I did once I 
have to repeat the process. It is a bit hackish, but for the time being it 
generates a fully functional (as far as I can tell) python 3 wrapper for b-tk.

Modify the file b-tk.core/Wrapping/Python/CMakeLists.txt 

In line 23 it says:
SET(CMAKE_SWIG_FLAGS "")

and should read
SET(CMAKE_SWIG_FLAGS "-py3")

That's it! If anyone can compile it for windows32/64, please share the library 
or the specific method, because I haven't been able after a couple of hours of 
frustation.

Best,
Jorge

Original comment by yosoymic...@gmail.com on 15 Dec 2014 at 4:10

GoogleCodeExporter commented 8 years ago
Hi,
I just noticed that the method I posted only generates functional python 
extensions for 32 bit versions. I haven't been able to determine the problem 
for 64 bit linux compilations, and for the time being I will give up on this 
because I use it mostly in a 32 bit distribution.

Original comment by yosoymic...@gmail.com on 7 Feb 2015 at 11:08

GoogleCodeExporter commented 8 years ago
Hi,

based on your comments, I manage to port generate python 3.4 bindings.
My os is a linux mint 17, 64 bit

Build and install cmake 3.1.3 with --qt-gui option (from here i can use python3 
compiler)
Modify the file b-tk.core/Wrapping/Python/CMakeLists.txt as you already 
mentionned.

Use cmake gui and build btk without bindings.
install btk with sudo make install in the terminal

Back to cmake-gui and enable binding.
configure give error finfing numpy, just add an entry NUMPY_VERSION and another 
named NUMPY_INCLUDE_DIR (pointing at 
/usr/lib/python3/dist_packages/numpy/core/include)
configure and build
and install again.

Finally, i don't know why but python files are not moved to the good place. I 
made it manually copying all the files in bin directory to 
/usr/local/lib/python3.4/dist-packages/btk. I also need to rename btk.py to 
__init__.py

With this method I manage to use btk in python3.4 idle and in blender python.

Original comment by marin_a...@yahoo.fr on 12 Mar 2015 at 4:12

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi,
I can confirm that your method to compile python 3 wrappers for amd64 linux 
works. Thanks for the nice explanation! I also had the same issue of having to 
manually move the wrapper to the appropiate location. I'm using a conda 
environment to run my analysis through ipython, and I had to move the 
"lib*.so*" files of the bin directory (so not the "_btk.so" file) in the lib 
directory of the conda installation.

I used the cmake version available in this ppa:
https://launchpad.net/~george-edison55/+archive/ubuntu/cmake-3.x

Original comment by yosoymic...@gmail.com on 24 Mar 2015 at 4:03