Skip to content

Make config/languages.json discoverable when openant-core is vendored or pip-installed standalone #64

Description

@ar7casper

Context

libs/openant-core/core/parser_adapter.py:30 resolves the shared language-detection config like this:

_LANGUAGES_CONFIG = Path(__file__).parent.parent.parent.parent / "config" / "languages.json"

Walks four .parent levels: core/parser_adapter.pycore/openant-core/libs/ → repo root → config/languages.json. Works correctly in the current monorepo layout.

The gap

The file is outside the openant-core package. If openant-core is:

  • Vendored into another project at a different depth
  • Pip-installed standalone (pip install openant-core someday)
  • Run from a worktree at a non-standard path
  • Moved during a refactor

…the four-.parent walk lands at the wrong directory and read_json(_LANGUAGES_CONFIG) raises FileNotFoundError.

Proposed approaches

Option A — Move the config inside openant-core, use importlib.resources (preferred)

Move config/languages.json to libs/openant-core/openant/config/languages.json. Update both consumers:

  • Python: from importlib.resources import files; data = json.loads(files('openant.config').joinpath('languages.json').read_text())
  • Go (apps/openant-cli/cmd/init.go::findLanguagesConfig): already walks from executable + cwd up to 6 levels — just update the relative path it's looking for.

Option B — Multiple search candidates with env override

Try importlib.resources first, fall back to repo-root path, then OPENANT_LANGUAGES_CONFIG env var.

Recommendation

Option A — follows Python packaging best practice. Config files that ship with the package live inside the package.

Why this is its own issue

Raised as a non-blocking Low in #40 round-1 review. #40 shipped the four-.parent walk knowing the limitation. Worth fixing eventually but doesn't block the current monorepo workflow.

References

  • libs/openant-core/core/parser_adapter.py:30 — the fragile path
  • apps/openant-cli/cmd/init.go::findLanguagesConfig — Go side, already more robust
  • config/languages.json — the file (introduced in feat: auto-detect language in init #40)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions