foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Bug Report: Incorrect File Path in RF3 Code Reference

Open Masterchiefm opened this issue 2 weeks ago • 0 comments

Hello,

I’ve encountered an issue with the rf3 module when it is installed via pip. The cli.py tool fails to locate the correct configuration directory, which appears to be due to how __file__ is resolved in an installed package environment.

Problem Description: In models/rf3/src/rf3/cli.py, lines 28–29 are intended to return the path models/rf3/configs. However, when the package is installed and run from /usr/local/lib/python3.12/site-packages/, it incorrectly returns /usr/local/lib/python3.12/configs.

Steps to Reproduce:

  1. Install fondry via pip.
  2. cd to modole/rf3 and Run the test: rf3 fold inputs='tests/data/5vht_from_json.json'
  3. Observe that the config path points to a system directory /usr/local/lib/python3.12/site-packages/ instead of the package-relative models/rf3/configs.

Evidence:

  1. Relevant code section (models/rf3/src/rf3/cli.py):

    # Lines 28–29 – expected to return models/rf3/configs
    

    Code snippet

  2. Incorrect output after adding debug print: Debug output

    The printed path shows /usr/local/lib/python3.12/configs.

Root Cause Analysis: The code uses __file__ to locate the rf3 directory. When running from source, this works correctly. However, when installed via pip, __file__ points to the site-packages location, breaking the relative path resolution.

Additional Impact: The same issue likely affects the .project-root detection, causing further errors when trying to resolve project-relative paths.

Error when attempting to manually correct the config path: Project root error

Suggested Fix: Consider using pkg_resources or importlib.resources to locate package data in a way that works both in development and in an installed environment, rather than relying solely on __file__.

Environment:

  • Python 3.12
  • Installed via pip
  • OS: [Your OS, if relevant]

Let me know if you need further details or testing assistance.

Masterchiefm avatar Dec 12 '25 03:12 Masterchiefm