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

compile against python 2.7 (on osx) #13

Open
iltommi opened this issue Mar 9, 2016 · 6 comments
Open

compile against python 2.7 (on osx) #13

iltommi opened this issue Mar 9, 2016 · 6 comments
Labels

Comments

@iltommi
Copy link

iltommi commented Mar 9, 2016

Hi,
I'm trying to use cmake to compile python qt on osx wth qt with qt installed via homebrew:

/usr/local/opt/qt5/bin/qmake --version
QMake version 3.0
Using Qt version 5.5.1 in /usr/local/Cellar/qt5/5.5.1_2/lib

I cmaked with

10:56 ~/PythonQt/my_build > cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-5 -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/ ..
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/local/bin/gcc-5
-- Check for working C compiler: /usr/local/bin/gcc-5 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/bin/g++-5
-- Check for working CXX compiler: /usr/local/bin/g++-5 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.6") 
-- Qt5WidgetsConfig.cmake
-- Qt5WidgetsConfig.cmake
-- Qt5WidgetsConfig.cmake
-- Qt5WidgetsConfig.cmake
-- Building Qt5Python27 + Qt5Python27_QtAll (shared Qt 5.5.1 + Python 2.7.10 | Release | Static)
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tommaso/PythonQt/my_build

but get this error

[  9%] Building CXX object src/CMakeFiles/Qt5Python27.dir/PythonQtImporter.cpp.o
cd /Users/tommaso/PythonQt/my_build/src && /usr/local/bin/g++-5   -DPYTHONQT_STATIC -DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I/usr/include/python2.7 -I/Users/tommaso/PythonQt/src -iframework /usr/local/opt/qt5/lib -I/usr/local/opt/qt5/lib/QtCore.framework/Headers -I/usr/local/opt/qt5/./mkspecs/macx-clang -I/usr/local/opt/qt5/lib/QtGui.framework/Headers -I/System/Library/Frameworks/OpenGL.framework/Headers -I/usr/local/opt/qt5/lib/QtWidgets.framework/Headers  -O3 -DNDEBUG   -fPIC -o CMakeFiles/Qt5Python27.dir/PythonQtImporter.cpp.o -c /Users/tommaso/PythonQt/src/PythonQtImporter.cpp
/Users/tommaso/PythonQt/src/PythonQtImporter.cpp: In function 'PyObject* PythonQtImporter_get_data(PyObject*, PyObject*)':
/Users/tommaso/PythonQt/src/PythonQtImporter.cpp:356:18: error: 'PyExc_FileNotFoundError' was not declared in this scope
     PyErr_Format(PyExc_FileNotFoundError, "Resource not found: %s", path);
                  ^
make[2]: *** [src/CMakeFiles/Qt5Python27.dir/PythonQtImporter.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/Qt5Python27.dir/all] Error 2
make: *** [all] Error 2

Which looks like a missing reference to python3 error.

What did I miss? So, my questions are:

  1. How to tell to compile for python2.7
  2. Is there a way to tell cmake to use the python framework located in python-config --prefix /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7

Thanks

p.s. I have to change the default compiler to g++5 otherwise I get these errors HERE

@Optiligence
Copy link
Contributor

Why did you set PYTHON_LIBRARY (and especially why to a directory)? The warnings even tell you that this seems to be wrong.
Try adding your python prefix to CMAKE_PREFIX_PATH like you did with qt.

@iltommi
Copy link
Author

iltommi commented Mar 9, 2016

Ohhh my bad, I copy/pasted a command I tryed... I've update the text above with the current error and cmake config.
Sorry

@Optiligence
Copy link
Contributor

The second sentence still stands.
Cool that the buggy pyport.h incidentally works with GCC 5.

@Orochimarufan
Copy link
Owner

Actually I think this is (at the very least partlially) my fault. I forgot all about Python 2.x when implementing PQI.get_data().
The FileNotFoundError exception was introduced as subclass of OSError with the Python 3k exception hierarchy restruturing.
This problem needs to be fixed by raising a OSError with ENOENT manually on 2.x.
If I get around to it, I'll fix up a patch tonight

P.S.: People should just start using Python 3 :(

@Orochimarufan Orochimarufan changed the title compile on osx compile against python 2.7 (on osx) Mar 9, 2016
@Orochimarufan
Copy link
Owner

About the other issue (having to use g++):
XCode seems to dislike how PythonQt deals with stl things it seems. I'm not sure how to fix that without breaking current code relying on stl integration.
You might want to try #5.

EDIT: Lastly, about using a custom python istall: See https://cmake.org/cmake/help/v3.0/module/FindPythonLibs.html

@Orochimarufan
Copy link
Owner

The Importer.get_data issue is fixed by 3134043

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

No branches or pull requests

3 participants