Skip to content

feat: make rxconfig.py filename configurable via env vars#6124

Open
timon0305 wants to merge 3 commits intoreflex-dev:mainfrom
timon0305:feature/configurable-rxconfig-filename-v2
Open

feat: make rxconfig.py filename configurable via env vars#6124
timon0305 wants to merge 3 commits intoreflex-dev:mainfrom
timon0305:feature/configurable-rxconfig-filename-v2

Conversation

@timon0305
Copy link

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • New feature (non-breaking change which adds functionality)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Summary

Make the rxconfig.py config filename configurable via two new environment variables:

  • REFLEX_CONFIG_MODULE — Python module name to import (default: rxconfig)
  • REFLEX_CONFIG_FILE — Config file path on disk (default: {module_name}.py)

This allows users to rename rxconfig.py to any filename they prefer, making the framework less opinionated about repo structure naming conventions.

How it works

  • A metaclass _ConfigMeta on constants.Config makes MODULE and FILE dynamic class-level properties that resolve from environment variables at access time
  • All hardcoded "rxconfig.py" strings in error messages and file detection logic now use constants.Config.FILE
  • Fully backward compatible — defaults to rxconfig / rxconfig.py when no env vars are set

Files changed (5)

File Change
reflex/constants/config.py Added _ConfigMeta metaclass to make Config.MODULE and Config.FILE dynamic
reflex/config.py Updated plugin warning messages to use dynamic constants.Config.FILE
reflex/utils/exec.py Updated hot reload config file detection to use dynamic filename
reflex/utils/prerequisites.py Updated error messages to use dynamic config filename
reflex/utils/rename.py Updated file existence checks and error messages to use dynamic config filename

Usage

# Rename config file and run with custom module name
mv rxconfig.py myconfig.py
REFLEX_CONFIG_MODULE=myconfig reflex run

# Or with explicit file path
REFLEX_CONFIG_MODULE=app_config REFLEX_CONFIG_FILE=app_config.py reflex run

Test results

  • 3375 unit tests passed, 0 failed
  • End-to-end tested: default behavior, custom module, custom file, error messages, hot reload detection

closes #6117

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 11, 2026

Greptile Overview

Greptile Summary

This PR makes the project config filename configurable via REFLEX_CONFIG_MODULE and REFLEX_CONFIG_FILE, exposing them through dynamic constants.Config.MODULE and constants.Config.FILE. Downstream code that previously hard-coded rxconfig.py (warnings, hot-reload root detection, rename tooling, and error messages) now references constants.Config.FILE.

Main issue to address before merge: a few call sites treat Config.FILE as a simple filename, but it can now be a path (e.g. configs/myconfig.py). In those cases, comparing against child_file.name or constructing current_dir / Config.FILE will fail to detect the config file and can break app-root detection logic (notably in hot reload and rename traversal).

Confidence Score: 4/5

  • Mostly safe to merge after fixing path-vs-basename handling for the configurable config file.
  • The change is localized and largely swaps hardcoded rxconfig.py references for constants.Config.FILE, but two code paths (hot reload root detection and rename root traversal) will behave incorrectly when REFLEX_CONFIG_FILE includes directories rather than just a basename.
  • reflex/utils/exec.py, reflex/utils/rename.py

Important Files Changed

Filename Overview
reflex/constants/config.py Introduces env-driven dynamic Config.MODULE/Config.FILE via metaclass; looks correct but returns potentially relative Paths from env.
reflex/config.py Updates plugin warning messages to reference constants.Config.FILE; no behavioral changes beyond messaging.
reflex/utils/exec.py Replaces hardcoded rxconfig.py with constants.Config.FILE in hot-reload path logic; introduces basename vs path mismatch when env provides a path.
reflex/utils/prerequisites.py Updates error messages to reference dynamic config filename; no functional behavior changes.
reflex/utils/rename.py Uses constants.Config.FILE for root/config detection and messages; root detection can fail when REFLEX_CONFIG_FILE includes directories.

Sequence Diagram

sequenceDiagram
    participant User
    participant Env as Environment Vars
    participant C as constants.Config
    participant Exec as utils.exec.get_reload_paths
    participant Ren as utils.rename.rename_path_up_tree

    User->>Env: set REFLEX_CONFIG_MODULE / REFLEX_CONFIG_FILE (optional)
    Exec->>C: access Config.FILE
    C->>Env: read env vars
    C-->>Exec: Path to config (derived or env)
    Exec->>Exec: _has_child_file(dir, str(Config.FILE))
    Exec-->>Exec: decide app root / __init__.py cleanup

    Ren->>C: access Config.FILE
    C->>Env: read env vars
    C-->>Ren: Path to config (derived or env)
    Ren->>Ren: check (current_dir / Config.FILE).exists()
    Ren-->>Ren: stop-at-root decision
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

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.

Flexibility in renaming the rxconfig.py File

1 participant