Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a realpath for the temporary build directory.
Some systems have /tmp symlinked which confuses custom builds, such as numpy. This ensures that real path is passed and that such builds resolve their paths correctly during build and install. Added test for the change and also for the previous related fix: #707
- Loading branch information
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
|
||
from pip.req.req_install import InstallRequirement | ||
|
||
|
||
class TestInstallRequirementBuildDirectory(object): | ||
# no need to test symlinks on Windows | ||
@pytest.mark.skipif("sys.platform == 'win32'") | ||
def test_tmp_build_directory(self): | ||
# when req is None, we can produce a temporary directory | ||
# Make sure we're handling it correctly with real path. | ||
requirement = InstallRequirement(None, None) | ||
tmp_dir = tempfile.mkdtemp('-build', 'pip-') | ||
tmp_build_dir = requirement.build_location(tmp_dir) | ||
assert ( | ||
os.path.dirname(tmp_build_dir) == | ||
os.path.realpath(os.path.dirname(tmp_dir)) | ||
) | ||
# are we on a system where /tmp is a symlink | ||
if os.path.realpath(tmp_dir) != os.path.abspath(tmp_dir): | ||
assert os.path.dirname(tmp_build_dir) != os.path.dirname(tmp_dir) | ||
else: | ||
assert os.path.dirname(tmp_build_dir) == os.path.dirname(tmp_dir) | ||
os.rmdir(tmp_dir) | ||
assert not os.path.exists(tmp_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters