1414import httpx
1515import tomlkit
1616import typer
17- from tomlkit .exceptions import TOMLKitError
17+ from tomlkit .exceptions import NonExistentKey , TOMLKitError
1818
1919from reflex import constants
2020from reflex .config import environment , get_config
@@ -533,7 +533,13 @@ def _get_version_to_publish() -> str:
533533 Returns:
534534 The version to publish.
535535 """
536- return _get_package_config ()["project" ]["version" ]
536+ try :
537+ return _get_package_config ()["project" ]["version" ]
538+ except NonExistentKey :
539+ # Try to get the version from dynamic sources
540+ import build .util
541+
542+ return build .util .project_wheel_metadata ("." , isolated = True )["version" ]
537543
538544
539545def _ensure_dist_dir (version_to_publish : str , build : bool ):
@@ -756,7 +762,7 @@ def _min_validate_project_info():
756762 )
757763 raise typer .Exit (code = 1 )
758764
759- if not project .get ("version" ):
765+ if not project .get ("version" ) and "version" not in project . get ( "dynamic" , []) :
760766 console .error (
761767 f"The project version is not found in { CustomComponents .PYPROJECT_TOML } "
762768 )
@@ -772,7 +778,7 @@ def _validate_project_info():
772778 pyproject_toml = _get_package_config ()
773779 project = pyproject_toml ["project" ]
774780 console .print (
775- f"Double check the information before publishing: { project ['name' ]} version { project [ 'version' ] } "
781+ f"Double check the information before publishing: { project ['name' ]} version { _get_version_to_publish () } "
776782 )
777783
778784 console .print ("Update or enter to keep the current information." )
0 commit comments