File tree Expand file tree Collapse file tree
src/fastapi_cloud_cli/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ dependencies = [
3737 " pydantic[email] >= 2.0" ,
3838 " sentry-sdk >= 2.20.0" ,
3939 " fastar >= 0.8.0" ,
40+ " tomli; python_version < '3.11'" ,
4041]
4142
4243[project .optional-dependencies ]
Original file line number Diff line number Diff line change 1717from rich .text import Text
1818from rich_toolkit import RichToolkit
1919from rich_toolkit .menu import Option
20+ try :
21+ import tomllib
22+ except ModuleNotFoundError :
23+ import tomli as tomllib
2024
2125from fastapi_cloud_cli .commands .login import login
2226from fastapi_cloud_cli .utils .api import APIClient , StreamLogError , TooManyRetriesError
@@ -39,9 +43,32 @@ def _cancel_upload(deployment_id: str) -> None:
3943 except Exception as e :
4044 logger .debug ("Failed to notify server about upload cancellation: %s" , e )
4145
46+ def _project_name_from_pyproject (path : Path ) -> str :
47+ if not path .exists ():
48+ return ""
49+
50+ try :
51+ with path .open ("rb" ) as f :
52+ data = tomllib .load (f )
53+
54+ project_name = data .get ("project" , {}).get ("name" )
55+ if project_name :
56+ return project_name
57+
58+ poetry_name = data .get ("tool" , {}).get ("poetry" , {}).get ("name" )
59+ if poetry_name :
60+ return poetry_name
61+
62+ except Exception :
63+ return ""
64+
65+ return ""
4266
4367def _get_app_name (path : Path ) -> str :
44- # TODO: use pyproject.toml to get the app name
68+ pyproject_path = path / "pyproject.toml"
69+ name = _project_name_from_pyproject (pyproject_path )
70+ if name :
71+ return name
4572 return path .name
4673
4774
You can’t perform that action at this time.
0 commit comments