python-poetry / python-poetry/poetry

`poetry build` gets slower the more files are in the project directory

Open
#7,644 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/build-system kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Poetry
Version: 1.4.0
Python:  3.10.4

Virtualenv
Python:         3.10.4
Implementation: CPython
Path:           /home/codespace/.cache/pypoetry/virtualenvs/example-p6HmNsBj-py3.10
Executable:     /home/codespace/.cache/pypoetry/virtualenvs/example-p6HmNsBj-py3.10/bin/python
Valid:          True

System
Platform:   linux
OS:         posix
Python:     3.10.4
Path:       /usr/local/python/3.10.4
Executable: /usr/local/python/3.10.4/bin/python3.10
  • pyproject.toml: poetry new defaults
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

With an increasing amount of files inside a project folder (let's say 50 000+) poetry build takes increasingly more time, e.g.:

Building example (0.1.0)
  - Building sdist
<Waiting for a few minutes>
  - Built example -0.1.0.tar.gz
  - Building wheel
  - Built example -0.1.0-py3-none-any.whl

I also found an issue from somebody on Stackoverflow, they reference a real world scenario of using node_modules somewhere in the project dir.

I know it is a real edge-case but it would still be nice if exluded files would not be considered at all.

Here is a short reproduction:

pip install poetry
poetry new example
cd example
mkdir folder
cd folder
for i in {1..70000}; do
  mkdir s"$i"
  touch s"$i"/file1.file
  touch s"$i"/file2.file
  touch s"$i"/file3.file
done

image

It just shows a small delay on my screenshot, but I have a real project where the delay is much more pronounced.

Using exclude = ["folder"] takes no effect on the speed of the build.

Just for my reference: https://github.com/DanielHabenicht/bug.poetry

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the slowdown with the provided 70,000-directory script, then trace the poetry build file-discovery and exclude-handling entry points. Confirm that excluded directories are not traversed during the build and rerun the reproduction to verify that build time no longer scales with those files.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.