Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to define temp directory location #4462

Closed
kracekumar opened this issue May 3, 2017 · 5 comments
Closed

Allow user to define temp directory location #4462

kracekumar opened this issue May 3, 2017 · 5 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@kracekumar
Copy link

  • Pip version: 9.0.1
  • Python version: 3.5
  • Operating system: Trisquel

Description:

I have two partitions in the Linux box. One with 20 GB (partition 1) where OS runs and data are stored in other partition with 250+ GB space (partition 2).

The partition 1 always has less than 1 GB of space after prolonged use of the machine and so far no other program has complained about the lack of space.

When I run pip I specify an option for cache-dir in the partition 2. Unfortunately, pip creates temp directory in /tmp directory. This creates problem while installing large set of packages like tensorflow. Specifying target option isn't helpful. Here is the code which creates temp directory.

    if options.target_dir:
            options.ignore_installed = True
            temp_target_dir = tempfile.mkdtemp()
            options.target_dir = os.path.abspath(options.target_dir)
            if (os.path.exists(options.target_dir) and not
                    os.path.isdir(options.target_dir)):
                raise CommandError(
                    "Target path exists but is not a directory, will not "
                    "continue."
                )
            install_options.append('--home=' + temp_target_dir)

One option is to use dir option while creating the directory.

  • Does it make sense to call tempfile.mkdtemp( dir=options.target_dir)?
  • Does it make sense to get the tmp directory from user?

What I've run:

krace@hotbox /m/u/c/tf> pwd
/media/user/code/tf
pip install tensorflow protobuf==3.0.0 numpy==1.11.1 pandas==0.18.1 bokeh==0.12.3 matplotlib pillow==3.4.2 --cache-dir .
Traceback (most recent call last):
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/commands/install.py", line 336, in run
    wb.build(autobuilding=True)
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 620, in _prepare_file
    session=self.session, hashes=hashes)
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/download.py", line 821, in unpack_url
    hashes=hashes
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/download.py", line 663, in unpack_http_url
    unpack_file(from_path, location, content_type, link)
  File "/media/user/code/tf/venv/lib/python3.5/site-packages/pip/utils/__init__.py", line 600, in unpack_file
    flatten=not filename.endswith('.whl')
  File "/media/user/code/tfvenv/lib/python3.5/site-packages/pip/utils/__init__.py", line 502, in unzip_file
    fp.write(data)
OSError: [Errno 28] No space left on device


@pfmoore
Copy link
Member

pfmoore commented May 3, 2017

AIUI pip should respect the standard TMPDIR environment variable. Does that work for you?

@kracekumar
Copy link
Author

AIUI pip should respect the standard TMPDIR environment variable. Does that work for you?

Yes! I didn't know the existence of TMPDIR.

@pfmoore
Copy link
Member

pfmoore commented May 3, 2017

Excellent. There's nothing specific in the pip docs about this, as it's a standard OS facility, but that doesn't help much if you don't know about it :-)

Glad you got it working.

@pfmoore pfmoore closed this as completed May 3, 2017
@pembo13
Copy link

pembo13 commented Apr 30, 2018

For anyone who Googled there way here, @kracekumar is right. In my case, I was using some Rackspace provided VMs, and /tmp had "noexec" and pip uses /tmp for anything. Luckily, using TMPDIR to a different path worked.

@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

3 participants