pyqt5: use sip_5 for Python 3

This commit is contained in:
Eduardo Sánchez Muñoz 2021-01-07 16:56:39 +01:00
parent fb7b08de32
commit 6347fdf071

View File

@ -15,7 +15,10 @@ let
inherit (pythonPackages) buildPythonPackage python isPy3k dbus-python enum34; inherit (pythonPackages) buildPythonPackage python isPy3k dbus-python enum34;
sip = (pythonPackages.sip.override { sip-module = "PyQt5.sip"; }).overridePythonAttrs(oldAttrs: { sip = if isPy3k then
pythonPackages.sip_5
else
(pythonPackages.sip.override { sip-module = "PyQt5.sip"; }).overridePythonAttrs(oldAttrs: {
# If we install sip in another folder, then we need to create a __init__.py as well # If we install sip in another folder, then we need to create a __init__.py as well
# if we want to be able to import it with Python 2. # if we want to be able to import it with Python 2.
# Python 3 could rely on it being an implicit namespace package, however, # Python 3 could rely on it being an implicit namespace package, however,
@ -28,6 +31,20 @@ let
''; '';
}); });
pyqt5_sip = buildPythonPackage rec {
pname = "PyQt5_sip";
version = "12.8.1";
src = pythonPackages.fetchPypi {
inherit pname version;
sha256 = "30e944db9abee9cc757aea16906d4198129558533eb7fadbe48c5da2bd18e0bd";
};
# There is no test code and the check phase fails with:
# > error: could not create 'PyQt5/sip.cpython-38-x86_64-linux-gnu.so': No such file or directory
doCheck = false;
};
in buildPythonPackage rec { in buildPythonPackage rec {
pname = "PyQt5"; pname = "PyQt5";
version = "5.15.2"; version = "5.15.2";
@ -69,8 +86,7 @@ in buildPythonPackage rec {
propagatedBuildInputs = [ propagatedBuildInputs = [
dbus-python dbus-python
sip ] ++ (if isPy3k then [ pyqt5_sip ] else [ sip enum34 ]);
] ++ lib.optional (!isPy3k) enum34;
patches = [ patches = [
# Fix some wrong assumptions by ./configure.py # Fix some wrong assumptions by ./configure.py
@ -103,7 +119,7 @@ in buildPythonPackage rec {
runHook postConfigure runHook postConfigure
''; '';
postInstall = '' postInstall = lib.optionalString (!isPy3k) ''
ln -s ${sip}/${python.sitePackages}/PyQt5/sip.* $out/${python.sitePackages}/PyQt5/ ln -s ${sip}/${python.sitePackages}/PyQt5/sip.* $out/${python.sitePackages}/PyQt5/
for i in $out/bin/*; do for i in $out/bin/*; do
wrapProgram $i --prefix PYTHONPATH : "$PYTHONPATH" wrapProgram $i --prefix PYTHONPATH : "$PYTHONPATH"
@ -116,8 +132,10 @@ in buildPythonPackage rec {
EOF EOF
''; '';
installCheckPhase = let # Checked using pythonImportsCheck
modules = [ doCheck = false;
pythonImportsCheck = [
"PyQt5" "PyQt5"
"PyQt5.QtCore" "PyQt5.QtCore"
"PyQt5.QtQml" "PyQt5.QtQml"
@ -129,13 +147,6 @@ in buildPythonPackage rec {
++ lib.optional withMultimedia "PyQt5.QtMultimedia" ++ lib.optional withMultimedia "PyQt5.QtMultimedia"
++ lib.optional withConnectivity "PyQt5.QtConnectivity" ++ lib.optional withConnectivity "PyQt5.QtConnectivity"
; ;
imports = lib.concatMapStrings (module: "import ${module};") modules;
in ''
echo "Checking whether modules can be imported..."
${python.interpreter} -c "${imports}"
'';
doCheck = true;
enableParallelBuilding = true; enableParallelBuilding = true;