Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python bindings in 2019 #102

Open
CedricVanhaverbeke opened this issue Oct 24, 2019 · 2 comments
Open

Python bindings in 2019 #102

CedricVanhaverbeke opened this issue Oct 24, 2019 · 2 comments

Comments

@CedricVanhaverbeke
Copy link

Hi

I just successfully executed the command make swig and I wanted to give my feedback on how I did it.

  1. First things first, you should be able to execute make install in the root of the project. So before anything else, do this.
    This should install LibXtract to /usr/local. If that didn't work execute following command:
    make install PREFIX=/usr/local

  2. Next up, let's install swig:
    In Ubuntu (or WSL for that matter). This is done by these commands:

git clone https://github.com/swig/swig.git

cd swig
sudo apt-get install automake
./autogen.sh
./configure
sudo apt-get install bison flex
make
sudo make install

You can choose where you want to clone the project to. I just did it in the folder where I want to use LibXtract.

  1. when you'd execute 'make swig' in the root folder of the project you would probably get following error:
xtract_wrap.c:154:11: fatal error: Python.h: No such file or directory
 # include <Python.h>
           ^~~~~~~~~~
compilation terminated.

This is because the devtools of Python aren't installed or your OS cannot find them.
Before installing the devtools, check your Python version with python --version. You should install the right devtools for your version.

sudo apt-get install python<version here>-devtools

An overview of all the commands in different OS's: https://icetutor.com/question/fatal-error-python-h-no-such-file-or-directory/

I still had a problem. Even though I installed the devtools, I couldn't import Python.h . I use anaconda and that was the problem.

Open swig/Makefile in an editor of your choice and change the value of the -I flag to the location of your devtools. In anaconda you'd get something like /home/youruser/anaconda3/include/python3.6m.

So, on line 22 and 23 change these values:

	@swig -I/path/to/devtools -python $(NAME).i
	@$(CC) $(CFLAGS) $(NAME)_wrap.c -o $(NAME)_wrap.o -I$(INCLUDEPY) -I/path/to/devtools

Also, the provided test file is outdated. sei-nicolas created an alternative one in issue #93 (find it here)

I hope this helps!
cheers

@yaxu
Copy link

yaxu commented Jul 7, 2021

Thanks! In 2021, I had to install sudo apt install python3-dev, and edit swig/Makefile to remove -framework Accelerate. I'm not sure what this is.

I'm not sure how to actually install the python library, though..

@saitharun051
Copy link

Hello, after building the python wrapper I am getting the error saying unbound variable xtract_free_window while trying to use the import xtract. I have compiled the xtract_wrap.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants