Error: No dependencies found in pyproject.toml

I’m trying to deploy a simple websocket server using the fly CLI. It’s a python poetry project which seems to be nothing out of the ordinary. When running the fly launch command from the project’s root directory I get the following output:

Scanning source code
INFO Detected Poetry project
WARN No supported Python frameworks found
INFO Detected pyproject.toml
Error: No dependencies found in pyproject.toml

I’m not sure what I’m doing wrong and was not able to find anything when trying to google. Anyone got a clue?

This is what the pyproject.toml looks like:

[tool.poetry]
name = "redacted"
version = "0.1.0"
description = ""
authors = ["redacted <redacted>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
black = "^24.4.2"
pytest = "^8.2.2"
websockets = "^12.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 100

Hi,

Python project auto-detection is fairly new and given the myriad ways in which a Python application can implement web services, it’s not really feasible to detect all of them to generate a reasonable fly.toml and Dockerfile. As seen here, auto-detection will only work for Flask, FastAPI, Streamlit and Django. So you could do one of two things:

  1. Use a framework to implement your application so it’s auto-detected. Forcing you to use a specific framework to allow fly launch to auto-detect seems a bit ham-fisted though - so the best option would probably be:
  2. Provide your own Dockerfile that creates a Docker image for your app. As long as the image builds and starts properly via e.g. docker run -p x:y, running fly launch will give you a fly.toml that should work, you only need to ensure that the internal_port in fly.toml matches the port your app is serving on. If you did docker run -p x:y, the y port is the one you should configure here.

You can use the starter Dockerfile that fly launch creates for an application with Flask:

FROM python:3.10-bookworm AS builder

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1
WORKDIR /app

RUN pip install poetry
RUN poetry config virtualenvs.in-project true
COPY pyproject.toml poetry.lock ./
RUN poetry install
FROM python:3.10-slim-bookworm
WORKDIR /app
COPY --from=builder /app/.venv .venv/
COPY . .
CMD ["/app/.venv/bin/flask", "run", "--host=0.0.0.0", "--port=8080"]

Replace the last line (CMD) with the actual command to run your app or service.

Cheers,

  • Daniel
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.