pypa / pypa/setuptools

[BUG] SETUPTOOLS_USE_DISTUTILS=local makes any `distutils` import very slow

Open
#3,585 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Needs Implementation Needs Investigation Needs Triage
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

setuptools==65.3.0

Python version

python 3.8.10

OS

ubuntu 20.04

Additional environment information

No response

Description

when using the bundled distutils, importing any part of distutils takes almost 10x longer than previously


I originally started with trying to figure out why virtualenv got way slower recently and ended up tracing it to setuptools>=60

Expected behavior

I expect the bundled distutils to not incur the import time problems of setuptools

How to Reproduce

compare the following:

  • time env SETUPTOOLS_USE_DISTUTILS=local venv3/bin/python3 -c 'import distutils.version'
  • time env SETUPTOOLS_USE_DISTUTILS=stdlib venv3/bin/python3 -c 'import distutils.version'
Output
$ best-of -n 10 -- env SETUPTOOLS_USE_DISTUTILS=local venv3/bin/python3 -c 'import distutils.version'
..........
best of 10: 0.254s
$ best-of -n 10 -- env SETUPTOOLS_USE_DISTUTILS=stdlib venv3/bin/python3 -c 'import distutils.version'
..........
best of 10: 0.021s

best-of here is just a script which runs the command in a loop and reports the fastest time -- time also works to reproduce this

Contributor guide

No contributing guide indexed for this repository

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

Start by reproducing the two commands in the issue with SETUPTOOLS_USE_DISTUTILS set to local and stdlib, and confirm the import-time difference on the stated Python and Ubuntu versions. Trace the bundled distutils import path to identify where the extra work occurs. Done means the local bundled implementation no longer has the reported import-time regression, with the comparison commands or a regression test demonstrating the result.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.