Search code examples
python-3.xread-the-docs

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?


Solution

  • I added into .readthedocs.yml:

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