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

Fix PYTHONPATH for tests when using a venv #1208

Closed
wants to merge 1 commit into from

Conversation

JCGoran
Copy link
Contributor

@JCGoran JCGoran commented Mar 7, 2024

When building NMODL with the default flags, it’s possible to get errors like:

/test/unit/visitor/sympy_solver.cpp:2233: FAILED:
  REQUIRE_NOTHROW( result = run_sympy_solver_visitor( nmodl_text, false, false, AstNodeType::DERIVATIVE_BLOCK, true) )
due to unexpected exception with message:
  ModuleNotFoundError: No module named 'find_libpython'

At:
    /build/lib/nmodl/__init__.py(9): <module>
    <frozen importlib._bootstrap>(228): _call_with_frames_removed
    <frozen importlib._bootstrap_external>(850): exec_module
    <frozen importlib._bootstrap>(695): _load_unlocked
    <frozen importlib._bootstrap>(986): _find_and_load_unlocked
    <frozen importlib._bootstrap>(1007): _find_and_load
    <frozen importlib._bootstrap>(228): _call_with_frames_removed
    <frozen importlib._bootstrap>(972): _find_and_load_unlocked
    <frozen importlib._bootstrap>(1007): _find_and_load
    <string>(3): <module>

when running ctest, even though you may have installed all of the requirements via pip in your virtualenv beforehand (and pip show find_libpython finds it). The reason is this line here:

set(testvisitor_env "PYTHONPATH=${PROJECT_BINARY_DIR}/lib:$ENV{PYTHONPATH}")

This PR fixes this by using the workaround from this SO answer to prepend PYTHONPATH with the path to where packages are installed in the venv (should work outside of the venv as well).

Note that, as the answer mentions, the Python that comes with Debian is a bit wonky, and I'm not sure if this patch fixes it also on that platform (I tested it on a Debian Bullseye container, aka currently "oldstable", and it seems to work), but at least it shouldn't introduce any regressions.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.58%. Comparing base (347f786) to head (c9ba53e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1208   +/-   ##
=======================================
  Coverage   86.58%   86.58%           
=======================================
  Files         175      175           
  Lines       13006    13006           
=======================================
  Hits        11261    11261           
  Misses       1745     1745           

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

@bbpbuildbot
Copy link
Collaborator

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

Status and direct links:

@JCGoran JCGoran marked this pull request as ready for review March 8, 2024 10:42
@1uc
Copy link
Collaborator

1uc commented May 10, 2024

This has been confirmed to be a real bug, and not just a problem while testing/running CI.

@1uc 1uc closed this May 10, 2024
@1uc 1uc deleted the jelic/fix_test_pythonpath branch July 12, 2024 14:03
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.

None yet

4 participants