Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homogenize finding our components. #1336

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

matz-e
Copy link
Member

@matz-e matz-e commented Jul 10, 2024

We currently rely on two files being present in predefined directories:

  • nrnunits.lib
  • libpywrapper.so (or similar)

These are searched for in:

  • CMake's binary directory for NMODL
  • CMake's install directory for NMODL
  • The environment variable NMODLHOME

Leading to some acrobatics to always set NMODLHOME correctly. This PR attempts to also find the above files relative to the NMODL executable, in the hope that some use cases of NMODLHOME can be removed.

It will now also treat nrnunits.lib and libpywrapper.so the same, before only the former was looked for in multiple directories, while the latter relied on the environment variable.

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 41.66667% with 7 lines in your changes missing coverage. Please review.

Project coverage is 86.90%. Comparing base (b91c0ea) to head (62a5a49).

Files Patch % Lines
src/pybind/pyembed.cpp 0.00% 3 Missing ⚠️
src/config/config.h 50.00% 2 Missing ⚠️
src/parser/main_units.cpp 0.00% 1 Missing ⚠️
src/visitors/main.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1336      +/-   ##
==========================================
+ Coverage   86.82%   86.90%   +0.07%     
==========================================
  Files         179      179              
  Lines       13684    13667      -17     
==========================================
- Hits        11881    11877       -4     
+ Misses       1803     1790      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Jul 11, 2024
@bbpbuildbot

This comment has been minimized.

We currently rely on two files being present in pre-defined directories:

* nrnunits.lib
* libpywrapper.so (or similar)

These are searched for in:

* CMake's binary directory for NMODL
* CMake's install directory for NMODL
* The environment variable `NMODLHOME`

Leading to some acrobatics to always set NMODLHOME correctly.  This PR
attempts to also find the above files relative to the NMODL executable,
in the hope that some use cases of NMODLHOME can be removed.
@matz-e matz-e force-pushed the attempted-defenestration-of-nmodl-home branch from 6d9e59e to f4863e4 Compare July 11, 2024 11:55
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Jul 11, 2024
@matz-e matz-e marked this pull request as ready for review July 11, 2024 12:11
@matz-e matz-e requested review from pramodk and 1uc July 11, 2024 12:11
src/config/config.cpp.in Outdated Show resolved Hide resolved
Comment on lines 61 to 80
#elif defined(__APPLE__)
char buffer[PATH_MAX + 1];
uint32_t bufsize = PATH_MAX + 1;
if( _NSGetExecutablePath(buffer, &bufsize) != 0) {
return "";
}
auto executable = fs::path(buffer);
#else
auto executable = fs::read_symlink("/proc/self/exe");
#endif

auto executable_dir = fs::weakly_canonical(executable).parent_path();
if (executable_dir.filename() == "bin") {
return executable_dir.parent_path();
} else {
// On Windows, we may find ourselves in the top-level directory without a bin/
return executable_dir;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past, I didn't go via this route. But if you see that this is a relatively stable approach that peopl use and works on windows/Mac/Linux then I would say this is fine as well!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that way. All my searches more or less indicated that this is the way to go. Mac OS/Windows could use some more testing though. It at least goes through the CI so far.

@bbpbuildbot

This comment has been minimized.

Copy link
Contributor

@pramodk pramodk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matz-e : Our CI doesn't cover windows. If you have option and could check if this approach/function works on windows then it would be great!

@matz-e
Copy link
Member Author

matz-e commented Jul 12, 2024

@matz-e : Our CI doesn't cover windows. If you have option and could check if this approach/function works on windows then it would be great!

At least with MSVC, the majority of the code does not even compile...

@matz-e
Copy link
Member Author

matz-e commented Jul 12, 2024

@pramodk I generated a tiny reproducer on Win11/MSVC that does what it should and adjusted the code accordingly.

bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Jul 12, 2024
@pramodk
Copy link
Contributor

pramodk commented Jul 12, 2024

thanks for checking! 👍

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot
Copy link
Collaborator

Logfiles from GitLab pipeline #223225 (:white_check_mark:) have been uploaded here!

Status and direct links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants