Skip to content

Commit

Permalink
Merge pull request #236 from singnet/angelo/#235/creating-deps-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloprobst authored Oct 16, 2024
2 parents d350d2f + d0fd231 commit 5135885
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
7 changes: 0 additions & 7 deletions hyperon_das_atomdb_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added hyperon_das_atomdb_cpp/deps/mbedtls-3.6.2.tar.bz2
Binary file not shown.
File renamed without changes.
28 changes: 15 additions & 13 deletions hyperon_das_atomdb_cpp/docker/Dockerfile.wheel
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 3 additions & 3 deletions hyperon_das_atomdb_cpp/src/utils/expression_hasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 5135885

Please sign in to comment.