I have my pyproject.toml
file in the root of my project. It looks something like this (names changed for simplicity/discretion, but works the same):
[tool.poetry]
name = "controller_poc"
version = "0.1.0"
description = "Controller (API) POC"
license = "MIT"
authors = ["Felipe Freitas"]
readme = "README.md"
repository = "https://github.com/felipefreitassilva/..."
keywords = ["Controller", "POC"]
[tool.poetry.dependencies]
python = "^3.9"
fastapi = "0.103.1"
pylint = "2.17.6"
pydantic = "2.3.0"
uvicorn = "0.23.2"
python-multipart = "0.0.6"
httpx = "0.25.0"
sqlalchemy = {version = "2.0.20", extras = ["sqlite"]}
sqlalchemy_utils = "0.41.1"
pymysql = "1.0.2"
autopep8 = "2.0.4"
pytest = "7.4.2"
pytest-cov = "4.1.0"
[tool.poetry.scripts]
start = "app.main:start"
test = "pytest"
lint = "autopep8 --in-place --recursive ."
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
If I run poetry install from the root, all goes correctly:
C:\Users\Felipe\Controller_POC> poetry install
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file
No dependencies to install or update
However, if I attempt to run the start command, like so:
C:\Users\Felipe\Controller_POC> poetry run start
Skipping virtualenv creation, as specified in config file.
No file/folder found for package controller-poc
It throws this error - which has nothing to do with the script itself, the script works normally (and looks like this) if it matters:
def start():
"""
Run the application with uvicorn
"""
from uvicorn import run
run('app.main:app',
reload=True,
workers=1,
host=settings.API_HOST,
port=settings.API_PORT)
if __name__ == "__main__":
start()
However, and this is where the problem occurs:
If I add the package, using pyproject's tool > packages option, like so:
pyproject.toml
...
keywords = ["Controller", "POC"]
packages=[{ include="app" }]
[tool.poetry.dependencies]
python = "^3.9"
...
and attempt to run poetry install
again, it throws a new error
C:\Users\Felipe\Controller_POC> poetry install
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file
No dependencies to install or update
Installing the current project: controller_poc (0.1.0)
not enough values to unpack (expected 2, got 1)
That being said, altough it "creates" this previously non existing error, it also fixes the start
script:
C:\Users\Felipe\Controller_POC> poetry run start
Skipping virtualenv creation, as specified in config file.
INFO: Will watch for changes in these directories: ['C:\\Users\\Felipe\\Controller_POC']
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: Started reloader process [3336] using StatReload
INFO: Started server process [7372]
INFO: Waiting for application startup.
INFO: Application startup complete.
I have no idea why this "seesaw" effect happens, and I have tried and tried through many forums, documentations and other sources, but I can't seem to find what is happening
I'm somewhat new to python, perhaps it doesn't work as I expect and I should change completely to another tool. I read about poethepoet, but don't know weather it is secure and if it would do what I intended.
If someone could give me any directions, I would deeply appreciate it