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

hplipWithPlugin: various commands broken by .py wrapping #24263

Closed
benley opened this issue Mar 24, 2017 · 9 comments
Closed

hplipWithPlugin: various commands broken by .py wrapping #24263

benley opened this issue Mar 24, 2017 · 9 comments
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: printing 6.topic: python

Comments

@benley
Copy link
Member

benley commented Mar 24, 2017

For some reason, various .py files in hplip appear to be wrapped in bash startup wrappers as though they were standalone binaries. For example, ${hplipWithPlugin}/share/hplip/hpssd.py} contains the following:

#! /nix/store/86blj9iqyxwmdgkn3dyrpib1gkbmz91v-bash-4.4-p5/bin/bash -e
export PATH=/nix/store/d939y5gldj6fs3k366pni3f9l104nh8x-python-2.7.13/bin:/nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/bin:/nix/store/ml7b9bnzr8g1wj85f76szy95wh5ln3jx-expat-2.2.0-dev/bin:/nix/store/4isj683cw90w3dx3rfx9z4rqs462ga15-dbus-1.10.16-lib/bin:/nix/store/594h2zrinydqs6dl41pnfzsnak075pa8-dbus-1.10.16/bin:/nix/store/3b2dbbfaqvdvivmr9n8jjq43wqb05c9m-python2.7-Pillow-3.4.2/bin:/nix/store/v3w03f57ws8sqbh4nynf6v2l5r77ky6x-python2.7-setuptools-30.2.0/bin:/nix/store/77l777x243yqsfqlrgf4avj8hi3bjig8-python2.7-pygobject-2.28.6/bin:/nix/store/28xqb140djy6xnasyr3m7vskj2w50w5p-usbutils-008/bin:/nix/store/7af16bh6jyi0h90cldm0xj1qi2zywabs-python2.7-PyQt-x11-gpl-4.11.3/bin:/nix/store/mnc5am0bqldvs6nydvaindlpny1pb31g-python2.7-sip-4.18.1/bin${PATH:+:}$PATH
exec -a "$0" /nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/share/hplip/.hpssd.py-wrapped "${extraFlagsArray[@]}" "$@"

hpdio.py and probably other files are similarly munged. The net effect is that some of the hplip utilities don't work:

$ /etc/cups/path/bin/hp-info

HP Linux Imaging and Printing System (ver. 3.16.5)
Device Information Utility ver. 5.2

Copyright (c) 2001-15 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.


HP Linux Imaging and Printing System (ver. 3.16.5)
System Tray Status Service ver. 2.0

Copyright (c) 2001-15 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

Traceback (most recent call last):
Traceback (most recent call last):
  File "/nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/share/hplip/.systray.py-wrapped", line 139, in <module>
  File "/nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/share/hplip/.systray.py-wrapped", line 146, in <module>
    import hpssd
    import hpdio
  File "  File "/nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/share/hplip/hpdio.py/nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/share/hplip/hpssd.py", line ", line 22

        export PATH=/nix/store/d939y5gldj6fs3k366pni3f9l104nh8x-python-2.7.13/bin:/nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/bin:/nix/store/ml7b9bnzr8g1wj85f76szy95wh5ln3jx-expat-2.2.0-dev/bin:/nix/store/4isj683cw90w3dx3rfx9z4rqs462ga15-dbus-1.10.16-lib/bin:/nix/store/594h2zrinydqs6dl41pnfzsnak075pa8-dbus-1.10.16/bin:/nix/store/3b2dbbfaqvdvivmr9n8jjq43wqb05c9m-python2.7-Pillow-3.4.2/bin:/nix/store/v3w03f57ws8sqbh4nynf6v2l5r77ky6x-python2.7-setuptools-30.2.0/bin:/nix/store/77l777x243yqsfqlrgf4avj8hi3bjig8-python2.7-pygobject-2.28.6/bin:/nix/store/28xqb140djy6xnasyr3m7vskj2w50w5p-usbutils-008/bin:/nix/store/7af16bh6jyi0h90cldm0xj1qi2zywabs-python2.7-PyQt-x11-gpl-4.11.3/bin:/nix/store/mnc5am0bqldvs6nydvaindlpny1pb31g-python2.7-sip-4.18.1/bin${PATH:+:}$PATH
export PATH=/nix/store/d939y5gldj6fs3k366pni3f9l104nh8x-python-2.7.13/bin:/nix/store/iffniazmkqf32546bk65877rxgh3p9jh-python2.7-hplip-3.16.5/bin:/nix/store/ml7b9bnzr8g1wj85f76szy95wh5ln3jx-expat-2.2.0-dev/bin:/nix/store/4isj683cw90w3dx3rfx9z4rqs462ga15-dbus-1.10.16-lib/bin:/nix/store/594h2zrinydqs6dl41pnfzsnak075pa8-dbus-1.10.16/bin:/nix/store/3b2dbbfaqvdvivmr9n8jjq43wqb05c9m-python2.7-Pillow-3.4.2/bin:/nix/store/v3w03f57ws8sqbh4nynf6v2l5r77ky6x-python2.7-setuptools-30.2.0/bin:/nix/store/77l777x243yqsfqlrgf4avj8hi3bjig8-python2.7-pygobject-2.28.6/bin:/nix/store/28xqb140djy6xnasyr3m7vskj2w50w5p-usbutils-008/bin:/nix/store/7af16bh6jyi0h90cldm0xj1qi2zywabs-python2.7-PyQt-x11-gpl-4.11.3/bin:/nix/store/mnc5am0bqldvs6nydvaindlpny1pb31g-python2.7-sip-4.18.1/bin${PATH:+:}$PATH
                            ^
^
SyntaxErrorSyntaxError: : invalid syntaxinvalid syntax


HP Linux Imaging and Printing System (ver. 3.16.5)
HPLIP upgrade latest version ver. 1.0

Copyright (c) 2001-15 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

sh: lsb_release: command not found
warning:  distro is not found in AUTH_TYPES
warning: Unable to connect to dbus. Is hp-systray running?

Steps to reproduce

In configuration.nix on nixos-17.03:

{
  services.printing.enable = true;
  services.printing.drivers = [ pkgs.hplipWithPluign ];
}

Run /etc/cups/path/bin/hp-info.

Technical details

@FRidh
Copy link
Member

FRidh commented Mar 24, 2017

See also #21796 and #20892. cc @listx

@FRidh
Copy link
Member

FRidh commented Mar 24, 2017

wrapPythonPrograms wraps all executable files in $out.

@FRidh
Copy link
Member

FRidh commented Mar 24, 2017

Sometimes Python devs give modules a shebang and makes them executable. This way they can be executed, and still remain importable. When we add wrappers the files are no longer importable.

@FRidh
Copy link
Member

FRidh commented May 19, 2017

What we need to do to solve this is implement the proposal I wrote at https://gist.github.com/FRidh/c3e974e34eac738405af699786b462d5.

In short:

  1. all executable Python programs will be injected with a piece of code that checks an env variable for its name
  2. Programs in /bin are also wrapped, setting NIX_PYTHONPATH and NIX_SCRIPT_NAME. That way, the programs in /bin work fine. They can import modules located elsewhere. They can also run scripts situated outside of /bin because those are not wrapped anymore and because those inherit NIX_PYTHONPATH from their caller. See Python: use environment variable for script name #24525

@FRidh FRidh changed the title hplip: various commands broken by .py wrapping hplipWithPlugin: various commands broken by .py wrapping May 23, 2017
@FRidh
Copy link
Member

FRidh commented May 23, 2017

I was just looking at hplip again, and found that I could not reproduce this issue. Could you confirm whether the issue is still present?

@listx
Copy link
Member

listx commented Oct 20, 2017

FWIW, I cannot reproduce either.

In my case however, it turns out that my printer (LaserJet Pro MFP M125nw) requires a binary plug-in, which hp-setup automatically tries to download by invoking hp-plugin, and it is this downloading step that fails for me:

HP Linux Imaging and Printing System (ver. 3.16.5)
Plugin Download and Install Utility ver. 2.1

Copyright (c) 2001-15 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

Checking for network connection...                                                                                                                                                Downloading plug-in from: 
sh: lsb_release: command not found
warning:  distro is not found in AUTH_TYPES                                                                                                                                    error: GPG command not found

For now I am just using a VirtualBox image of Ubuntu to get around this, but maybe my data point can still help someone.

@benley
Copy link
Member Author

benley commented Oct 30, 2017

My general printing solution won't work for everybody, but I have been relying on Cloud Print for the past while. Chrome can send jobs there directly, and for other apps I "print" to a PDF, then open the pdf in chrome and hit print. I think there's a way to have CUPS send jobs straight to Cloud Print too, but I haven't taken the time to set that up yet.

@stale
Copy link

stale bot commented Jun 5, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 5, 2020
@attila-lendvai
Copy link
Contributor

guys, i'll close this issue. i cannot reproduce, and it's 3+ years old.

FTR, hplip doesn't work for me on 20.09 stable, but for other reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: printing 6.topic: python
Projects
None yet
Development

No branches or pull requests

4 participants