diff --git a/hyperon_das_atomdb_cpp/CMakeLists.txt b/hyperon_das_atomdb_cpp/CMakeLists.txt index 232e0acb..7db0736f 100644 --- a/hyperon_das_atomdb_cpp/CMakeLists.txt +++ b/hyperon_das_atomdb_cpp/CMakeLists.txt @@ -59,15 +59,8 @@ find_package(nanobind CONFIG REQUIRED) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src /usr/local/include) add_library(libmbedcrypto STATIC IMPORTED) -if(EXISTS "/usr/lib/x86_64-linux-gnu/libmbedcrypto.a") -# localion on Ubuntu 22.04 - installed package libmbedtls-dev -set_target_properties( - libmbedcrypto PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/libmbedcrypto.a) -else() -# localion on AlmaLinux 8 - compiled and installed from source set_target_properties( libmbedcrypto PROPERTIES IMPORTED_LOCATION /usr/local/lib64/libmbedcrypto.a) -endif() # Collect header and source files file(GLOB_RECURSE headers diff --git a/hyperon_das_atomdb_cpp/deps/mbedtls-3.6.2.tar.bz2 b/hyperon_das_atomdb_cpp/deps/mbedtls-3.6.2.tar.bz2 new file mode 100644 index 00000000..6e1a7cd1 Binary files /dev/null and b/hyperon_das_atomdb_cpp/deps/mbedtls-3.6.2.tar.bz2 differ diff --git a/hyperon_das_atomdb_cpp/requirements.txt b/hyperon_das_atomdb_cpp/deps/requirements.txt similarity index 100% rename from hyperon_das_atomdb_cpp/requirements.txt rename to hyperon_das_atomdb_cpp/deps/requirements.txt diff --git a/hyperon_das_atomdb_cpp/docker/Dockerfile.wheel b/hyperon_das_atomdb_cpp/docker/Dockerfile.wheel index 4d964034..e5f96cd0 100644 --- a/hyperon_das_atomdb_cpp/docker/Dockerfile.wheel +++ b/hyperon_das_atomdb_cpp/docker/Dockerfile.wheel @@ -1,26 +1,28 @@ # See https://github.com/pypa/manylinux for more information FROM quay.io/pypa/manylinux_2_28_x86_64 -# Install mbedtls-2.28 from source -# (there is no pre-built package available in the AlmaLinux repos) -WORKDIR /tmp -RUN git clone https://github.com/Mbed-TLS/mbedtls.git \ - && cd mbedtls \ - && git checkout mbedtls-2.28 \ +ENV MBEDTLS_VERSION=3.6.2 +ENV PYTHON_PATH=/opt/python/cp310-cp310 +ENV PYTHON_EXECUTABLE=${PYTHON_PATH}/bin/python3.10 + +COPY ./deps /tmp/deps + +# Install `mbedtls` from source +# (there was no pre-built package available in the AlmaLinux repos) +RUN cd /tmp \ + && tar jxf ./deps/mbedtls-${MBEDTLS_VERSION}.tar.bz2 \ + && cd mbedtls-${MBEDTLS_VERSION} \ && mkdir build \ && cd build \ - && export CFLAGS="$CFLAGS -fPIC" \ + && export CFLAGS="$CFLAGS -fPIC -Ofast" \ && cmake .. \ && make -j$(nproc) \ && make install \ - && rm -rf /tmp/mbedtls + && rm -rf /tmp/mbedtls-${MBEDTLS_VERSION} -COPY requirements.txt /tmp/requirements.txt - -ENV PYTHON_PATH=/opt/python/cp310-cp310 -ENV PYTHON_EXECUTABLE=${PYTHON_PATH}/bin/python3.10 +RUN ${PYTHON_EXECUTABLE} -m pip install -r /tmp/deps/requirements.txt -RUN ${PYTHON_EXECUTABLE} -m pip install -r /tmp/requirements.txt +RUN rm -rf /tmp/deps WORKDIR /hyperon_das_atomdb_cpp diff --git a/hyperon_das_atomdb_cpp/src/utils/expression_hasher.h b/hyperon_das_atomdb_cpp/src/utils/expression_hasher.h index f8ceed2f..e89a9e53 100644 --- a/hyperon_das_atomdb_cpp/src/utils/expression_hasher.h +++ b/hyperon_das_atomdb_cpp/src/utils/expression_hasher.h @@ -64,9 +64,9 @@ class ExpressionHasher { new mbedtls_md5_context(), &mbedtls_md5_free); mbedtls_md5_init(ctx.get()); uchar md5_buffer[MD5_BUFFER_SIZE]; - if (mbedtls_md5_starts_ret(ctx.get()) != 0 or - mbedtls_md5_update_ret(ctx.get(), (const uchar*) input.c_str(), input.length()) != 0 or - mbedtls_md5_finish_ret(ctx.get(), md5_buffer) != 0) { + if (mbedtls_md5_starts(ctx.get()) != 0 or + mbedtls_md5_update(ctx.get(), (const uchar*) input.c_str(), input.length()) != 0 or + mbedtls_md5_finish(ctx.get(), md5_buffer) != 0) { throw runtime_error("Failed to compute MD5 hash"); } char hash[2 * MD5_BUFFER_SIZE + 1];