Skip to content

Using poetry as a build tool with python_distribution does not work #21276

Open
@georgieprojie

Description

@georgieprojie

I want to generate a whl file from a package i wrote. to do that i use the python_distribution target.
my dependencies contain a resource, which a pyproject.toml file is it's source.

as described in the docs, Running pants package {dir}:{name of the python_distribution target} will cause Pants to inspect the [build-system] table in pyproject.toml, install the requirements specified in that table's requires key, and then execute the entry point specified in the build-backend key to build an sdist and a wheel, just as PEP 517 requires.

my pyproject.toml contains:

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

until here everything is great, only that when i actually run pants package, i get an error: ValueError: /tmp/{some sandbox dir}/chroot/{mytargetname} does not contain any element.

after some research and debugging poetry itself with pants, i found out that the problem is that the pyproject.toml is copied to the tmp directory, and when poetry api starts trying to build the package, it thinks that the root directory (where the packages should actually be) is in the tmp sandbox dir, which are not (maybe you should copy the package files into the sandbox dir?)

I would really appreciate if you could validate me and check this bug, and maybe upload an example of a project that generates a whl package with poetry as it's backend?

im using pants version 2.21.0 on a wsl platform

thanks in advance!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions