I use virtualenv to create isolated environments for my Python projects. Then i install dependencies with pip - Python package manager. Sometimes i forget to do source venv/bin/activate
, and then pip creates build/
directories inside my projects. Why does pip create them? May i delete them, and if not, may i put them in my .hgignore
file?
As far as i understand, pip stores source of downloaded packages there along a file called pip-delete-this-directory.txt
. But when i delete it, everything still works, as the real code is being put into venv/lib/python2.7/site-packages/
. Then what is build/
really for?
The build
directory is where a packages gets unpacked into and build from. When the package is installed successfully, pip removes the unpacked dir from build
, unless you've removed pip-delete-this-directory.txt
. As described in pip-delete-this-directory.txt
:
This file is placed here by pip to indicate the source was put
here by pip.
Once this package is successfully installed this source code will be
deleted (unless you remove this file).
Thus its less important for runtime environment. You could ignore it safely.
Also, you could use pip install -b customized_build_directory
to specify another directory as build
base directory, for example /tmp
Update: -b
was removed from Pip 20.3. The deprecation notice said:
use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean
Furthermore, you could pip install --no-download package_name
to rebuild the package w/o downloading it, if the previous installation of the package failed.