Skip to content

Resolve relative paths of import_module_from_file against the testbench directory - #9

Open
ru551n wants to merge 1 commit into
VUnit:mainfrom
ru551n:import-module-path
Open

ru551n wants to merge 1 commit into
VUnit:mainfrom
ru551n:import-module-path

Conversation

@ru551n

@ru551n ru551n commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

import_module_from_file now resolves a relative path against the testbench directory (tb_path) through the same p_file_path helper as exec_file, instead of passing it to Python relative to the simulator's working directory. Absolute paths, the session parameter and import_run_script are unchanged. A relative path needs test_runner_setup to have run.

Fixes #7

  • python_pkg.vhd.in: forward-declares p_file_path in the package body and uses it in import_module_from_file; python_pkg.vhd regenerated.
  • docs/user_guide.rst: documents the path base and the runner-setup requirement.
  • release_notes/0.2.0.md: flags the change for callers relying on working-directory-relative imports.

Testing

New tests in tb_python_pkg_bridge: a relative import from a procedure without runner_cfg (also checks that the simulator cwd differs from the testbench directory), and an absolute import. The relative test failed before the fix with FileNotFoundError on <cwd>/models/filters.py.

  • tests/run.py: 108/108 on NVC and on GHDL
  • examples/embedded_python/run.py --without-attributes .optional_deps --without-attributes .expected_failure: 17/17 on NVC and on GHDL
  • pytest tests/test_python_bridge.py: 85 passed

🤖 Generated with Claude Code

…ch directory

Like exec_file, a relative path is now taken from tb_path rather than from
the working directory of the simulator, so verification components can
import their models without runner_cfg. Fixes VUnit#7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Make import_module_from_file resolve relative paths consistently with exec_file

1 participant