@@ -840,18 +840,24 @@ def initialize_gitignore(
840840
841841def initialize_requirements_txt () -> bool :
842842 """Initialize the requirements.txt file.
843- If absent, generate one for the user.
843+ If absent and no pyproject.toml file exists , generate one for the user.
844844 If the requirements.txt does not have reflex as dependency,
845845 generate a requirement pinning current version and append to
846846 the requirements.txt file.
847847
848848 Returns:
849- True if the requirements.txt file was created or updated, False otherwise .
849+ True if the user has to update the requirements.txt file .
850850
851851 Raises:
852852 Exit: If the requirements.txt file cannot be read or written to.
853853 """
854854 requirements_file_path = Path (constants .RequirementsTxt .FILE )
855+ if (
856+ not requirements_file_path .exists ()
857+ and Path (constants .PyprojectToml .FILE ).exists ()
858+ ):
859+ return True
860+
855861 requirements_file_path .touch (exist_ok = True )
856862
857863 for encoding in [None , "utf-8" ]:
@@ -864,12 +870,12 @@ def initialize_requirements_txt() -> bool:
864870 console .error (f"Failed to read { requirements_file_path } ." )
865871 raise click .exceptions .Exit (1 ) from e
866872 else :
867- return False
873+ return True
868874
869875 for line in content .splitlines ():
870876 if re .match (r"^reflex[^a-zA-Z0-9]" , line ):
871877 console .debug (f"{ requirements_file_path } already has reflex as dependency." )
872- return True
878+ return False
873879
874880 console .debug (
875881 f"Appending { constants .RequirementsTxt .DEFAULTS_STUB } to { requirements_file_path } "
@@ -879,7 +885,7 @@ def initialize_requirements_txt() -> bool:
879885 "\n " + constants .RequirementsTxt .DEFAULTS_STUB + constants .Reflex .VERSION
880886 )
881887
882- return True
888+ return False
883889
884890
885891def initialize_app_directory (
0 commit comments