Skip to content

[Helper::Utils] Add method to be able to manually set SOFAPathPrefix to override getExecutablePath if SOFA_ROOT is not set#5851

Merged
fredroy merged 2 commits intosofa-framework:masterfrom
epernod:inf_2026_01-addSofaPrefixPath
Jan 15, 2026
Merged

[Helper::Utils] Add method to be able to manually set SOFAPathPrefix to override getExecutablePath if SOFA_ROOT is not set#5851
fredroy merged 2 commits intosofa-framework:masterfrom
epernod:inf_2026_01-addSofaPrefixPath

Conversation

@epernod
Copy link
Copy Markdown
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
@fredroy fredroy force-pushed the inf_2026_01-addSofaPrefixPath branch from 68b4d16 to 722b7ee Compare January 13, 2026 23:41
@fredroy fredroy force-pushed the inf_2026_01-addSofaPrefixPath branch from b0e9465 to b12cc46 Compare January 15, 2026 23:52
@fredroy fredroy merged commit ea2d1c6 into sofa-framework:master Jan 15, 2026
9 of 13 checks passed
bakpaul pushed a commit that referenced this pull request Jan 16, 2026
…to override getExecutablePath if SOFA_ROOT is not set (#5851)

* [Helper::Utils] Add method to be able to set SOFAPathPrefix to overidde getExecutablePath if SOFA_ROOT is not set

* [Helper] Update FileRepository to display path using logging system
@bakpaul bakpaul added pr: backport done This PR has been backported into the release before its milestone. and removed pr: backport todo This PR will be backported into the release preceeding its milestone. labels Jan 20, 2026
@hugtalbot hugtalbot added this to the v25.12 milestone Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: backport done This PR has been backported into the release before 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.

4 participants