3
0
Fork 0
forked from mirrors/nixpkgs

hplip: use mkPythonDerivation

since hplip is a Python package that doesn't use setuptools. Note that a
setup.py is provided, however, using buildPythonPackage fails.
This commit is contained in:
Frederik Rietdijk 2016-10-26 10:29:04 +02:00
parent 85a87f5155
commit d9c7a14c6a

View file

@ -3,7 +3,7 @@
, cups, zlib, libjpeg, libusb1, pythonPackages, sane-backends, dbus, usbutils , cups, zlib, libjpeg, libusb1, pythonPackages, sane-backends, dbus, usbutils
, net_snmp, openssl, polkit , net_snmp, openssl, polkit
, bash, coreutils, utillinux , bash, coreutils, utillinux
, qtSupport ? true, qt4 , qtSupport ? true
, withPlugin ? false , withPlugin ? false
}: }:
@ -47,32 +47,27 @@ in
assert withPlugin -> builtins.elem hplipArch pluginArches assert withPlugin -> builtins.elem hplipArch pluginArches
|| throw "HPLIP plugin not supported on ${stdenv.system}"; || throw "HPLIP plugin not supported on ${stdenv.system}";
stdenv.mkDerivation { pythonPackages.mkPythonDerivation {
inherit name src; inherit name src;
buildInputs = [ buildInputs = [
libjpeg libjpeg
cups cups
libusb1 libusb1
pythonPackages.python
pythonPackages.wrapPython
sane-backends sane-backends
dbus dbus
net_snmp net_snmp
openssl openssl
] ++ stdenv.lib.optionals qtSupport [
qt4
]; ];
nativeBuildInputs = [ nativeBuildInputs = [
pkgconfig pkgconfig
]; ];
pythonPath = with pythonPackages; [ propagatedBuildInputs = with pythonPackages; [
dbus dbus
pillow pillow
pygobject2 pygobject2
recursivePthLoader
reportlab reportlab
usbutils usbutils
] ++ stdenv.lib.optionals qtSupport [ ] ++ stdenv.lib.optionals qtSupport [
@ -149,32 +144,7 @@ stdenv.mkDerivation {
rm $out/etc/udev/rules.d/56-hpmud.rules rm $out/etc/udev/rules.d/56-hpmud.rules
''; '';
fixupPhase = '' postFixup = ''
# Wrap the user-facing Python scripts in $out/bin without turning the
# ones in $out /share into shell scripts (they need to be importable).
# Note that $out/bin contains only symlinks to $out/share.
for bin in $out/bin/*; do
py=`readlink -m $bin`
rm $bin
cp $py $bin
wrapPythonProgramsIn $bin "$out $pythonPath"
sed -i "s@$(dirname $bin)/[^ ]*@$py@g" $bin
done
# Remove originals. Knows a little too much about wrapPythonProgramsIn.
rm -f $out/bin/.*-wrapped
# Merely patching shebangs in $out/share does not cause trouble.
for i in $out/share/hplip{,/*}/*.py; do
substituteInPlace $i \
--replace /usr/bin/python \
${pythonPackages.python}/bin/${pythonPackages.python.executable} \
--replace "/usr/bin/env python" \
${pythonPackages.python}/bin/${pythonPackages.python.executable}
done
wrapPythonProgramsIn $out/lib "$out $pythonPath"
substituteInPlace $out/etc/hp/hplip.conf --replace /usr $out substituteInPlace $out/etc/hp/hplip.conf --replace /usr $out
'' + stdenv.lib.optionalString (!withPlugin) '' '' + stdenv.lib.optionalString (!withPlugin) ''
# A udev rule to notify users that they need the binary plugin. # A udev rule to notify users that they need the binary plugin.