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

About how to build and install pyqpbo on Macos #10

Open
gaoyangyiqiao opened this issue Apr 16, 2018 · 3 comments
Open

About how to build and install pyqpbo on Macos #10

gaoyangyiqiao opened this issue Apr 16, 2018 · 3 comments

Comments

@gaoyangyiqiao
Copy link

I encountered quite a lot problem with opengm, so I come back here..

1.run python setup.py build_ext --inplace
1.You will got some errors, change the setup.py file: delete the QPBOinstall.
3.Go to the QPBO-v1.3.src and find the instance.ini, change it to:

#include "QPBO.h"

#ifdef _MSC_VER
#pragma warning(disable: 4661)
#endif



template <> 
	inline void QPBO<int>::get_type_information(char*& type_name, char*& type_format)
{
	type_name = "int";
	type_format = "d";
}

template <> 
	inline void QPBO<float>::get_type_information(char*& type_name, char*& type_format)
{
	type_name = "float";
	type_format = "f";
}

template <> 
	inline void QPBO<double>::get_type_information(char*& type_name, char*& type_format)
{
	type_name = "double";
	type_format = "Lf";
}
// Instantiations
template class QPBO<int>;
template class QPBO<float>;
template class QPBO<double>;

which moves the instantiation to the bottom.
4.run python setup.py build_ext --inplace again.
And now you can use it normally I think. Copy the pyqpbo dir to your own project and then you'll be able to:
from pyqpbo import binary_grid, alpha_expansion_grid, binary_graph

@tomclavmaster
Copy link

Hi, can you be a little more clear with what you mean when you say: delete the QPBOInstall in setup.py. I've been having this issue and this guide is very helpful!

@gaoyangyiqiao
Copy link
Author

@tomclavmaster delete those lines in setup.py:

class QPBOInstall(build_ext):
    def run(self):
        # locate urlretrieve: with Python3, this has been moved to urllib.request
        import urllib
        if hasattr(urllib, "urlretrieve"):
            urlretrieve = urllib.urlretrieve
        else:
            import urllib.request
            urlretrieve = urllib.request.urlretrieve
            # fetch and unpack the archive. Not the nicest way...
        urlretrieve("http://pub.ist.ac.at/~vnk/software/QPBO-v1.3.src.tar.gz",
                    "QPBO-v1.3.src.tar.gz")
        tfile = tarfile.open("QPBO-v1.3.src.tar.gz", 'r:gz')
        tfile.extractall('.')
        build_ext.run(self)

Since you have changed the file in QPBO, while if you run setup.py these lines will download QPBO again, which will make your changing useless.

@andrewdavis3
Copy link

Steps 1-3 worked well on Mac OS Big Sur, but running pip install . --use-feature=2020-resolver made it so I didn't have to copy the pyqpbo dir to my project.

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