Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies = [
"pydantic[email] >= 2.0",
"sentry-sdk >= 2.20.0",
"fastar >= 0.8.0",
"tomli; python_version < '3.11'",
]

[project.optional-dependencies]
Expand Down
29 changes: 28 additions & 1 deletion src/fastapi_cloud_cli/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
from rich.text import Text
from rich_toolkit import RichToolkit
from rich_toolkit.menu import Option
try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib

from fastapi_cloud_cli.commands.login import login
from fastapi_cloud_cli.utils.api import APIClient, StreamLogError, TooManyRetriesError
Expand All @@ -39,9 +43,32 @@ def _cancel_upload(deployment_id: str) -> None:
except Exception as e:
logger.debug("Failed to notify server about upload cancellation: %s", e)

def _project_name_from_pyproject(path: Path) -> str:
if not path.exists():
return ""

try:
with path.open("rb") as f:
data = tomllib.load(f)

project_name = data.get("project", {}).get("name")
if project_name:
return project_name

poetry_name = data.get("tool", {}).get("poetry", {}).get("name")
if poetry_name:
return poetry_name

except Exception:
return ""

return ""

def _get_app_name(path: Path) -> str:
# TODO: use pyproject.toml to get the app name
pyproject_path = path / "pyproject.toml"
name = _project_name_from_pyproject(pyproject_path)
if name:
return name
return path.name


Expand Down
2 changes: 2 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading