- Package:
- python3-virtualsmartcard
- Source:
- vsmartcard
- Submitter:
- Robin Krahl
- Date:
- 2023-02-16 13:12:03 UTC
- Severity:
- important
Dear Maintainer,
after installing the python3-virtualsmartcard package, I cannot import
it with python3:
$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtualsmartcard
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'virtualsmartcard'
As far as I see, this is because the package is installed into
/usr/lib/python3/site-packages instead of <..>/dist-packages:
$ apt-file show python3-virtualsmartcard | grep __init__.py
python3-virtualsmartcard: /usr/lib/python3/site-packages/virtualsmartcard/virtualsmartcard/__init__.py
python3-virtualsmartcard: /usr/lib/python3/site-packages/virtualsmartcard/virtualsmartcard/cards/__init__.py
$ python3 -m site
sys.path = [
'/home/robin',
'/usr/lib/python39.zip',
'/usr/lib/python3.9',
'/usr/lib/python3.9/lib-dynload',
'/usr/local/lib/python3.9/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/robin/.local' (exists)
USER_SITE: '/home/robin/.local/lib/python3.9/site-packages' (doesn't exist)
ENABLE_USER_SITE: True
If I manually put that folder in the Python path, for example by linking
/usr/lib/python3/site-packages/virtualsmartcard/virtualsmartcard to
~/.local/lib/python3.9/site-package/virtualsmartcard, I can at least
import the virtualsmartcard module. But there seem to be missing
dependencies:
>>> import virtualsmartcard.VirtualSmartcard
Traceback (most recent call last):
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/CryptoUtils.py", line 29, in <module>
from Crypto.Cipher import DES3, DES, AES, ARC4 # @UnusedImport
ModuleNotFoundError: No module named 'Crypto'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/VirtualSmartcard.py", line 31, in <module>
from virtualsmartcard.CardGenerator import CardGenerator
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/CardGenerator.py", line 34, in <module>
from virtualsmartcard.SmartcardSAM import SAM
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/SmartcardSAM.py", line 24, in <module>
import virtualsmartcard.CryptoUtils as vsCrypto
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/CryptoUtils.py", line 35, in <module>
import sha as SHA1
ModuleNotFoundError: No module named 'sha'
Hi, It seems very logical to me that it cannot import virtualsmartcard if it's in site-packages and not dist-packages. I'll have a look at the debian rules to patch it and upload it here, or if Philippe allows me, package it and have it uploaded by my mentor nicoo. Best regards,
Hi Guinness, It is indeed an error in the rules file. If you already have the patch ready, your can upload a NMU release if you wish. If not, I can handle it during the current week. Keep me informed of what you prefer :-) Best regards,
Hi, is there any chance to get a fixed package released sometime soon? The following change fixed this for me in a local rebuild of the package, but there might be a better way to handle it: diff --git a/debian/python3-virtualsmartcard.install b/debian/python3-virtualsmartcard.install index 47ee4d3..ded283b 100644 --- a/debian/python3-virtualsmartcard.install +++ b/debian/python3-virtualsmartcard.install @@ -1 +1 @@ -usr/lib/python3.*/site-packages/virtualsmartcard /usr/lib/python3/site-packages/virtualsmartcard +usr/lib/python3.*/site-packages/virtualsmartcard usr/lib/python3/dist-packages/ Side note: With this in place, I still ran into another problem, described in upstream issue https://github.com/frankmorgner/vsmartcard/issues/218 ("ModuleNotFoundError: No module named 'sha'"). With a logical backport of the suggested upstream PR https://github.com/frankmorgner/vsmartcard/pull/228 , running `vicc` then works without errors for me. Backport in the patch-queue branch of my local package looks like this: diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py index 56e0ed4..552cff1 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py @@ -27,12 +27,11 @@ from virtualsmartcard.utils import inttostring try: # Use PyCrypto (if available) from Crypto.Cipher import DES3, DES, AES, ARC4 # @UnusedImport - from Crypto.Hash import HMAC, SHA as SHA1 + from Crypto.Hash import HMAC except ImportError: # PyCrypto not available. Use the Python standard library. import hmac as HMAC - import sha as SHA1 CYBERFLEX_IV = b'\x00' * 8 Best regards, Michael
FWIW, that upstream pull request has been merged now.
I'm forwarding the debdiff I submitted to https://launchpad.net/bugs/2007568 in hope that it will be useful.