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
segfault causing regression from PEP 573 implementation (PyQt5) #84754
Comments
e1becf4 causes pyqt5 to segfault an accessing an attribute To reproduce this: pip install pyqt5 Setting up faulthandler gives: jupiter@23:54 ➤ python -X faulthandler -c "import PyQt5.QtCore; PyQt5.QtCore.Qt.Key_Control" Current thread 0x00007f52111cd740 (most recent call first): It is likely that this should also be reported to riverbank as a pyqt/sip bug, but I'm starting here. I apologize for not having a simpler reproducing case. jupiter@00:01 ➤ git bisect log |
Sorry, forgot to add this is on Linux. |
I tried to install pyqt5 on Python compiled from source: make But I failed to install pyqt5: vstinner@apu$ env/bin/python -m pip install pyqt5
Collecting pyqt5
/home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/msgpack/fallback.py:133: DeprecationWarning: encoding is deprecated, Use raw=False instead.
unpacker = Unpacker(None, max_buffer_size=len(packed), **kwargs)
Using cached https://files.pythonhosted.org/packages/4d/81/b9a66a28fb9a7bbeb60e266f06ebc4703e7e42b99e3609bf1b58ddd232b9/PyQt5-5.14.2.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /home/vstinner/python/master/env/bin/python /home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpzl766kxn
cwd: /tmp/pip-install-a2jym86c/pyqt5
Complete output (33 lines):
Traceback (most recent call last):
File "/home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 64, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 66, in prepare_metadata_for_build_wheel
return _get_wheel_metadata_from_wheel(backend, metadata_directory,
File "/home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 95, in _get_wheel_metadata_from_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "/tmp/pip-build-env-w2h9381n/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "/tmp/pip-build-env-w2h9381n/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 82, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/tmp/pip-build-env-w2h9381n/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 410, in setup
self.apply_user_defaults(tool)
File "project.py", line 62, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-w2h9381n/overlay/lib/python3.9/site-packages/pyqtbuild/project.py", line 86, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-w2h9381n/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 215, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/tmp/pip-build-env-w2h9381n/overlay/lib/python3.9/site-packages/pyqtbuild/builder.py", line 67, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
/home/vstinner/python/master/Lib/tempfile.py:818: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/tmpqj0vy32i'>
_warnings.warn(warn_message, ResourceWarning)
ERROR: Command errored out with exit status 1: /home/vstinner/python/master/env/bin/python /home/vstinner/python/master/env/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpzl766kxn Check the logs for full command output. |
Ah, if I install Python, I can install PyQt5. I installed PyQt5: I also tested the following hello world, it doesn't crash neither. # https://pythonprogramminglanguage.com/pyqt5-hello-world/
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize
class HelloWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(640, 480))
self.setWindowTitle("Hello world - pythonprogramminglanguage.com")
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
gridLayout = QGridLayout(self)
centralWidget.setLayout(gridLayout)
title = QLabel("Hello World from PyQt", self)
title.setAlignment(QtCore.Qt.AlignCenter)
gridLayout.addWidget(title, 0, 0)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mainWin = HelloWindow()
mainWin.show()
sys.exit( app.exec_() ) I built Python with: ./configure --cache-file=../python-config.cache --with-pydebug CFLAGS=-O0 --prefix=/opt/py39 --with-system-expat --with-system-ffi What is your OS? How did you build Python? Which SIP and PyQt5 versions did you try? |
I also with: ./configure --prefix=/opt/py39 --with-system-expat --with-system-ffi I still cannot reproduce the crash. I tested Python at commit 1c2fa78. I tested on Fedora 32 (GCC 10.0.1). $ /opt/py39/bin/python3.9 -m pip freeze
pyflakes==2.2.0
pyperf==2.0.0
PyQt5==5.14.2
PyQt5-sip==12.7.2
$ /opt/py39/bin/python3.9 -VV
Python 3.9.0a6+ (heads/master:1c2fa78156, May 10 2020, 11:37:38)
[GCC 10.0.1 20200430 (Red Hat 10.0.1-0.14)] |
The script I used for the bisect was: --- TARGET_ENV=bisect_env rm -r ~/.pybuild/$TARGET_ENV || true popd source ~/.virtualenvs/$TARGET_ENV/bin/activate pushd ../sip # this was at "tip" in the hg repo python -c "import PyQt5.QtCore; PyQt5.QtCore.Qt.Key_Control" --- I'm on a relatively up-to-date Arch ➤ gcc --version --- updating pip is a key step (that I thoughtlessly carried over from my normal build process) because that lets it see manylinux2014 wheels and does not try to build pyqt5 from source. python3.9 -m pip freeze ➤ python3.9 -VV ---- I'm also having issues getting pyqt5 to compile from the tarball, what do you mean by "Ah, if I install Python, I can install PyQt5. I installed PyQt5:"? |
I think I have figured out the problem. I had a locally built and cached wheel of PyQt5-sip from before PEP-573 went in. If that wheel is used for later commits I get the segfault, if I rebuilt the wheel from source it works. I am not sure if this is an expected sharp edge (wheels are be expected to be good between commits prior to a release) or not. ----- Below is a script that will build everything (sip, pyqt5, pyqt5-sip) from source and install them into a virtual env. ---- rm -r ~/.pybuild/py39 || true ~/.pybuild/py39/bin/python3 -m venv --copies --clear ~/.virtualenvs/py39 source ~/.virtualenvs/py39/bin/activate pushd PyQt5 pushd PyQt5-5.14.2 python -c "import PyQt5.QtCore; PyQt5.QtCore.Qt.Key_Control" ---- |
Hum, I'm not sure that I understand well. Is there a bug in Python or not? It seems when in my tests, pip of Python 3.9 installed wheel package marked as "python38". I understand that the ABI didn't change and we are all good. I suggest to close the issue. |
The path is
I suspect that this also means that wheels made with the early alphas will not work future 3.9 (pre-)releases, however I am not sure if that is a problem or not (given that it is all pre-releases). I am going to close this as I think if there is a bug, it would be better addressed in the packaging space. |
The stable ABI should not change between Python 3.8 and 3.9. In practice, it seems like something changed. But without any gdb traceback, I cannot tell what. I suggest to try again when beta1 will be released. The ABI should be way more stable after beta1. |
So, the failure is expected. Python's ABI can change until the 3.9.0 final release, so wheels built for different commits can be incompatible. There is the PEP-384 stable ABI, which is much stricter (and more limited), but sip doesn't use it -- its wheels are specific to cp36/cp37/cp38: https://pypi.org/project/sip/#files Thanks for testing, though! Perhaps we need to communicate better that for the alphas/betas, everything needs to be rebuilt. |
That seems reasonable. To be pedantic, it is pyqt5-sip (not sip) that was the source of the problem. I am going to open an issue with pip to disable caching locally built wheels for pre-released versions of Python. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: