Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip creates build/ directories

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?

like image 208
Mirzhan Irkegulov Avatar asked May 16 '12 11:05

Mirzhan Irkegulov


People also ask

How do you create a build directory in Python?

Python's OS module provides an another function to create a directories i.e. os. makedirs(name) will create the directory on given path, also if any intermediate-level directory don't exists then it will create that too. Its just like mkdir -p command in linux.

Does pip automatically install dependencies?

Pip relies on package authors to stipulate the dependencies for their code in order to successfully download and install the package plus all required dependencies from the Python Package Index (PyPI). But if packages are installed one at a time, it may lead to dependency conflicts.

Does pip install global packages?

The Pip Package Manager can be used to list both globally and locally installed Python packages.


1 Answers

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

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.

like image 173
okm Avatar answered Oct 01 '22 20:10

okm