question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip 21.3+ in-tree builds with setuptools, do not clean local build directories

See original GitHub issue

Description

Given a requirements.txt including a local package path, installing them will litter the local path with in-tree build folders.

This is slightly bloating docker builds and causing some issues due to build artifacts permissions that force us to clean every local build folder with

WORKDIR /path/to/package-1
RUN python setup.py clean --all
WORKDIR /path/to/package-2
RUN python setup.py clean --all
# etc

but note this won’t slim image sizes either.

Expected behavior

Previous pip versions built local packages in folders like /tmp/pip-req-build-XXXXXXX/ . Regardless of being in-tree or out-of-tree, the point is those folders vanished at the end of a pip install instruction unless the --no-clean flag was used.

pip version

21.3

Python version

3.9.7

OS

GNU/Linux + Docker 20.10.8

How to Reproduce

  1. git clone https://github.com/pypa/sampleproject.git /tmp/sampleproject
  2. pip install --use-feature=in-tree-build /tmp/sampleproject
  3. find /tmp/sampleproject/build

Output

/tmp/sampleproject/build
/tmp/sampleproject/build/bdist.linux-x86_64
/tmp/sampleproject/build/lib
/tmp/sampleproject/build/lib/sample
/tmp/sampleproject/build/lib/sample/__init__.py
/tmp/sampleproject/build/lib/sample/simple.py
/tmp/sampleproject/build/lib/sample/package_data.dat

Code of Conduct

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
sigma67commented, Sep 23, 2022

This issue caused a lot of confusion for me, as repeated in-tree installs with pip and pyproject.toml would install the prior version in the build directory instead of the local files with my changes. I wasn’t aware that such a directory was being left behind.

It would be highly appreciated if setuptools did not leave behind a build directory.

3reactions
pfmoorecommented, Oct 14, 2021

We’ve been round this loop a few times now. Incremental builds are another topic that comes up in this context. When PEP 517 was being designed, there was a lot of discussion over how to control what the backend did, and ultimately the strong consensus was to not try to force backends to behave in a particular way, but to “trust the backend” to do the build. Being able to do in-place builds in pip was also a motivating factor in these discussions, as we only really did out-of-place builds to protect against backend issues (stale build artefacts affecting the build, for example).

In practice, backends (in particular, setuptools) haven’t changed much since those original discussions, and so the various issues that were discussed remain. I suspect pip’s out-of-place build mechanism removed a lot of the incentives for backends to consider the problem. So we’re now in a situation where the implications of the “trust the backend” principle are becoming more apparent, but there will be a transition period before mechanisms appear in backends and/or user workflows to address use cases like this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does this deprecation warning mean, and how to fix it?
DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend ...
Read more >
pip install - pip documentation v22.3.1
When looking at the items to be installed, pip checks what type of item each is, in the following order: Project or archive...
Read more >
setuptools-scm - PyPI
git,type=bind \ pip install --no-cache-dir -e . However, this build step introduces a dependency to the state of your local .git folder the...
Read more >
pip install - pip documentation v21.1.dev0
Local directory (which must contain a setup.py , or pip will report an error). ... For whatever reason, they don't or won't declare...
Read more >
Windows Nightly build error: pip install of SimpleITK build failing
The error can NOT be reproduced by locally runnin… ... before it becomes the default. pip 21.3 will remove support for this functionality....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found