Skip to content

Make import_module_from_file resolve relative paths consistently with exec_file #7

Closed

Description

@ru551n

Currently, exec_file resolves relative paths against the testbench directory using the shared VUnit runner state, while import_module_from_file passes its path directly to Python, resolving relative paths against the simulator’s working directory.

This makes importing Python models from verification components unnecessarily awkward: the component must receive an absolute path or obtain the testbench path explicitly.

Please make both APIs use the same path resolution:

  • Resolve relative paths against the top-level testbench directory.
  • Preserve absolute paths unchanged.
  • Allow calls from verification components and VHDL package procedures without passing tb_path or runner_cfg locally.

For example, after test_runner_setup, a component should be able to write:

import_module_from_file("models/filter.py", "filter_model");
result := call_integer("filter_model.compute", arg(21));

This should load models/filter.py relative to the top-level testbench directory.

The existing p_file_path helper used by exec_file could be shared with import_module_from_file.

Acceptance criteria:

  • Relative imports work from a child component after runner setup, even when the simulator’s working directory differs from the testbench directory.
  • Absolute paths and the optional session parameter retain their existing behavior.
  • import_run_script, which uses import_module_from_file internally, continues to work.
  • Documentation explains the path base and runner-setup requirement.
  • Release notes flag the change for callers relying on working-directory-relative imports.

Resolving paths relative to the calling component’s own VHDL source directory is outside the scope of this issue.

Activity

  1. assigned and unassigned on Oct 2, 2026
  2. added a commit that references this issue on Oct 3, 2026
    5d86497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions