Skip to content

Conversation

@epernod
Copy link
Contributor

@epernod epernod commented Jan 7, 2026

I need this method when I'm shipping SOFA dll which are used froma third party software.

Right now the main mechanism is to set SOFA_ROOT to explicitly define where is the build/install of SOFA with it's internal structure: bin/ data/ and even /etc/sofa/python.d/ which is used by PythonEnvironment to load site-packages
I can't rely on this mechanism as I can't ask all users to set a env variable (especially not IT users).

The current fallback solution if SOFA_ROOT is not set is to use the current executable path. This solution is not always relevant, for example, inside Unity3D, the path would be something like: C:/Program Files/Unity/Unity.exe which doesn't correspond to the current project path.

The method just allows to set a custom path. Then, if the path is set we don't call computeSofaPathPrefix() which is doing the normal mechanism:

const char* pathVar = getenv("SOFA_ROOT");
if (pathVar != nullptr && FileSystem::exists(pathVar))
{
    return FileSystem::convertBackSlashesToSlashes(pathVar);
}
else {
    const std::string exePath = Utils::getExecutablePath();
...

[with-all-tests]


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@epernod epernod added pr: status to review To notify reviewers to review this pull-request pr: new feature Implement a new feature labels Jan 7, 2026
@epernod epernod changed the title [Helper::Utils] Add method to be able to set manually SOFAPathPrefix to override getExecutablePath if SOFA_ROOT is not set [Helper::Utils] Add method to be able to manually set SOFAPathPrefix to override getExecutablePath if SOFA_ROOT is not set Jan 7, 2026
@epernod epernod added the pr: backport todo This PR will be backported into the release preceeding its milestone. label Jan 8, 2026
@hugtalbot hugtalbot added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: backport todo This PR will be backported into the release preceeding its milestone. pr: new feature Implement a new feature pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants