diff --git a/.gitignore b/.gitignore index 16954878ecf6cb430e4dcd48920ceb7743d337cf..70998b3182f6eb1afa35993e7816b17fe7156fd6 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 1b5a43fc9f6012f0ae1cd4bf63e65b25eeb92e52..9593a41489a58952afe97496024927d6b1817c75 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 0000000000000000000000000000000000000000..7572e247dc5f5f7e798603b9c53157a8ec462968 --- /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 0000000000000000000000000000000000000000..4b876f63002972c1f8f1340b70cdecdace911012 --- /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 f2c248cdf6983caad4b546e780d649f488edc164..05b6f936f3ff4b1d2427a47f1221567ee7f03b4d 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 b16c2a98e62cd0d02b935d8a9cf30740342ee385..958593405a7b585d17178cf14f364a08b32de538 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 0000000000000000000000000000000000000000..c4ae60f9e09a5a1ac770e72f90b57417e4da32c8 --- /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 0000000000000000000000000000000000000000..aa0f227f6688468a5ab93384f7b1670086000035 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +# pbr file +[metadata] +version = file: version.txt