Maria
Maria

Reputation: 186

Building wheel for pyscard (setup.py): finished with status 'error'

I have pyscard within requirements.txt. Therefore the build on readthedocs is failing:

Running setup.py install for pyscard: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Running setup.py install for pyscard did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      running install
      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
      creating build/temp.linux-x86_64-3.7
      creating build/temp.linux-x86_64-3.7/smartcard
      creating build/temp.linux-x86_64-3.7/smartcard/scard
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DVER_PRODUCTVERSION=2,0,2,0000 -DVER_PRODUCTVERSION_STR=2.0.2 -DPCSCLITE=1 -Ismartcard/scard/ -I/usr/include/PCSC -I/usr/local/include/PCSC -I/home/docs/.pyenv/versions/3.7.9/include/python3.7m -c smartcard/scard/helpers.c -o build/temp.linux-x86_64-3.7/smartcard/scard/helpers.o
      smartcard/scard/helpers.c:28:10: fatal error: winscard.h: No such file or directory
       #include <winscard.h>
                ^~~~~~~~~~~~
      compilation terminated.
      error: command 'gcc' failed with exit status 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyscard

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

I have tried to skip pyscard in docs/conf.py:

autodoc_mock_imports = ['pyscard']

and in setup.py:

if os.getenv('READTHEDOCS'):
        requirements = [x for x in requirements if "pyscard" not in x]

but I still get the same error. Have you encountered something similar? If so, how have you solved the problem?

Upvotes: 3

Views: 3690

Answers (3)

timusp
timusp

Reputation: 46

This header file is provided by pcsc-lite. Install libpcsclite-dev (or similar) package.

https://github.com/LudovicRousseau/pyscard/issues/78

Edit: please follow Manuel Kaufmann's answer for detailed solution

Upvotes: 2

Maria
Maria

Reputation: 186

I added into .readthedocs.yml:

build:
  apt_packages:
    - swig
    - pcscd
    - libpcsclite-dev

Upvotes: 0

Manuel Kaufmann
Manuel Kaufmann

Reputation: 480

If pyscard is not required to build your documentation, you should remove it from your documentation requirements.txt. This is the most common case.

You may need to split your current requirements.txt:

  • requirements.txt with all the dependencies
  • docs/requirements.txt with only the dependencies to build the documentation (without pyscard)

Then, in your readthedocs.yaml file (see https://docs.readthedocs.io/en/stable/config-file/v2.html), you can use:

python:
  install:
    - requirements: docs/requirements.txt

On the other hand, if pyscard is required to build your documentation, you can take a look at the FAQ from the documentation https://docs.readthedocs.io/en/stable/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules

Upvotes: 1

Related Questions