Closed SixK closed 8 months ago
What happens if you follow the documentation to build PyKCS11? https://github.com/LudovicRousseau/PyKCS11/blob/master/README.md#unix-build-howto
Got the same error if building with this commands in a virtual python env (following the unix-build-howto).
If compairing generated pykcs11_wrap.cpp from ubuntu 22.04 and 24.04, I see the following difference:
Ubuntu 22.04 --> src/pykcs11_wrap.cpp:#define SWIGTYPE_p_std__vectorT_unsigned_char_stdallocatorT_unsigned_char_t_t swig_types[29]
Ubuntu 24.04 --> src/pykcs11_wrap.cpp:#define SWIGTYPE_p_stdvectorT_unsigned_char_t swig_types[29]
That can explain that SWIGTYPE_p_std__vectorT_unsigned_char_std__allocatorT_unsigned_char_t_t definition is not found.
At this state, I can't figure out if this is a swig 4.2.0 (or swig 4.1.1) change or something else.
In swig #defines seem's to be generated here: https://github.com/swig/swig/blob/f762ab35b29b993e868ea4e0750bdb608e0084cd/Source/Swig/typesys.c#L2263
But this doesn't help much to understand
I replaced SWIGTYPE_p_std__vectorT_unsigned_char_stdallocatorT_unsigned_char_t_t by SWIGTYPE_p_stdvectorT_unsigned_char_t in pykcs11.i file. Build is now working without any error, but I didn't have tested the generated package. I have no idea if it's the right modification to do for Ubuntu 24.04 or Swig 4.2.0 Maybe it will be more obvious for you ?
We had a similar error using swig==4.2.0 (latest) and pykcs==1.5.12
Workaround: use swig==4.1.1.post1
pip install swig==4.1.1.post1
If I follow the sequence below on an official ubuntu 24.04 image, I can confirm that your work-around is working to build PyKCS11 for Ubuntu 24.04:
2 apt update
3 apt install python3 python3-pip
4 apt install git
6 apt install python3-venv
8 apt install build-essential
9 python3 -m venv temp
10 source temp/bin/activate
11 pip3 install -r dev-requirements.txt
12 git clone https://github.com/LudovicRousseau/PyKCS11
13 cd PyKCS11/
14 pip3 install -r dev-requirements.txt
16 pip3 install swig==4.1.1.post1
17 make
But If I simply want to install PyKCS11 to the system, I can't find a simple way : pip3 install swig==4.1.1.post1 --break-system-packages pip3 install PyKCS11 --break-system-packages
Collecting PyKCS11
Using cached PyKCS11-1.5.13.tar.gz (78 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: PyKCS11
Building wheel for PyKCS11 (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for PyKCS11 (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
running bdist_wheel
running build
running build_py
running build_ext
building 'PyKCS11._LowLevel' extension
swigging src/pykcs11.i to src/pykcs11_wrap.cpp
swig -python -c++ -o src/pykcs11_wrap.cpp src/pykcs11.i
Traceback (most recent call last):
File "/usr/local/bin/swig", line 5, in <module>
from swig import swig
ModuleNotFoundError: No module named 'swig'
error: command '/usr/local/bin/swig' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for PyKCS11
Failed to build PyKCS11
ERROR: Could not build wheels for PyKCS11, which is required to install pyproject.toml-based projects
It's weird that swig module is not found, in this case. If I install swig using apt, I will get v4.2.0 and will have the undefined variable error.
Thanks for the bug report. I will make a new release of PyKCS11 "soon".
New release available https://blog.apdu.fr/posts/2024/02/new-version-of-pykcs11-1514/
Thank's for new release,
according to wsfulton on swig project, the right way to solve the error would be to use descriptor:
$descriptor(std::vector
corresponding swig issue: https://github.com/swig/swig/issues/2793#issuecomment-1926509914
I tried with $descriptor(std::vector<unsigned char>)
but I then have regressions in my tests.
It may be a problem in my code.
I will have a look. Thanks for the info @SixK.
Fixed in https://github.com/LudovicRousseau/PyKCS11/commit/808199fb969bbb26f6e98a1829cc407f640c6e2c
The correct fix is to use $descriptor(vector<unsigned char> *)
PyKCS11 seem's to not install on Ubuntu 24.04 (Noble) anymore (seem's it was working about a week ago)
The problem can be reproduced using Ubuntu 24.04 docker image like this:
Note that v1.5.0 also finish with the same error: pip install PyKCS11==1.5.0 --break-system-packages --verbose But this command work: pip install PyKCS11==1.4.4 --break-system-packages --verbose
SWIG library version is 4.2.0 on Ubuntu 24.04. PyKCS11 installation work with Ubuntu 22.04 (Swig 4.0.2) and Debian Bookworm (Swig 4.1.0)
Problem seem's to be related to this variable: SWIGTYPE_p_std__vectorT_unsigned_char_std__allocatorT_unsigned_char_t_t
Corresponding error seem's to be in the following file near line 281: https://github.com/LudovicRousseau/PyKCS11/blob/master/src/pykcs11.i
Find below full log: