LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
377 stars 108 forks source link

pip install pyscard does not work #132

Closed githubkusi closed 2 years ago

githubkusi commented 2 years ago

It would be great to have a wheel for pyscard.

(venv) $ pip install pyscard
Collecting pyscard
  Using cached pyscard-2.0.3.tar.gz (150 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for pyscard, since package 'wheel' is not installed.
...

Installing wheel, then I get

(venv) $  pip install pyscard
Collecting pyscard
  Using cached pyscard-2.0.3.tar.gz (150 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyscard
  Building wheel for pyscard (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [13 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
      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
      unable to execute 'swig': No such file or directory
      error: command 'swig' failed with exit status 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
  Running setup.py clean for pyscard
Failed to build pyscard

Installing swig with pipx install git+https://github.com/nightlark/swig-pypi.git and re-running

(venv) $ pip install pyscard
Collecting pyscard
  Using cached pyscard-2.0.3.tar.gz (150 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyscard
  Building wheel for pyscard (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [18 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
      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
      Traceback (most recent call last):
        File "/home/kusi/.local/bin/swig", line 5, in <module>
          from swig import swig
        File "/home/kusi/.local/pipx/venvs/swig/lib64/python3.8/site-packages/swig/__init__.py", line 6, in <module>
          from ._version import get_versions
      ImportError: cannot import name 'get_versions' from 'swig._version' (/home/kusi/.local/pipx/venvs/swig/lib64/python3.8/site-packages/swig/_version.py)
      error: command 'swig' failed with exit status 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
  Running setup.py clean for pyscard

Is there a way to install everything in a venv or by means of pipx? System: Opensuse Tumbleweed, Python 3.8

LudovicRousseau commented 2 years ago

It looks like the last error comes from swig-pypi.

have you tried to install the OpenSUSE swig package instead? https://software.opensuse.org/package/swig

You may also have to install the OpenSUSE package libpcsclite-dev https://software.opensuse.org/package/libpcsclite-dev to solve the problem:

      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
githubkusi commented 2 years ago

yes, installing the opensuse swig package brings me indeed further. libpcsclite-dev is also needed for winscard.h. I intend to prepare a multi-platform (mac & linux) package where it would be very helpful to have a wheel such that it can be completely installed in a venv rather than touching the system. Would you consider a wheel for pyscard?

LudovicRousseau commented 2 years ago

I use swig to create the connection between Python and C. A Python wheel package then have a part of native code compiled. This binary depends on the Python version and also the CPU architecture.

I already provide wheels for Windows. Because installing the dependencies on Windows is "complex". See https://pypi.org/project/pyscard/#files

I am no sure it is possible to create a multi-platform wheel for pyscard. But please do try it by yourself. Feel free to send me patches.

githubkusi commented 2 years ago

This one could be of help: https://github.com/pypa/cibuildwheel, with an example for appveyor what you are using

LudovicRousseau commented 2 years ago

Please provide a patch. I do not plan to work on multi-Python and multi-OS wheel myself.

This is now a different subject. I close this issue as it is resolved.