From 28b0135170c1bcfede2fc7a7223a4df84a68bde1 Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Wed, 11 Dec 2024 08:45:23 +0000 Subject: [PATCH] Update learning with https://gitlab.eclipse.org/eclipse/aidge/aidge_core/-/merge_requests/277 --- .gitignore | 3 +- CMakeLists.txt | 23 ++++++++++++ .../utils/sys_info/LearningVersionInfo.hpp | 37 +++++++++++++++++++ include/aidge/version.h.in | 11 ++++++ pyproject.toml | 18 +++++---- python_binding/pybind_learning.cpp | 3 +- .../sys_info/pybind_LearningVersionInfo.cpp | 12 ++++++ setup.cfg | 3 ++ 8 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 include/aidge/utils/sys_info/LearningVersionInfo.hpp create mode 100644 include/aidge/version.h.in create mode 100644 python_binding/utils/sys_info/pybind_LearningVersionInfo.cpp create mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index 1695487..70998b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # C++ Build build*/ install*/ - +include/aidge/learning_version.h # VSCode .vscode @@ -10,7 +10,6 @@ install*/ __pycache__ *.pyc *.egg-info -aidge_learning/_version.py wheelhouse/* # Mermaid diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b5a43f..9593a41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,21 @@ set(CXX_STANDARD 14) file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version) +# Parse version.txt to retrieve Major, Minor and Path +string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" _ MATCHES ${version}) +set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1}) +set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2}) +set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3}) + +# Retrieve latest git commit +execute_process( + COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + project(aidge_learning VERSION ${version} DESCRIPTION "Functions and alogrithms to train models in the AIDGE framework" @@ -10,6 +25,7 @@ project(aidge_learning message(STATUS "Project name: ${CMAKE_PROJECT_NAME}") message(STATUS "Project version: ${version}") +message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}") # Note : project name is {project} and python module name is also {project} set(module_name _${CMAKE_PROJECT_NAME}) # target name @@ -92,6 +108,13 @@ if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE) append_coverage_compiler_flags() endif() +message(STATUS "Creating ${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/learning_version.h") +# Generate version.h file from config file version.h.in +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/version.h.in" + "${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/learning_version.h" +) + ############################################## # Installation instructions include(GNUInstallDirs) diff --git a/include/aidge/utils/sys_info/LearningVersionInfo.hpp b/include/aidge/utils/sys_info/LearningVersionInfo.hpp new file mode 100644 index 0000000..7572e24 --- /dev/null +++ b/include/aidge/utils/sys_info/LearningVersionInfo.hpp @@ -0,0 +1,37 @@ +#ifndef AIDGE_UTILS_SYS_INFO_LEARNING_VERSION_INFO_H +#define AIDGE_UTILS_SYS_INFO_LEARNING_VERSION_INFO_H + +#include "aidge/utils/Log.hpp" +#include "aidge/learning_version.h" + +namespace Aidge { + +constexpr inline const char * getLearningProjectVersion(){ + return PROJECT_VERSION; +} + +constexpr inline const char * getLearningGitHash(){ + return PROJECT_GIT_HASH; +} + +void showLearningVersion() { + Log::info("Aidge Learning: {} ({}), {} {}", getLearningProjectVersion(), getLearningGitHash(), __DATE__, __TIME__); + // Compiler version + #if defined(__clang__) + /* Clang/LLVM. ---------------------------------------------- */ + Log::info("Clang/LLVM compiler version: {}.{}.{}\n", __clang_major__ , __clang_minor__, __clang_patchlevel__); + #elif defined(__ICC) || defined(__INTEL_COMPILER) + /* Intel ICC/ICPC. ------------------------------------------ */ + Log::info("Intel ICC/ICPC compiler version: {}\n", __INTEL_COMPILER); + #elif defined(__GNUC__) || defined(__GNUG__) + /* GNU GCC/G++. --------------------------------------------- */ + Log::info("GNU GCC/G++ compiler version: {}.{}.{}", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); + #elif defined(_MSC_VER) + /* Microsoft Visual Studio. --------------------------------- */ + Log::info("Microsoft Visual Studio compiler version: {}\n", _MSC_VER); + #else + Log::info("Unknown compiler\n"); + #endif +} +} // namespace Aidge +#endif // AIDGE_UTILS_SYS_INFO_LEARNING_VERSION_INFO_H diff --git a/include/aidge/version.h.in b/include/aidge/version.h.in new file mode 100644 index 0000000..4b876f6 --- /dev/null +++ b/include/aidge/version.h.in @@ -0,0 +1,11 @@ +#ifndef VERSION_H +#define VERSION_H + +namespace Aidge { +static constexpr const int PROJECT_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@; +static constexpr const int PROJECT_VERSION_MINOR = @PROJECT_VERSION_MINOR@; +static constexpr const int PROJECT_VERSION_PATCH = @PROJECT_VERSION_PATCH@; +static constexpr const char * PROJECT_VERSION = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"; +static constexpr const char * PROJECT_GIT_HASH = "@GIT_COMMIT_HASH@"; +} +#endif // VERSION_H diff --git a/pyproject.toml b/pyproject.toml index f2c248c..05b6f93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,18 +5,25 @@ dependencies = [] requires-python = ">= 3.7" readme = "README.md" license = { file = "LICENSE" } -classifiers = [ +classifiers = [ "Development Status :: 2 - Pre-Alpha", "Programming Language :: Python :: 3" ] -dynamic = ["version"] # defined in tool.setuptools_scm +dynamic = ["version"] # defined in pbr + +[project.urls] +Homepage = "https://www.deepgreen.ai/en/platform" +Documentation = "https://eclipse-aidge.readthedocs.io/en/latest/" +Repository = "https://gitlab.eclipse.org/eclipse/aidge/aidge_learning" +Issues = "https://gitlab.eclipse.org/eclipse/aidge/aidge_learning/-/issues/" +Changelog = "https://gitlab.eclipse.org/eclipse/aidge/aidge_learning/-/releases" [build-system] requires = [ "setuptools>=64", - "setuptools_scm[toml]==7.1.0", "cmake>=3.15.3.post1", - "toml" + "toml", + "pbr" ] build-backend = "setuptools.build_meta" @@ -28,9 +35,6 @@ where = ["."] # list of folders that contain the packages (["."] by default) include = ["aidge_learning*"] # package names should match these glob patterns (["*"] by default) exclude = ["aidge_learning.unit_tests*"] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) -# SETUPTOOLS_SCM -[tool.setuptools_scm] -write_to = "aidge_learning/_version.py" ##################################################### # CIBUILDWHEEL diff --git a/python_binding/pybind_learning.cpp b/python_binding/pybind_learning.cpp index b16c2a9..9585934 100644 --- a/python_binding/pybind_learning.cpp +++ b/python_binding/pybind_learning.cpp @@ -22,6 +22,7 @@ void init_SGD(py::module&); void init_Adam(py::module&); void init_LRScheduler(py::module&); void init_Accuracy(py::module&); +void init_LearningSysInfo(py::module&); void init_Aidge(py::module& m) { init_Loss(m); @@ -29,7 +30,7 @@ void init_Aidge(py::module& m) { init_SGD(m); init_Adam(m); init_Accuracy(m); - + init_LearningSysInfo(m); init_LRScheduler(m); } diff --git a/python_binding/utils/sys_info/pybind_LearningVersionInfo.cpp b/python_binding/utils/sys_info/pybind_LearningVersionInfo.cpp new file mode 100644 index 0000000..c4ae60f --- /dev/null +++ b/python_binding/utils/sys_info/pybind_LearningVersionInfo.cpp @@ -0,0 +1,12 @@ + +#include <pybind11/pybind11.h> +#include "aidge/utils/sys_info/LearningVersionInfo.hpp" + +namespace py = pybind11; +namespace Aidge { +void init_LearningSysInfo(py::module& m){ + m.def("show_version", &showLearningVersion); + m.def("get_project_version", &getLearningProjectVersion); + m.def("get_git_hash", &getLearningGitHash); +} +} diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..aa0f227 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +# pbr file +[metadata] +version = file: version.txt -- GitLab