Vivek Katial
Vivek Katial

Reputation: 646

python - [tool.poetry] section not found in pyproject.toml when building Singularity Container

I am trying to build a Singularity Container to run on HPC environment. I am using poetry to manage python packages.

The contents of my pyproject.toml file are as follows:

[tool.poetry]
name = "haqc"
version = "0.1.0"
description = ""
authors = ["Vivek Katial <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"
...
haqc = {path = ".", develop = true}

[tool.poetry.dev-dependencies]

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

Then in my Singularity definition file I have the following to get setup with poetry:

%post
  pip install --upgrade pip
  git clone https://<REPO>.git
  cd HAQC
  pip install "poetry==$POETRY_VERSION"
  poetry config virtualenvs.create false \
  && poetry install --no-interaction --no-ansi

Every time I try and build the container I receive the following error, despite the pyproject.toml file being present in the directory at build (I echo'd an ls -lhar to check):

  PyProjectException

  [tool.poetry] section not found in /HAQC/pyproject.toml

  at /usr/local/lib/python3.9/site-packages/poetry/core/pyproject/toml.py:56 in poetry_config
      52│     def poetry_config(self):  # type: () -> Optional[TOMLDocument]
      53│         if self._poetry_config is None:
      54│             self._poetry_config = self.data.get("tool", {}).get("poetry")
      55│             if self._poetry_config is None:
    → 56│                 raise PyProjectException(
      57│                     "[tool.poetry] section not found in {}".format(self._file)
      58│                 )
      59│         return self._poetry_config
      60│

Upvotes: 7

Views: 13898

Answers (2)

Manas Sambare
Manas Sambare

Reputation: 1348

I faced a similar issue, in my case I had the following line in my Dockerfile:

COPY pyproject.toml poetry.lock

It should be:

COPY pyproject.toml poetry.lock ./

Upvotes: 0

Thytu
Thytu

Reputation: 103

It happened to me when I provided a .toml without any package to install in it (due to a wrong COPY in my Dockerfile).

Make sure your pyproject.toml contains a [tool.poetry.dependencies] section.

Upvotes: 1

Related Questions