Closed Alan-Lynn closed 4 years ago
Hi Alan-Lynn,
You are not doing anything wrong. That reminds me that I should complete the documentation.
I distribute binary wheels for Linux only. I guess I could make some for MacOS as well. Anyway, you must first install libmbedtls
(the C library) before you can compile python-mbedtls
. If you use MacPorts, you can get libmbedtls
with port install mbedtls
. They distribute a fairly recent version so that is fine. Homebrew has it as well. If you do not use a package manager, libmbedtls
is easy to build from source, check it out and
# from mbedtls top-level directory
mkdir build
cd build
CFLAGS="-DMBEDTLS_ARIA_C=ON" \
SHARED="ON" \
make -C .. -j lib
sudo make -C .. -j install
or with CMake
# from mbedtls top-level directory
mkdir build
cd build
CFLAGS="-DMBEDTLS_ARIA_C=ON" \
cmake .. \
-DENABLE_TESTING=OFF \
-DUSE_SHARED_MBEDTLS_LIBRARY=ON \
-DUSE_STATIC_MBEDTLS_LIBRARY=OFF
make -j
sudo make -j install
should install mbedtls. Then you can pip install python-mbedtls
.
I develop on MacOS so I know that it works there as well.
This also happens on Leap 15.1 . The problem is the old version of libmbedtls 2.8.0.
....
[ 46s] building 'mbedtls._ringbuf' extension
[ 46s] creating build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14
[ 46s] creating build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7
[ 46s] creating build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7/pyrex
[ 46s] creating build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls
[ 46s] gcc -pthread -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -fPIC -I/usr/include/python2.7 -c build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c -o build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.o
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c: In function '__Pyx_PyInt_EqObjC':
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20232:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] Py_RETURN_TRUE;
[ 46s] ^~~~~~~~~~~~~~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20238:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
[ 46s] ^~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20238:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20248:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
[ 46s] ^~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20248:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20251:17: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] Py_RETURN_FALSE;
[ 46s] ^~~~~~~~~~~~~~~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20256:17: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] Py_RETURN_FALSE;
[ 46s] ^~~~~~~~~~~~~~~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20284:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
[ 46s] ^~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20284:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20290:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
[ 46s] ^~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:20290:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c: In function '__Pyx_PyBool_FromLong':
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:23866:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 46s] return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
[ 46s] ^~~~~~
[ 46s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.c:23866:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 50s] gcc -pthread -shared -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_ringbuf.o -L -L -L/usr/lib64 -lmbedcrypto -lmbedtls -lmbedx509 -lpython2.7 -o build-2.7.14/lib.linux-x86_64-2.7/mbedtls/_ringbuf.so
[ 50s] cythoning src/mbedtls/version.pyx to build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.c
[ 51s] building 'mbedtls.version' extension
[ 51s] gcc -pthread -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -fPIC -I/usr/include/python2.7 -c build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.c -o build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.o
[ 51s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.c: In function '__pyx_pf_7mbedtls_7version_has_feature':
[ 51s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.c:1948:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 51s] __Pyx_INCREF(Py_False);
[ 51s] ^~~~~~~~~~~~
[ 51s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.c: In function '__Pyx_PyBool_FromLong':
[ 51s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.c:4335:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 51s] return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
[ 51s] ^~~~~~
[ 51s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.c:4335:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 51s] gcc -pthread -shared -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/version.o -L -L -L/usr/lib64 -lmbedcrypto -lmbedtls -lmbedx509 -lpython2.7 -o build-2.7.14/lib.linux-x86_64-2.7/mbedtls/version.so
[ 51s] cythoning src/mbedtls/_random.pyx to build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_random.c
[ 52s] warning: src/mbedtls/_random.pyx:156:0: Overriding cdef method with def method.
[ 53s] building 'mbedtls._random' extension
[ 53s] gcc -pthread -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -fPIC -I/usr/include/python2.7 -c build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_random.c -o build-2.7.14/temp.linux-x86_64-2.7/build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_random.o
[ 53s] build-2.7.14/temp.linux-x86_64-2.7/pyrex/mbedtls/_random.c:600:10: fatal error: mbedtls/platform_util.h: No such file or directory
[ 53s] #include "mbedtls/platform_util.h"
[ 53s] ^~~~~~~~~~~~~~~~~~~~~~~~~
[ 53s] compilation terminated.
[ 53s] error: command 'gcc' failed with exit status 1
i.e. https://github.com/Synss/python-mbedtls/blob/master/src/mbedtls/_platform.pxd is where this is assumed to exist.
Ah! I did not think about that. Anyway, I am not sure that I want to support any old version of mbedtls. I would rather try to print a more helpful error message if the version of mbedtls is too old.
Hi Synss, Many thanks for so detailed explanation. And it solved the problem. I use home-brew. So I just "brew install mbedtls" first, and then "pip install python-mbedtls". Everything works fine. Thanks. :)
There now is a more helpful message on Linux and MacOS if mbedtls is either missing or too old to work. Thank you for your feedback.
I don't know if it only happened on my side. The system information is as below:
When installing the package with command "pip install python-mbedtls -i https://pypi.python.org/simple", I got the following error:
The full logs can be found in attached logs.txt Please have a look at it. Thanks.