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

During pipx upgrade on Debian: fatal error: winscard.h: No such file or directory #579

Closed
farblos opened this issue Oct 24, 2024 · 4 comments · Fixed by #580
Closed

During pipx upgrade on Debian: fatal error: winscard.h: No such file or directory #579

farblos opened this issue Oct 24, 2024 · 4 comments · Fixed by #580

Comments

@farblos
Copy link

farblos commented Oct 24, 2024

I get the following error from pynitrokey during pipx upgrade-all

[~]$ pipx upgrade-all
  error: subprocess-exited-with-error
  
  × Building wheel for pyscard (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      building 'smartcard.scard._scard' extension
      swigging src/smartcard/scard/scard.i to src/smartcard/scard/scard_wrap.c
      swig -python -outdir src/smartcard/scard -DPCSCLITE -o src/smartcard/scard/scard_wrap.c src/smartcard/scard/scard.i
      creating build/temp.linux-x86_64-cpython-312/src/smartcard/scard
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -DVER_PRODUCTVERSION=2,2,0,0000 -DVER_PRODUCTVERSION_STR=2.2.0 -DPCSCLITE=1 -Isrc/smartcard/scard/ -I/usr/include/PCSC -I/usr/local/include/PCSC -I/home/farblos/.local/share/pipx/venvs/pynitrokey/include -I/usr/include/python3.12 -c src/smartcard/scard/helpers.c -o build/temp.linux-x86_64-cpython-312/src/smartcard/scard/helpers.o
      src/smartcard/scard/helpers.c:28:10: fatal error: winscard.h: No such file or directory
         28 | #include <winscard.h>
            |          ^~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyscard
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pyscard)
'/home/farblos/.local/share/pipx/venvs/pynitrokey/bin/python -m pip
--no-input install --upgrade pynitrokey -q' failed
No packages upgraded after running 'pipx upgrade-all' 😴
The following package(s) failed to upgrade: pynitrokey

Version information:

[~]$ uname -a
Linux host01 6.11.2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.11.2-1 (2024-10-05) x86_64 GNU/Linux

[~]$ python3 --version
Python 3.12.6

[~]$ cat /etc/debian_version 
trixie/sid

[~]$ pipx list
venvs are in /home/farblos/.local/share/pipx/venvs
apps are exposed on your $PATH at /home/farblos/.local/bin
manual pages are exposed at /home/farblos/.local/share/man
   package pynitrokey 0.4.50, installed using Python 3.12.4
    - nitropy

There does not seem to be a canonical candidate package providing winscard.h on Debian, plus I'm more or less Python-agnostic, so any help appreciated.

@robin-nitrokey
Copy link
Member

Installing libpcsclite-dev should fix this issue on Debian. But it’s not nice that you need to install additional libraries to get pynitrokey to install properly. Maybe we can put the piv command that depends on pyscard behind an optional extra to make installation easier for those users that are not interested in PIV.

@farblos
Copy link
Author

farblos commented Oct 25, 2024

@robin-nitrokey, thanks for your quick reply and action on this. Installing libpcsclite-dev indeeds works around the above error, but then the compile fails on Python.h, so your fix will be most appreciated.

For reference and searching, here the error message related to Python.h (and no, I'd rather not install more header files - will wait for your fix :-):

[~]$ pipx upgrade-all
  error: subprocess-exited-with-error
  
  × Building wheel for pyscard (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      building 'smartcard.scard._scard' extension
      swigging src/smartcard/scard/scard.i to src/smartcard/scard/scard_wrap.c
      swig -python -outdir src/smartcard/scard -DPCSCLITE -o src/smartcard/scard/scard_wrap.c src/smartcard/scard/scard.i
      creating build/temp.linux-x86_64-cpython-312/src/smartcard/scard
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -DVER_PRODUCTVERSION=2,2,0,0000 -DVER_PRODUCTVERSION_STR=2.2.0 -DPCSCLITE=1 -Isrc/smartcard/scard/ -I/usr/include/PCSC -I/usr/local/include/PCSC -I/home/farblos/.local/share/pipx/venvs/pynitrokey/include -I/usr/include/python3.12 -c src/smartcard/scard/helpers.c -o build/temp.linux-x86_64-cpython-312/src/smartcard/scard/helpers.o
      src/smartcard/scard/helpers.c:31:10: fatal error: Python.h: No such file or directory
         31 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyscard
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pyscard)
'/home/farblos/.local/share/pipx/venvs/pynitrokey/bin/python -m pip
--no-input install --upgrade pynitrokey -q' failed
No packages upgraded after running 'pipx upgrade-all' 😴
The following package(s) failed to upgrade: pynitrokey

@robin-nitrokey
Copy link
Member

For reference, python3-dev should be the relevant package. Overall, on Debian-based systems, the packages libpcsclite-dev, python3-dev, gcc and swig should be sufficient.

@bocekm
Copy link

bocekm commented Oct 30, 2024

I faced the same issue on Fedora 41 and fixed it by running $ sudo dnf install pcsc-lite-devel python3-devel.
Related: LudovicRousseau/pyscard#218.

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

Successfully merging a pull request may close this issue.

3 participants