fastapi-cli 0.0.2__py3-none-any.whl → 0.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fastapi_cli/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.2"
1
+ __version__ = "0.0.4"
fastapi_cli/cli.py CHANGED
@@ -3,7 +3,6 @@ from pathlib import Path
3
3
  from typing import Any, Union
4
4
 
5
5
  import typer
6
- import uvicorn
7
6
  from rich import print
8
7
  from rich.padding import Padding
9
8
  from rich.panel import Panel
@@ -20,6 +19,11 @@ app = typer.Typer(rich_markup_mode="rich")
20
19
  setup_logging()
21
20
  logger = getLogger(__name__)
22
21
 
22
+ try:
23
+ import uvicorn
24
+ except ImportError: # pragma: no cover
25
+ uvicorn = None # type: ignore[assignment]
26
+
23
27
 
24
28
  def version_callback(value: bool) -> None:
25
29
  if value:
@@ -51,6 +55,7 @@ def _run(
51
55
  host: str = "127.0.0.1",
52
56
  port: int = 8000,
53
57
  reload: bool = True,
58
+ workers: Union[int, None] = None,
54
59
  root_path: str = "",
55
60
  command: str,
56
61
  app: Union[str, None] = None,
@@ -80,11 +85,16 @@ def _run(
80
85
  style="green",
81
86
  )
82
87
  print(Padding(panel, 1))
88
+ if not uvicorn:
89
+ raise FastAPICLIException(
90
+ "Could not import Uvicorn, try running 'pip install uvicorn'"
91
+ ) from None
83
92
  uvicorn.run(
84
93
  app=use_uvicorn_app,
85
94
  host=host,
86
95
  port=port,
87
96
  reload=reload,
97
+ workers=workers,
88
98
  root_path=root_path,
89
99
  proxy_headers=proxy_headers,
90
100
  )
@@ -200,6 +210,12 @@ def run(
200
210
  help="Enable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development."
201
211
  ),
202
212
  ] = False,
213
+ workers: Annotated[
214
+ Union[int, None],
215
+ typer.Option(
216
+ help="Use multiple worker processes. Mutually exclusive with the --reload flag."
217
+ ),
218
+ ] = None,
203
219
  root_path: Annotated[
204
220
  str,
205
221
  typer.Option(
@@ -249,6 +265,7 @@ def run(
249
265
  host=host,
250
266
  port=port,
251
267
  reload=reload,
268
+ workers=workers,
252
269
  root_path=root_path,
253
270
  app=app,
254
271
  command="run",
fastapi_cli/discover.py CHANGED
@@ -5,7 +5,6 @@ from logging import getLogger
5
5
  from pathlib import Path
6
6
  from typing import Union
7
7
 
8
- from fastapi import FastAPI
9
8
  from rich import print
10
9
  from rich.padding import Padding
11
10
  from rich.panel import Panel
@@ -16,6 +15,11 @@ from fastapi_cli.exceptions import FastAPICLIException
16
15
 
17
16
  logger = getLogger(__name__)
18
17
 
18
+ try:
19
+ from fastapi import FastAPI
20
+ except ImportError: # pragma: no cover
21
+ FastAPI = None # type: ignore[misc, assignment]
22
+
19
23
 
20
24
  def get_default_path() -> Path:
21
25
  path = Path("main.py")
@@ -107,6 +111,10 @@ def get_app_name(*, mod_data: ModuleData, app_name: Union[str, None] = None) ->
107
111
  "Ensure all the package directories have an [blue]__init__.py[/blue] file"
108
112
  )
109
113
  raise
114
+ if not FastAPI: # type: ignore[truthy-function]
115
+ raise FastAPICLIException(
116
+ "Could not import FastAPI, try running 'pip install fastapi'"
117
+ ) from None
110
118
  object_names = dir(mod)
111
119
  object_names_set = set(object_names)
112
120
  if app_name:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastapi-cli
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
5
5
  Home-page: https://github.com/tiangolo/fastapi-cli
6
6
  Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
@@ -32,8 +32,9 @@ Project-URL: Homepage, https://github.com/tiangolo/fastapi-cli
32
32
  Project-URL: Repository, https://github.com/tiangolo/fastapi-cli
33
33
  Requires-Python: >=3.8
34
34
  Requires-Dist: typer>=0.12.3
35
- Requires-Dist: fastapi
36
- Requires-Dist: uvicorn[standard]>=0.29.0
35
+ Requires-Dist: fastapi; extra == "standard"
36
+ Requires-Dist: uvicorn[standard]>=0.15.0; extra == "standard"
37
+ Provides-Extra: standard
37
38
  Description-Content-Type: text/markdown
38
39
 
39
40
  # FastAPI CLI
@@ -120,6 +121,8 @@ FastAPI CLI takes the path to your Python program and automatically detects the
120
121
 
121
122
  For production you would use `fastapi run` instead. 🚀
122
123
 
124
+ Internally, **FastAPI CLI** uses <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>, a high-performance, production-ready, ASGI server. 😎
125
+
123
126
  ## `fastapi dev`
124
127
 
125
128
  When you run `fastapi dev`, it will run on development mode.
@@ -0,0 +1,12 @@
1
+ fastapi_cli-0.0.4.dist-info/METADATA,sha256=BygSIC-5T6QJPYcaT2vP8vnOAcv8zA1JAV6OmhxuNr4,7022
2
+ fastapi_cli-0.0.4.dist-info/WHEEL,sha256=vnE8JVcI2Wz7GRKorsPArnBdnW2SWKWGow5gu5tHlRU,90
3
+ fastapi_cli-0.0.4.dist-info/entry_points.txt,sha256=RLUGtkrAf9gNKxCS3EeJNYN8AF1Er364vjW7bnEcCA8,50
4
+ fastapi_cli-0.0.4.dist-info/licenses/LICENSE,sha256=FqD5B4VbXJnefprQseE0U8llL6FxojC-i8muZy7YmSU,1086
5
+ fastapi_cli/__init__.py,sha256=1mptEzQihbdyqqzMgdns_j5ZGK9gz7hR2bsgA_TnjO4,22
6
+ fastapi_cli/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
7
+ fastapi_cli/cli.py,sha256=o7dRxEfZ_lBO72b6RZEAa_wKua2pkK5kp6Rr5PhZML4,9278
8
+ fastapi_cli/discover.py,sha256=MxXPVqd9X-cgUdikVECjs8BtXcXygX8g3zppUEyqK5Y,5570
9
+ fastapi_cli/exceptions.py,sha256=AHRSqd43fbqN5IpX-Fq389k9MoEK_q28wVFL7oqPNcc,47
10
+ fastapi_cli/logging.py,sha256=lI7rIsioTJQsxDuWpG5YR_brWpIAUY4vDnhYm5p91ws,664
11
+ fastapi_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ fastapi_cli-0.0.4.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- fastapi_cli-0.0.2.dist-info/METADATA,sha256=DADt2yADHsKGZzCrzC4bcnF7ZKyHZnmaGPXSjmEzRVc,6780
2
- fastapi_cli-0.0.2.dist-info/WHEEL,sha256=vnE8JVcI2Wz7GRKorsPArnBdnW2SWKWGow5gu5tHlRU,90
3
- fastapi_cli-0.0.2.dist-info/entry_points.txt,sha256=RLUGtkrAf9gNKxCS3EeJNYN8AF1Er364vjW7bnEcCA8,50
4
- fastapi_cli-0.0.2.dist-info/licenses/LICENSE,sha256=FqD5B4VbXJnefprQseE0U8llL6FxojC-i8muZy7YmSU,1086
5
- fastapi_cli/__init__.py,sha256=QvlVh4JTl3JL7jQAja76yKtT-IvF4631ASjWY1wS6AQ,22
6
- fastapi_cli/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
7
- fastapi_cli/cli.py,sha256=OkiQenSf9HgBN7FxTTAoLfzqySsX1Z6FGxlRU7ILcGM,8754
8
- fastapi_cli/discover.py,sha256=5QbjDHEbfNUQoYG7ZXRfYWvSJkj74ojkFtzUftPb2VE,5285
9
- fastapi_cli/exceptions.py,sha256=AHRSqd43fbqN5IpX-Fq389k9MoEK_q28wVFL7oqPNcc,47
10
- fastapi_cli/logging.py,sha256=lI7rIsioTJQsxDuWpG5YR_brWpIAUY4vDnhYm5p91ws,664
11
- fastapi_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- fastapi_cli-0.0.2.dist-info/RECORD,,