iT邦幫忙

2023 iThome 鐵人賽

DAY 28
0

小獅:誒都,電腦壞掉了

老獅:程式都有上傳了吧?

小獅:有喔,都有推上去

老獅:去隔壁 IT 部門拿一台能用的,我們來重新建立環境吧

小獅:我需要些什麼?

老獅:老樣子,先把 git, docker, docker-compose 以及 python 裝起來

小獅:好喔,然後拉最新的程式碼對吧?

老獅:是的,拉完我們再來處理其他的

git clone git@github.com:lambdaTW/fastit.git

小獅:可以裝套件了吧?

老獅:你的虛擬環境呢?

小獅:好喔!

python -m venv venv
source venv/bin/activate

小獅:好拉!

make pip
pip3 show pip-tools && echo "pip-tools is installed" || (pip3 install -U pip && pip3 install -U pip-tools)
WARNING: Package(s) not found: pip-tools
Requirement already satisfied: pip in ./venv/lib/python3.11/site-packages (23.0.1)
Collecting pip
  Using cached pip-23.2.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 23.0.1
    Uninstalling pip-23.0.1:
      Successfully uninstalled pip-23.0.1
Successfully installed pip-23.2.1
Collecting pip-tools
  Obtaining dependency information for pip-tools from https://files.pythonhosted.org/packages/e8/df/47e6267c6b5cdae867adbdd84b437393e6202ce4322de0a5e0b92960e1d6/pip_tools-7.3.0-py3-none-any.whl.metadata
  Using cached pip_tools-7.3.0-py3-none-any.whl.metadata (23 kB)
Collecting build (from pip-tools)
  Obtaining dependency information for build from https://files.pythonhosted.org/packages/93/dd/b464b728b866aaa62785a609e0dd8c72201d62c5f7c53e7c20f4dceb085f/build-1.0.3-py3-none-any.whl.metadata
  Using cached build-1.0.3-py3-none-any.whl.metadata (4.2 kB)
Collecting click>=8 (from pip-tools)
  Obtaining dependency information for click>=8 from https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl.metadata
  Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Requirement already satisfied: pip>=22.2 in ./venv/lib/python3.11/site-packages (from pip-tools) (23.2.1)
Requirement already satisfied: setuptools in ./venv/lib/python3.11/site-packages (from pip-tools) (67.6.1)
Collecting wheel (from pip-tools)
  Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/b8/8b/31273bf66016be6ad22bb7345c37ff350276cfd46e389a0c2ac5da9d9073/wheel-0.41.2-py3-none-any.whl.metadata
  Using cached wheel-0.41.2-py3-none-any.whl.metadata (2.2 kB)
Collecting packaging>=19.0 (from build->pip-tools)
  Obtaining dependency information for packaging>=19.0 from https://files.pythonhosted.org/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl.metadata
  Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB)
Collecting pyproject_hooks (from build->pip-tools)
  Using cached pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)
Using cached pip_tools-7.3.0-py3-none-any.whl (57 kB)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Using cached build-1.0.3-py3-none-any.whl (18 kB)
Using cached wheel-0.41.2-py3-none-any.whl (64 kB)
Using cached packaging-23.2-py3-none-any.whl (53 kB)
Installing collected packages: wheel, pyproject_hooks, packaging, click, build, pip-tools
Successfully installed build-1.0.3 click-8.1.7 packaging-23.2 pip-tools-7.3.0 pyproject_hooks-1.0.0 wheel-0.41.2
ls requirements/*.in | xargs -n1 pip-compile --resolver=backtracking --strip-extras
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
#    pip-compile --strip-extras requirements/base.in
#
alembic==1.12.0
    # via -r requirements/base.in
annotated-types==0.5.0
    # via pydantic
anyio==3.7.1
    # via
    #   starlette
    #   watchfiles
asyncpg==0.28.0
    # via -r requirements/base.in
bcrypt==4.0.1
    # via passlib
cffi==1.15.1
    # via cryptography
click==8.1.7
    # via uvicorn
cryptography==41.0.3
    # via python-jose
ecdsa==0.18.0
    # via python-jose
fastapi==0.101.1
    # via -r requirements/base.in
greenlet==2.0.2
    # via sqlalchemy
h11==0.14.0
    # via uvicorn
httptools==0.6.0
    # via uvicorn
idna==3.4
    # via anyio
mako==1.2.4
    # via alembic
markupsafe==2.1.3
    # via mako
passlib==1.7.4
    # via -r requirements/base.in
pyasn1==0.5.0
    # via
    #   python-jose
    #   rsa
pycparser==2.21
    # via cffi
pydantic==2.2.1
    # via
    #   fastapi
    #   pydantic-settings
pydantic-core==2.6.1
    # via pydantic
pydantic-settings==2.0.3
    # via -r requirements/base.in
python-dotenv==1.0.0
    # via
    #   pydantic-settings
    #   uvicorn
python-jose==3.3.0
    # via -r requirements/base.in
pyyaml==6.0.1
    # via uvicorn
rsa==4.9
    # via python-jose
six==1.16.0
    # via ecdsa
sniffio==1.3.0
    # via anyio
sqlalchemy==2.0.20
    # via
    #   -r requirements/base.in
    #   alembic
    #   sqlalchemy-utils
sqlalchemy-utils==0.41.1
    # via -r requirements/base.in
starlette==0.27.0
    # via fastapi
typing-extensions==4.7.1
    # via
    #   alembic
    #   fastapi
    #   pydantic
    #   pydantic-core
    #   sqlalchemy
uvicorn==0.23.2
    # via -r requirements/base.in
uvloop==0.17.0
    # via uvicorn
watchfiles==0.19.0
    # via uvicorn
websockets==11.0.3
    # via uvicorn
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
#    pip-compile --strip-extras requirements/development.in
#
anyio==3.7.1
    # via httpcore
black==23.7.0
    # via -r requirements/development.in
certifi==2023.7.22
    # via
    #   httpcore
    #   httpx
click==8.1.7
    # via black
h11==0.14.0
    # via httpcore
httpcore==0.17.3
    # via httpx
httpx==0.24.1
    # via -r requirements/development.in
idna==3.4
    # via
    #   anyio
    #   httpx
iniconfig==2.0.0
    # via pytest
isort==5.12.0
    # via -r requirements/development.in
mypy-extensions==1.0.0
    # via black
packaging==23.1
    # via
    #   black
    #   pytest
pathspec==0.11.2
    # via black
platformdirs==3.10.0
    # via black
pluggy==1.2.0
    # via pytest
pytest==7.4.0
    # via
    #   -r requirements/development.in
    #   pytest-asyncio
pytest-asyncio==0.21.1
    # via -r requirements/development.in
ruff==0.0.287
    # via -r requirements/development.in
sniffio==1.3.0
    # via
    #   anyio
    #   httpcore
    #   httpx
pip-sync `ls requirements/*.txt`
Collecting alembic==1.12.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 1))
  Obtaining dependency information for alembic==1.12.0 from https://files.pythonhosted.org/packages/a2/8b/46919127496036c8e990b2b236454a0d8655fd46e1df2fd35610a9cbc842/alembic-1.12.0-py3-none-any.whl.metadata
  Using cached alembic-1.12.0-py3-none-any.whl.metadata (7.2 kB)
Collecting annotated-types==0.5.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 2))
  Obtaining dependency information for annotated-types==0.5.0 from https://files.pythonhosted.org/packages/d8/f0/a2ee543a96cc624c35a9086f39b1ed2aa403c6d355dfe47a11ee5c64a164/annotated_types-0.5.0-py3-none-any.whl.metadata
  Using cached annotated_types-0.5.0-py3-none-any.whl.metadata (11 kB)
Collecting anyio==3.7.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 3))
  Obtaining dependency information for anyio==3.7.1 from https://files.pythonhosted.org/packages/19/24/44299477fe7dcc9cb58d0a57d5a7588d6af2ff403fdd2d47a246c91a3246/anyio-3.7.1-py3-none-any.whl.metadata
  Using cached anyio-3.7.1-py3-none-any.whl.metadata (4.7 kB)
Collecting asyncpg==0.28.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 4))
  Obtaining dependency information for asyncpg==0.28.0 from https://files.pythonhosted.org/packages/f3/5d/2b5f88592a75aa29b18d62f6d665457dd0df529b6a3317311b4e7b95f754/asyncpg-0.28.0-cp311-cp311-macosx_10_9_x86_64.whl.metadata
  Using cached asyncpg-0.28.0-cp311-cp311-macosx_10_9_x86_64.whl.metadata (4.3 kB)
Collecting bcrypt==4.0.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 5))
  Using cached bcrypt-4.0.1-cp36-abi3-macosx_10_10_universal2.whl (473 kB)
Collecting black==23.7.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 6))
  Obtaining dependency information for black==23.7.0 from https://files.pythonhosted.org/packages/51/32/4dacd14494e60d93cbfaea023f9a82c1db998ddfa5a359afeaf5e2c11f8c/black-23.7.0-cp311-cp311-macosx_10_16_x86_64.whl.metadata
  Using cached black-23.7.0-cp311-cp311-macosx_10_16_x86_64.whl.metadata (63 kB)
Collecting certifi==2023.7.22 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 7))
  Obtaining dependency information for certifi==2023.7.22 from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata
  Using cached certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Collecting cffi==1.15.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 8))
  Using cached cffi-1.15.1-cp311-cp311-macosx_10_9_x86_64.whl (179 kB)
Collecting cryptography==41.0.3 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 9))
  Obtaining dependency information for cryptography==41.0.3 from https://files.pythonhosted.org/packages/a2/e6/2331e5bde68343b820a9e5d937b2e22a0f81ba68e87b74dbbdd98944da4e/cryptography-41.0.3-cp37-abi3-macosx_10_12_x86_64.whl.metadata
  Using cached cryptography-41.0.3-cp37-abi3-macosx_10_12_x86_64.whl.metadata (5.2 kB)
Collecting ecdsa==0.18.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 10))
  Using cached ecdsa-0.18.0-py2.py3-none-any.whl (142 kB)
Collecting fastapi==0.101.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 11))
  Obtaining dependency information for fastapi==0.101.1 from https://files.pythonhosted.org/packages/09/ae/8378894f9fbdf0297cdffdc79496ccd779166d675fec47cad8d2ca782739/fastapi-0.101.1-py3-none-any.whl.metadata
  Using cached fastapi-0.101.1-py3-none-any.whl.metadata (23 kB)
Collecting greenlet==2.0.2 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 12))
  Using cached greenlet-2.0.2-cp311-cp311-macosx_10_9_universal2.whl (243 kB)
Collecting h11==0.14.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 13))
  Using cached h11-0.14.0-py3-none-any.whl (58 kB)
Collecting httpcore==0.17.3 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 14))
  Obtaining dependency information for httpcore==0.17.3 from https://files.pythonhosted.org/packages/94/2c/2bde7ff8dd2064395555220cbf7cba79991172bf5315a07eb3ac7688d9f1/httpcore-0.17.3-py3-none-any.whl.metadata
  Using cached httpcore-0.17.3-py3-none-any.whl.metadata (18 kB)
Collecting httptools==0.6.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 15))
  Obtaining dependency information for httptools==0.6.0 from https://files.pythonhosted.org/packages/61/46/c06a1f2a35d961204c1fd38700220df71ddcf5d01ff0f4cae73e28b67480/httptools-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl.metadata
  Using cached httptools-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl.metadata (3.6 kB)
Collecting httpx==0.24.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 16))
  Obtaining dependency information for httpx==0.24.1 from https://files.pythonhosted.org/packages/ec/91/e41f64f03d2a13aee7e8c819d82ee3aa7cdc484d18c0ae859742597d5aa0/httpx-0.24.1-py3-none-any.whl.metadata
  Using cached httpx-0.24.1-py3-none-any.whl.metadata (7.4 kB)
Collecting idna==3.4 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 17))
  Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting iniconfig==2.0.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 18))
  Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting isort==5.12.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 19))
  Using cached isort-5.12.0-py3-none-any.whl (91 kB)
Collecting mako==1.2.4 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 20))
  Using cached Mako-1.2.4-py3-none-any.whl (78 kB)
Collecting markupsafe==2.1.3 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 21))
  Obtaining dependency information for markupsafe==2.1.3 from https://files.pythonhosted.org/packages/c0/c7/171f5ac6b065e1425e8fabf4a4dfbeca76fd8070072c6a41bd5c07d90d8b/MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_x86_64.whl.metadata
  Using cached MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_x86_64.whl.metadata (3.0 kB)
Collecting mypy-extensions==1.0.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 22))
  Using cached mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)
Collecting packaging==23.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 23))
  Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting passlib==1.7.4 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 24))
  Using cached passlib-1.7.4-py2.py3-none-any.whl (525 kB)
Collecting pathspec==0.11.2 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 25))
  Obtaining dependency information for pathspec==0.11.2 from https://files.pythonhosted.org/packages/b4/2a/9b1be29146139ef459188f5e420a66e835dda921208db600b7037093891f/pathspec-0.11.2-py3-none-any.whl.metadata
  Using cached pathspec-0.11.2-py3-none-any.whl.metadata (19 kB)
Collecting platformdirs==3.10.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 26))
  Obtaining dependency information for platformdirs==3.10.0 from https://files.pythonhosted.org/packages/14/51/fe5a0d6ea589f0d4a1b97824fb518962ad48b27cd346dcdfa2405187997a/platformdirs-3.10.0-py3-none-any.whl.metadata
  Using cached platformdirs-3.10.0-py3-none-any.whl.metadata (11 kB)
Collecting pluggy==1.2.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 27))
  Obtaining dependency information for pluggy==1.2.0 from https://files.pythonhosted.org/packages/51/32/4a79112b8b87b21450b066e102d6608907f4c885ed7b04c3fdb085d4d6ae/pluggy-1.2.0-py3-none-any.whl.metadata
  Using cached pluggy-1.2.0-py3-none-any.whl.metadata (4.4 kB)
Collecting pyasn1==0.5.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 28))
  Using cached pyasn1-0.5.0-py2.py3-none-any.whl (83 kB)
Collecting pycparser==2.21 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 29))
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting pydantic==2.2.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 30))
  Obtaining dependency information for pydantic==2.2.1 from https://files.pythonhosted.org/packages/fd/35/86b1e7571e695587df0ddf2937100436dce0caa277d2f016d4e4f7d3791a/pydantic-2.2.1-py3-none-any.whl.metadata
  Using cached pydantic-2.2.1-py3-none-any.whl.metadata (145 kB)
Collecting pydantic-core==2.6.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 31))
  Obtaining dependency information for pydantic-core==2.6.1 from https://files.pythonhosted.org/packages/76/85/3f2ec281b21604cfe8d9dc95fd69a612ab75a4b42a8bbf42cd29307b5e93/pydantic_core-2.6.1-cp311-cp311-macosx_10_7_x86_64.whl.metadata
  Using cached pydantic_core-2.6.1-cp311-cp311-macosx_10_7_x86_64.whl.metadata (6.5 kB)
Collecting pydantic-settings==2.0.3 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 32))
  Obtaining dependency information for pydantic-settings==2.0.3 from https://files.pythonhosted.org/packages/46/92/918ef6b14d54c6a4fccdecd65b3ee15360ca2b4aa52d5c9c4f39f99b4c56/pydantic_settings-2.0.3-py3-none-any.whl.metadata
  Using cached pydantic_settings-2.0.3-py3-none-any.whl.metadata (2.9 kB)
Collecting pytest==7.4.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 33))
  Obtaining dependency information for pytest==7.4.0 from https://files.pythonhosted.org/packages/33/b2/741130cbcf2bbfa852ed95a60dc311c9e232c7ed25bac3d9b8880a8df4ae/pytest-7.4.0-py3-none-any.whl.metadata
  Using cached pytest-7.4.0-py3-none-any.whl.metadata (8.0 kB)
Collecting pytest-asyncio==0.21.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 34))
  Obtaining dependency information for pytest-asyncio==0.21.1 from https://files.pythonhosted.org/packages/7d/2c/2e5ab8708667972ee31b88bb6fed680ed5ba92dfc2db28e07d0d68d8b3b1/pytest_asyncio-0.21.1-py3-none-any.whl.metadata
  Using cached pytest_asyncio-0.21.1-py3-none-any.whl.metadata (4.0 kB)
Collecting python-dotenv==1.0.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 35))
  Using cached python_dotenv-1.0.0-py3-none-any.whl (19 kB)
Collecting python-jose==3.3.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 36))
  Using cached python_jose-3.3.0-py2.py3-none-any.whl (33 kB)
Collecting pyyaml==6.0.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 37))
  Obtaining dependency information for pyyaml==6.0.1 from https://files.pythonhosted.org/packages/ec/0d/26fb23e8863e0aeaac0c64e03fd27367ad2ae3f3cccf3798ee98ce160368/PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl.metadata
  Using cached PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl.metadata (2.1 kB)
Collecting rsa==4.9 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 38))
  Using cached rsa-4.9-py3-none-any.whl (34 kB)
Collecting ruff==0.0.287 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 39))
  Obtaining dependency information for ruff==0.0.287 from https://files.pythonhosted.org/packages/52/c4/0dd703ccd8934d941cdd93974234c615ec6dd56f7653ba9c63c577a75bd3/ruff-0.0.287-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.metadata
  Using cached ruff-0.0.287-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.metadata (21 kB)
Collecting six==1.16.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 40))
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting sniffio==1.3.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 41))
  Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting sqlalchemy==2.0.20 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 42))
  Obtaining dependency information for sqlalchemy==2.0.20 from https://files.pythonhosted.org/packages/b4/2b/570a1caa015115a34562965498276de4251bc6cb049a349541f5693e43c3/SQLAlchemy-2.0.20-cp311-cp311-macosx_10_9_x86_64.whl.metadata
  Using cached SQLAlchemy-2.0.20-cp311-cp311-macosx_10_9_x86_64.whl.metadata (9.4 kB)
Collecting sqlalchemy-utils==0.41.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 43))
  Using cached SQLAlchemy_Utils-0.41.1-py3-none-any.whl (92 kB)
Collecting starlette==0.27.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 44))
  Obtaining dependency information for starlette==0.27.0 from https://files.pythonhosted.org/packages/58/f8/e2cca22387965584a409795913b774235752be4176d276714e15e1a58884/starlette-0.27.0-py3-none-any.whl.metadata
  Using cached starlette-0.27.0-py3-none-any.whl.metadata (5.8 kB)
Collecting typing-extensions==4.7.1 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 45))
  Obtaining dependency information for typing-extensions==4.7.1 from https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl.metadata
  Using cached typing_extensions-4.7.1-py3-none-any.whl.metadata (3.1 kB)
Collecting uvicorn==0.23.2 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 46))
  Obtaining dependency information for uvicorn==0.23.2 from https://files.pythonhosted.org/packages/79/96/b0882a1c3f7ef3dd86879e041212ae5b62b4bd352320889231cc735a8e8f/uvicorn-0.23.2-py3-none-any.whl.metadata
  Using cached uvicorn-0.23.2-py3-none-any.whl.metadata (6.2 kB)
Collecting uvloop==0.17.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 47))
  Using cached uvloop-0.17.0-cp311-cp311-macosx_10_9_x86_64.whl (1.5 MB)
Collecting watchfiles==0.19.0 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 48))
  Using cached watchfiles-0.19.0-cp37-abi3-macosx_10_7_x86_64.whl (405 kB)
Collecting websockets==11.0.3 (from -r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 49))
  Using cached websockets-11.0.3-cp311-cp311-macosx_10_9_x86_64.whl (120 kB)
Requirement already satisfied: click>=8.0.0 in ./venv/lib/python3.11/site-packages (from black==23.7.0->-r /var/folders/4v/h10vk38s6tncnphv23_7fzr00000gn/T/tmpcblbagn2 (line 6)) (8.1.7)
Using cached alembic-1.12.0-py3-none-any.whl (226 kB)
Using cached annotated_types-0.5.0-py3-none-any.whl (11 kB)
Using cached anyio-3.7.1-py3-none-any.whl (80 kB)
Using cached asyncpg-0.28.0-cp311-cp311-macosx_10_9_x86_64.whl (642 kB)
Using cached black-23.7.0-cp311-cp311-macosx_10_16_x86_64.whl (1.5 MB)
Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
Using cached cryptography-41.0.3-cp37-abi3-macosx_10_12_x86_64.whl (2.8 MB)
Using cached fastapi-0.101.1-py3-none-any.whl (65 kB)
Using cached httpcore-0.17.3-py3-none-any.whl (74 kB)
Using cached httptools-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl (162 kB)
Using cached httpx-0.24.1-py3-none-any.whl (75 kB)
Using cached MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_x86_64.whl (13 kB)
Using cached pathspec-0.11.2-py3-none-any.whl (29 kB)
Using cached platformdirs-3.10.0-py3-none-any.whl (17 kB)
Using cached pluggy-1.2.0-py3-none-any.whl (17 kB)
Using cached pydantic-2.2.1-py3-none-any.whl (373 kB)
Using cached pydantic_core-2.6.1-cp311-cp311-macosx_10_7_x86_64.whl (1.7 MB)
Using cached pydantic_settings-2.0.3-py3-none-any.whl (11 kB)
Using cached pytest-7.4.0-py3-none-any.whl (323 kB)
Using cached pytest_asyncio-0.21.1-py3-none-any.whl (13 kB)
Using cached PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl (187 kB)
Using cached ruff-0.0.287-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (11.4 MB)
Using cached SQLAlchemy-2.0.20-cp311-cp311-macosx_10_9_x86_64.whl (2.1 MB)
Using cached starlette-0.27.0-py3-none-any.whl (66 kB)
Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Using cached uvicorn-0.23.2-py3-none-any.whl (59 kB)
Installing collected packages: passlib, websockets, uvloop, typing-extensions, sniffio, six, ruff, pyyaml, python-dotenv, pycparser, pyasn1, pluggy, platformdirs, pathspec, packaging, mypy-extensions, markupsafe, isort, iniconfig, idna, httptools, h11, greenlet, certifi, bcrypt, asyncpg, annotated-types, uvicorn, sqlalchemy, rsa, pytest, pydantic-core, mako, ecdsa, cffi, black, anyio, watchfiles, starlette, sqlalchemy-utils, python-jose, pytest-asyncio, pydantic, httpcore, cryptography, alembic, pydantic-settings, httpx, fastapi
  Attempting uninstall: packaging
    Found existing installation: packaging 23.2
    Uninstalling packaging-23.2:
      Successfully uninstalled packaging-23.2
Successfully installed alembic-1.12.0 annotated-types-0.5.0 anyio-3.7.1 asyncpg-0.28.0 bcrypt-4.0.1 black-23.7.0 certifi-2023.7.22 cffi-1.15.1 cryptography-41.0.3 ecdsa-0.18.0 fastapi-0.101.1 greenlet-2.0.2 h11-0.14.0 httpcore-0.17.3 httptools-0.6.0 httpx-0.24.1 idna-3.4 iniconfig-2.0.0 isort-5.12.0 mako-1.2.4 markupsafe-2.1.3 mypy-extensions-1.0.0 packaging-23.1 passlib-1.7.4 pathspec-0.11.2 platformdirs-3.10.0 pluggy-1.2.0 pyasn1-0.5.0 pycparser-2.21 pydantic-2.2.1 pydantic-core-2.6.1 pydantic-settings-2.0.3 pytest-7.4.0 pytest-asyncio-0.21.1 python-dotenv-1.0.0 python-jose-3.3.0 pyyaml-6.0.1 rsa-4.9 ruff-0.0.287 six-1.16.0 sniffio-1.3.0 sqlalchemy-2.0.20 sqlalchemy-utils-0.41.1 starlette-0.27.0 typing-extensions-4.7.1 uvicorn-0.23.2 uvloop-0.17.0 watchfiles-0.19.0 websockets-11.0.3

小獅:這麼簡單,結束!

老獅:你覺得怎樣算是有把專案跑起來?

小獅:伺服器可以起起來吧?

老獅:那你缺些什麼?

小獅:痾。。。

老獅:何不想辦法把測試跑起來?

小獅:喔!對耶,就算是伺服器沒有跑起來,依照我們之前開發的流程,只要測試跑起來,我就可以繼續開發新的程式,以及修改 bug 了

老獅:是的,跑看看測試吧!

make test
# 省略
=================================================== short test summary info ====================================================
ERROR src/tests/test_services/test_hashes.py::test_create_token_by_username_and_passowrd_hash - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_services/test_token.py::test_create_jwt_token_by_username_and_passowrd - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_services/test_token.py::test_user_cannot_get_jwt_token_by_incorrect_passowrd - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_services/test_token.py::test_create_token_by_username_and_passowrd_hash - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_services/test_users.py::test_superuser_can_create_user[True] - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_services/test_users.py::test_superuser_can_create_user[False] - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_services/test_users.py::test_user_cannot_create_superuser - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_services/test_users.py::test_anonymous_cannot_create_superuser - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
ERROR src/tests/test_units/test_users_crud.py::test_create_and_read_user - OSError: Multiple exceptions: [Errno 61] Connect call failed ('::1', 5432, 0, 0), [Errno 61] Connect call failed ('127.0.0....
============================================ 1 passed, 1 warning, 9 errors in 6.72s ============================================
make: *** [test] Error 1

小獅:啊,忘了把資料庫起起來!這我還記得

docker-comose up -d
[+] Running 3/3
 ✔ Network fastit_default       Created                                                                                    0.1s
 ✔ Volume "fastit_pg_vol"       Created                                                                                    0.0s
 ✔ Container fastit-postgres-1  Started                                                                                    0.0s
make test
pytest .
===================================================== test session starts ======================================================
platform darwin -- Python 3.11.3, pytest-7.4.0, pluggy-1.2.0
rootdir: /Users/super/projects/fastit
configfile: pyproject.toml
plugins: asyncio-0.21.1, anyio-3.7.1
asyncio: mode=Mode.AUTO
collecting ... /Users/super/projects/fastit/src
collected 10 items

src/tests/test_main.py .                                                                                                 [ 10%]
src/tests/test_services/test_hashes.py .                                                                                 [ 20%]
src/tests/test_services/test_token.py ...                                                                                [ 50%]
src/tests/test_services/test_users.py ....                                                                               [ 90%]
src/tests/test_units/test_users_crud.py .                                                                                [100%]

======================================================= warnings summary =======================================================
venv/lib/python3.11/site-packages/passlib/utils/__init__.py:854
  /Users/super/projects/fastit/venv/lib/python3.11/site-packages/passlib/utils/__init__.py:854: DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13
    from crypt import crypt as _crypt

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================ 10 passed, 1 warning in 5.01s =================================================

老獅:很好,恭喜你完成機器移轉,可以繼續開發了

小獅:不用把伺服器起起來看看嗎?

老獅:可以,不過你應該會遇到一些問題,不過經過這麼多錯誤訊息的訓練,我相信你可以解決的,你就自己處理看看吧!

本日作業

  • 刪除原本的作業目錄
  • 重建專案
  • 建立超級使用者
  • 使用 /docs UI 介面,新增一個使用者
  • 利用該使用者帳密換取 token
  • 使用該 token 換取使用者名稱 (username)

上一篇
超級使用者 - 初始化 Script - 實作
下一篇
回顧
系列文
FastAPI 開發30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言