Open vsbogd opened 1 year ago
This comment is to explain the use-cases of the build system we are supporting, explain which difficulties exist and discuss what can be done to make a project setup more easier.
libcheck pybind11 + option-lite
v v
metta-lib (./lib) --> metta-c (./c) -> metta-py (./python including hyperonpy.cpp)
\-> metta-repl (./repl)
Developer clones repository and changes the code. Need a single command to build or test the whole chain of native projects after changing any of them. Changes in Python files should be applied without rebuild.
Each component is released and published independently, next component is released using release version of previous one. Release version is received from artifacts storage. Cargo workspace publishing should do it automatically. metta-py
component is released building metta-c
version from crates.io
.
User gets a copy of repo to use the latest version of binaries but without needness to modify the source code frequently. In such case the common way is to build binaries from source, install them into system using make install
or similar and use them.
Rust components can be build easily using Cargo but there is no Cargo command to install metta-c
into a LFS to allow metta-py
finding it. metta-py
should have separate project to compile hyperonpy.cpp
into a binary Python module.
Each component can be built separately:
metta-lib
and metta-repl
) has Cargo project file.metta-c
) has both Cargo and CMake project files. CMake project file is used to implement make install
which is absent in Cargo for libraries and export dependency to the other CMake projects.metta-py
) has CMake setup to build a native part (hyperonpy.cpp
) and Python project setup (setup.py
+ pyproject.toml
). setup.py
implements two cases:
hyperonpy
library from ./python
directory if it is present. Now I am not sure in which case it is triggered. In dev mode built library is already present in ./python
directory. In other modes it should be built.hyperonpy
library from source distribution. It is expected that user already installed hyperonc
library properly thus CMake can find it by using standard paths. This approach is used to release binaries or install Python component separately. When Python library is released inside cibuildwheel
docker then install-hyperonc.sh
script is used to install hyperonc
from sources.CMake is used to orchestrate the build in a dev mode: it builds metta-c
and metta-py
and ensures projects see each other.
Rust projects can be built by one command which is handy for pure Rust devs who wants to play with code. Central CMake script allows building and testing the C and Python related part by a single command. Python module can be installed in editable mode and all changes in Python files are automatically applied. Changes in Rust part are applied after rebuild. All native dependencies are automatically downloaded.
metta-c
library has two different build scripts: Cargo to build Rust related code, CMake to run C unit tests, install C libraries. make install
usually requires root privileges but Rust cannot build the project under the root user (even building a project using make
and then use make install
doesn't work). Thus one should use install path which doesn't require root privileges. On the other hand Python project cannot be configured to use custom root prefix, thus use-case 3 is not implemented.metta-py
CMake script directly hijacking its behaviour via variables. Second step is needed to install Python project in a dev mode. One cannot use just pip install -e ./python
either.1.xx
we use to get dependencies is not longer developed, there is some gap between new compilers released and they are supported by Conan (see https://github.com/trueagi-io/hyperon-experimental/issues/421).
At the moment the project has two CMake projects inside:
hyperonc
which builds C API libraryhyperonpy
which builds Python API library using C API onehyperonpy
depends onhyperonc
and they can be built one by one. Ashyperonpy
linkshyperonc
statically the developer need to rebuild bothhyperonc
andhyperonpy
when C API is changed. To simplify development a root CMake projects is added.hyperonc
andhyperonpy
are included into the root project as external projects in order to allow them be built by a single cmake/make command.It turns out this configuration doesn't work properly. In particular it doesn't propagate the
CMAKE_BUILD_TYPE
from root project tohyperonc
andhyperonpy
subprojects (see https://github.com/trueagi-io/hyperon-experimental/pull/377 which is quickfix). It also doesn't allow usingmake test
target on the root project to test subprojects (this is workarounded by introducing custommake check
target).This issue is to work on proper project configuration. There are number of things to try:
FetchContent
instead ofExternalProjects
hyperonc
project intohyperonpy
project and remove root project