Tom Short wrote here:
The code from 479cec8 seems like a kludgy solution. I’m not sure what’s the best approach. Maybe it points to the need for better Base tooling.
How about including an
examples/Project.toml with those dependencies? The user would have to activate that to run the code.
i hope that @StefanKarpinski could also have a look and give his opinion.
Let me add some more explanations: Currently, there are about 20 examples in ModiaMath and there will be much more, especially in Modia and in Modia3D, at some point in the future (say hundreds or thousands of such examples). All these examples are also executed from the test directory. So we have:
examples # 100 ... 1000 independent examples (not handled by package manager)
src # source code handled by package manager
test # tests + calling all the examples (partially handled by package manager)
With the current package manager, via [extras] and [test] test runs can be handled, if the test is started in a special environment (]activate ModiaMath; test). However, if the user would like to run single examples from the examples directory or single tests from the test directory directly from his/her standard environment, then this might not work and the user has to add packages to his standard environment that are used in the examples directory (but the examples directory was potentially tested with another version).
My current solution in ModiaMath (as proposed above) is nice in the sense, that it always works and the user does not have to think about (just start the single example or single test in any environment in which ModiaMath is present, and it will work; this also includes ContinuousIntegration environments).
I agree that this solution looks not nice from a conceptual point of view and it would be better to have some nicer solution in this respect.
It is not clear how to add project.toml/manifest.toml files to the examples or test directory. In particular if single examples and single tests would like to be executed, then potentially for every single example or test separte project.toml/manifest.toml files are needed. If one has 100 files, it would be hard to manage and/or maintain this. In particular, all the examples and tests would be typically developed with the same base packages, so to define in every example that version xxx from package yyy is used would be a nightmare.