Failed to upgrade pynitroky to 0.6.0

Hello.
I recently tryed to upgrade pynitrokey
via pipx upgrade pynitrokey.
The result was an error.

upgrading pynitrokey...
pipx >(run_subprocess:175): running /home/computer/.local/share/pipx/venvs/pynitrokey/bin/python -m pip --no-input install --upgrade pynitrokey
  error: subprocess-exited-with-error
  
  × Building wheel for pyscard (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Package libpcsclite was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libpcsclite.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libpcsclite', required by 'virtual:world', not found
      /tmp/pip-build-env-ccry3pjx/overlay/lib/python3.10/site-packages/setuptools

After I searched a bit via duckduckgo I tried to install the

lib64pcsclite-devel

Package and after this I get a different error.

pipx >(upgrade_package:457): Upgrading pynitrokey
upgrading pynitrokey...
pipx >(run_subprocess:175): running /home/computer/.local/share/pipx/venvs/pynitrokey/bin/python -m pip --no-input install --upgrade pynitrokey
  error: subprocess-exited-with-error
  
  × Building wheel for pyscard (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      /tmp/pip-build-env-zinhvwle/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_suite'
        warnings.warn(msg)
      running bdist_wheel
      running build
      running build_py
      running build_ext
      building 'smartcard.scard._scard' extension
      swigging smartcard/scard/scard.i to smartcard/scard/scard_wrap.c
      swig -python -outdir smartcard/scard -DPCSCLITE -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
      creating build/temp.linux-x86_64-cpython-310/smartcard/scard
      gcc -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DVER_PRODUCTVERSION=2,1,1,0000 -DVER_PRODUCTVERSION_STR=2.1.1 -DPCSCLITE=1 -Ismartcard/scard/ -I/home/computer/.local/share/pipx/venvs/pynitrokey/include -I/usr/include/python3.10 -c smartcard/scard/helpers.c -o build/temp.linux-x86_64-cpython-310/smartcard/scard/helpers.o -I/usr/include/PCSC -pthread
      smartcard/scard/helpers.c:31:10: schwerwiegender Fehler: Python.h: Datei oder Verzeichnis nicht gefunden
         31 | #include <Python.h>

:confused:
Frustrating. I just want to use my nk3 and get stuck in hours of searching the net and trying to find the answer.
Meanwhile I tried to install the latest version of
PCSCLite (2.3.3)
This failed to because of

meson setup builddir
The Meson build system
Version: 1.3.1
Source dir: /home/computer/J/Bin/Src/PCSCD/pcsc-lite-2.3.0
Build dir: /home/computer/J/Bin/Src/PCSCD/pcsc-lite-2.3.0/builddir
Build type: native build
Project name: pcsc-lite
Project version: 2.3.0
C compiler for the host machine: cc (gcc 12.3.0 "cc (Mageia 12.3.0-3.mga9) 12.3.0")
C linker for the host machine: cc ld.bfd 2.40
Host machine cpu family: x86_64
Host machine cpu: x86_64
Checking for function "getrandom" : YES 
Checking for function "secure_getenv" : YES 
Checking for function "getopt_long" : YES 
Program flex found: YES (/usr/bin/flex)
Run-time dependency threads found: YES
Found pkg-config: YES (/usr/bin/pkg-config) 1.8.0
Found CMake: /usr/bin/cmake (3.26.4)
Run-time dependency libudev found: NO (tried pkgconfig and cmake)

My system did knot know libudev. In the project overview it is stated that this is optional if I have libusb. Which I have installed.
Confusing

So what should I do?
I can also not install GitHub - LudovicRousseau/pyscard: pyscard smartcard library for python
via

pip install pyscard.

which is what I for now guess the problem.

I use Python 3.10. PCSCLite 1.9.9 and got no problems until 0.6.0.

Any Ideas?
much regards!

TL

why don’t you just use the pynitrokey binary from github than compiling it yourself ?

i remember i had faced issues while installing it through pipx myself , its not that user friendly method.
Also make sure you setup udev rules Installing nitropy With pipx - Nitrokey Documentation on linux

On linux just download the binary and give it executable permission and you should be good to go. It has worked form me without much problems.

Hi

You miss to mention which distribution (+version) you are using. Without this information it is hard to help you - actually pynitrokey 0.6.0 has massively reduced its dependencies thus in fact it should be easier to install than before. (also compiling pcsclite from scratch feels excessive)

Furthermore, if such an installation generates hours of work for you, you might maybe be better off using the nitrokey-app2, which comes through flathub as flatpak - which essentially boils down to a one-click installation.

An alternative for pynitrokey is using the linux binary as @kevin mentioned.

But also don’t miss to mention your distribution - this will give us the chance to solve this ground up and then update the docs accordingly.

Hello!
Thanks for your answers!

@kevin Thank you for the link. I want to rely on pip or pipx . Becuase they are the default package manager for python. When somewhing went wrong during a package update I don’t want to ignore this rather figure out why. Because then on my system something is maybe wrong or missing.

@daringer
Unfortunately the update broke the build of pynitrokey on my system.
My system is Mageia 9. RPM based distro. After the first failure screen I figured out that I have to install the lib64pcsclite-devel package. And the next error and contacting the maintainer of pcsclite he tell me that I need lib64python3-devel too. See this link.

Now I am able to install version 0.6.0 via pipx :slight_smile:

I have had installed The flatpak version of nitrokey-app. But I never used it ;).
The command line version offers much more options.
As you know. And I want to use all option and understand them.

So for me as a not so experienced linux user a good documentation is the best way to get used to this device which I like and may recommend this to other people If I think this is “easy to use” which is for now not really the case. Maybe this stems from the fact of the complexity of the device type. :wink:

Anyway. It would be nice if you add the hints for users who maybe face the same problems like me.

Thanks!

T.L.

Maybe you could check why pynitrokey cannot find this? Do you have libpcsclite installed (not -dev) and which version? Can it be detected with pkg-config or pkgconf? I think you have a problem with pkg-config in general, I think this should be troubleshoot first (talk to your distribution).

Hello @saper
Thanks for your answer.
I meanwhile was able to install the 0.6.0 version of pynitrokey.

How can I tell pip or pipx to look for such a file?

Before installing lib64pcsclite-devel I had only `pcscd.

pcscd --version
pcsc-lite version 1.9.9.
Copyright (C) 1999-2002 by David Corcoran <corcoran@musclecard.com>.
Copyright (C) 2001-2022 by Ludovic Rousseau <ludovic.rousseau@free.fr>.
Copyright (C) 2003-2004 by Damien Sauveron <sauveron@labri.fr>.
Report bugs to <pcsclite-muscle@lists.infradead.org>.
Enabled features: Linux x86_64-mageia-linux-gnu libsystemd serial usb libudev usbdropdir=/usr/lib64/pcsc/drivers ipcdir=/run/pcscd filter configdir=/etc/reader.conf.d
MAX_READERNAME: 128, PCSCLITE_MAX_READERS_CONTEXTS: 16

Can you please tell me why?

How to query this?
Regards

T.L.