Skip to content

Commit

Permalink
Merge branch 'master' into imp/205-custom-template-index-pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebrissow authored Dec 11, 2024
2 parents 280873d + c374929 commit 0f15605
Show file tree
Hide file tree
Showing 68 changed files with 668 additions and 285 deletions.
2 changes: 1 addition & 1 deletion .black.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tool.black]
line-length = 100
target-version = ['py38']
target-version = ['py310']
skip-string-normalization = true
4 changes: 2 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
publish-cpp:
needs: tag
environment: prod
environment: prod-cpp
runs-on: ubuntu-22.04
steps:
- name: Checkout code
Expand All @@ -65,7 +65,7 @@ jobs:
- name: Update version
working-directory: hyperon_das_atomdb_cpp
run: sed -i 's/version = ".*"/version = "${{ github.event.inputs.version }}"/' pyproject.toml
run: sed -i 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' pyproject.toml

- name: Build Wheels
working-directory: hyperon_das_atomdb_cpp
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
./lib/
lib64/
parts/
sdist/
Expand Down
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions cpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
format:
@find ./lib/include ./lib/src ./nanobind/include ./nanobind/src \
-iname "*.hpp" -o \
-iname "*.cpp" -o \
-iname "*.hh" -o \
-iname "*.cc" -o \
-iname "*.h" -o \
-iname "*.c" \
| xargs clang-format -verbose -style=file -i

packer-images:
@./scripts/build_glibc_packer_docker_image.sh
@./scripts/build_musl_packer_docker_image.sh

packs: packer-images
@./scripts/run_glibc_packer.sh
@./scripts/run_musl_packer.sh

install:
@./scripts/build_glibc_packer_docker_image.sh
@./scripts/run_glibc_packer.sh
@pip install ./nanobind/dist/hyperon_das_atomdb_cpp*manylinux*.whl --force-reinstall --no-cache-dir

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ wheel>=0.37.1
nanobind>=2.1.0
scikit-build-core>=0.10
auditwheel>=6.1.0

Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# See https://github.com/pypa/manylinux for more information
FROM quay.io/pypa/musllinux_1_2_x86_64

ENV MBEDTLS_VERSION=3.6.2
ENV PYTHON_PATH=/opt/python/cp310-cp310
ENV PYTHON_EXECUTABLE=${PYTHON_PATH}/bin/python3.10
ARG BASE_IMAGE="empty"
FROM ${BASE_IMAGE}

COPY ./deps /tmp/deps

ENV MBEDTLS_VERSION=3.6.2

# 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} \
Expand All @@ -20,10 +17,11 @@ RUN cd /tmp \
&& make install \
&& rm -rf /tmp/mbedtls-${MBEDTLS_VERSION}

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 rm -rf /tmp/deps

WORKDIR /hyperon_das_atomdb_cpp

CMD ["bash", "-x", "./scripts/_build_musl_wheel.sh"]
6 changes: 6 additions & 0 deletions cpp/docker/Dockerfile.glibc.packer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# See https://github.com/pypa/manylinux for more information
FROM quay.io/pypa/manylinux_2_28_x86_64

RUN dnf install -y rpm-build

CMD ["bash", "-x", "./scripts/_build_glibc_packs.sh"]
4 changes: 4 additions & 0 deletions cpp/docker/Dockerfile.musl.packer
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://github.com/pypa/manylinux for more information
FROM quay.io/pypa/musllinux_1_2_x86_64

CMD ["bash", "-x", "./scripts/_build_musl_packs.sh"]
3 changes: 3 additions & 0 deletions cpp/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
dist/

83 changes: 83 additions & 0 deletions cpp/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.15...3.30)

if(DEFINED CMAKE_PROJECT_VERSION AND NOT "${CMAKE_PROJECT_VERSION}" STREQUAL "")
set(LIB_VERSION ${CMAKE_PROJECT_VERSION})
else()
message(FATAL_ERROR "CMAKE_PROJECT_VERSION is not defined or is empty")
endif()

if(NOT DEFINED TARGET_TYPE OR "${TARGET_TYPE}" STREQUAL "")
message(FATAL_ERROR "TARGET_TYPE is not defined or is empty")
endif()

set(namespace "atomdb")
project(
"hyperon_das_atomdb_cpp"
VERSION ${LIB_VERSION}
DESCRIPTION "Atom Space DB for Hyperon DAS"
)

set(CPACK_PACKAGE_NAME "${PROJECT_NAME}-dev")

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Ofast")
set(CMAKE_VERBOSE_MAKEFILE ON)

add_library(${PROJECT_NAME} STATIC)

# Detect the installed mbedtls static library and import it into hyperon_das_atomdb_cpp
if(EXISTS /usr/local/lib/libmbedcrypto.a)
set(LIBMBCRYPTO_PATH /usr/local/lib/libmbedcrypto.a)
elseif(EXISTS /usr/local/lib64/libmbedcrypto.a)
set(LIBMBCRYPTO_PATH /usr/local/lib64/libmbedcrypto.a)
else()
message(FATAL_ERROR "libmbedcrypto.a not found in /usr/local/lib or /usr/local/lib64")
endif()

# This step is required to embed the `mbedtls` library into the `hyperon_das_atomdb_cpp` static
# library. This is done to avoid the need to install the `mbedtls` library on the target system.
# Teoretically, it would be possible to do the same with just `CMAKE_CXX_ARCHIVE_CREATE`, but it
# does not work as expected due to some limitations related to the number of files that can be
# passed as objects.
set(MBCRYPTO_SYMBOLS_PATH ${CMAKE_BINARY_DIR}/mbedcrypto_symbols)
make_directory(${MBCRYPTO_SYMBOLS_PATH})
execute_process(COMMAND ar x ${LIBMBCRYPTO_PATH} --output=${MBCRYPTO_SYMBOLS_PATH})
file(GLOB mbedcrypto_symbols ${MBCRYPTO_SYMBOLS_PATH}/*.o)
set(CREATE_STATIC_LIB_SCRIPT ${PROJECT_SOURCE_DIR}/scripts/_create_static_library.sh)
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
"${CREATE_STATIC_LIB_SCRIPT} <TARGET> <OBJECTS> ${MBCRYPTO_SYMBOLS_PATH}/*o")

file(GLOB_RECURSE sources
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE headers
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hh
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)

target_sources(${PROJECT_NAME} PRIVATE ${sources} ${headers})

target_include_directories(${PROJECT_NAME}
PRIVATE
# where the library itself will look for its internal headers
${CMAKE_CURRENT_SOURCE_DIR}/src
PUBLIC
# where top-level project will look for the library's public headers
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
# where external projects will look for the library's public headers
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

# without it public headers won't get installed
set(public_headers ${headers})

target_compile_options(${PROJECT_NAME} PRIVATE -Werror)

# where to find our CMake modules
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(Installing)
include(Packing)


5 changes: 5 additions & 0 deletions cpp/lib/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

check_required_components(@PROJECT_NAME@)
20 changes: 20 additions & 0 deletions cpp/lib/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2024 SingularityNET

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
File renamed without changes.
50 changes: 50 additions & 0 deletions cpp/lib/cmake/Installing.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# for CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_INCLUDEDIR and others
include(GNUInstallDirs)

# note that ${public_headers} should be in quotes
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${public_headers}")

set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")

# install the target and create export-set
install(
TARGETS ${PROJECT_NAME}
EXPORT "${PROJECT_NAME}-targets"
COMPONENT ${PROJECT_NAME} # must be here, not any line lower
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # include/hyperon_das_atomdb_cpp
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # include
)

set(CMAKE_INSTALL_DESTINATION "cmake/${PROJECT_NAME}")

# generate and install export file
install(
EXPORT "${PROJECT_NAME}-targets"
FILE "${PROJECT_NAME}-targets.cmake"
NAMESPACE ${namespace}::
DESTINATION ${CMAKE_INSTALL_DESTINATION}
COMPONENT ${PROJECT_NAME}
)

include(CMakePackageConfigHelpers)

# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPATIBILITY AnyNewerVersion
)
# create config file
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DESTINATION}
)
# install config files
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_DESTINATION}
COMPONENT ${PROJECT_NAME}
)

43 changes: 43 additions & 0 deletions cpp/lib/cmake/Packing.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
set(CPACK_PACKAGE_NAME ${PROJECT_NAME} CACHE STRING "hyperon_das_atomdb_cpp")
set(
CPACK_PACKAGE_DESCRIPTION_SUMMARY "Atom Space DB for Hyperon DAS"
CACHE STRING "Atom Space DB for Hyperon DAS is a C++ library for managing Atom databases."
)
set(CPACK_PACKAGE_VENDOR "SingularityNET")

set(CPACK_VERBATIM_VARIABLES YES)

set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/dist")
set(CPACK_STRIP_FILES YES)

set(
CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)

set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")

set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})

set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Andre Senna <${CPACK_PACKAGE_CONTACT}>")

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

set(CPACK_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE})
set(CPACK_PACKAGE_VERSION
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_ARCHITECTURE}-${TARGET_TYPE}")
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
set(CPACK_DEB_COMPONENT_INSTALL YES)

include(CPack)

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "expression_hasher.h"
#include "type_aliases.h"
#include "utils/expression_hasher.h"

using namespace std;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include "constants.h"
#include "document_types.h"
#include "exceptions.h"
#include "expression_hasher.h"
#include "type_aliases.h"
#include "utils/expression_hasher.h"

using namespace std;

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0f15605

Please sign in to comment.