RustPython / RustPython/RustPython

Importing RustPython via Git leads to failure in importing local modules.

Open
#6,138 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
22.4k
Forks
1.5k
Avg merge
16h 33m
Merged PRs (30d)
165

Description

When I import the latest version of RustPython dependencies using Git, I encounter issues with failing to import local modules. However, if I use version 0.4.0 from crates.io, the imports work successfully.

rustpython = { git = "https://github.com/RustPython/RustPython", branch = "main", features = ["stdlib", "freeze-stdlib","threading","ssl-vendor" ] }
rustpython-vm = { git = "https://github.com/RustPython/RustPython", branch = "main" }

python code:

    script_dir = os.path.dirname(__file__)
    print(f"Script directory: {script_dir}")
    print("Python directory contents:")
    for item in os.listdir(script_dir):
       item_path = os.path.join(script_dir, item)
       if os.path.isdir(item_path):
             print(f"  [DIR]  {item}")
    test_dir = os.path.join(script_dir, 'test')
    if os.path.exists(test_dir):
      print(f"\nTest directory contents:")
      for item in os.listdir(test_dir):
        print(f"  {item}")
    else:
        print(f"\nTest directory does not exist at: {test_dir}")

    try:
          from test.test_base import TestBase
          print("Import successful!")
    except ImportError as e:
          print(f"Import failed: {e}")

Print log:
[python/main.py:379 in main()] Script directory: /var/mobile/Containers/Data/Application/4FC1AFD7-F437-48CB-B439-B165177E3CEB/Documents/home/debug/main/python
[python/main.py:380 in main()] Python directory contents:
[python/main.py:384 in main()] [DIR] test
[python/main.py:387 in main()] Test directory contents:
[python/main.py:389 in main()] test_base.py
[python/main.py:397 in main()] Import failed: No module named 'test.test_base'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported import with RustPython from the main Git branch and compare it with the working 0.4.0 crates.io version, using the provided Python snippet and dependency declarations. Trace the local-module import path around the failure; the issue is done when importing test.test_base works with the Git dependencies without breaking the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.