Skip to content

Exception on poetry build, incorrect gitignore handling logic. #1946

@kawing-chiu

Description

@kawing-chiu
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Arch Linux

  • Poetry version: 1.0.2

  • Link of a Gist with the contents of your pyproject.toml file: pyproject.toml

Issue

I got an exception when running poetry build -vvv, on the wheel building step:
image

The issue here is that, poetry seems to be trying to use the /.git directory under my root directory to get ignored files, which does not make sense. I dig into the source and find that the get_vcs() logic here

def get_vcs(directory):  # type: (Path) -> Git
    directory = directory.resolve()
    for p in [directory] + list(directory.parents):
        ...

is incorrect. Here is the content of [directory] + list(directory.parents), the list of directories that get_vcs() searches for .git:

[PosixPath('/tmp/tmp51qstjuk/mypackage-0.3.0.dev3'), PosixPath('/tmp/tmp51qstjuk'), PosixPath('/tmp'), PosixPath('/')]

When running poetry build -vvv, the CompleteBuilder will unpack the sdist file to a tmpdir:

with self.unpacked_tarball(sdist_file) as tmpdir:
    WheelBuilder.make_in(
        Factory().create_poetry(tmpdir),
        ...

Here the value of tmpdir is '/tmp/tmp51qstjuk/mypackage-0.3.0.dev3', there is no .git directory there, so the get_vcs() function is searching for the .git directory in the wrong place. In my specific case, I happen to have a .git directory in my /, so it results in the above exception. Usually, the incorrect search in get_vcs() will return an empty set, so the files ignored by git will not be honored. I suspect this might cause some other issues, like #1660.

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions