osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python 3.6 fails to install to non-standard directory under Linux


I posted this to Stackoverflow and the original post can be seen here. I'll try and copy and past the contents below. Thank you for your help!

https://stackoverflow.com/questions/49074327/python-3-6-fails-to-install-to-non-standard-directory-under-linux

I have a completely insulated boostrapped toolchain+binaries setup (located under /home/tools) that has been able to build everything that I throw at it. That includes Python 2.7.14, which built without issue with a simple --prefix. The lone exception is Python 3.6.4. I had to edit the configure and setup.py script to patch some of the hardcoded paths that were set to standard /usr directories (the link to ncursesw was notable). It completely compiled and built correctly, except failed during the 'make install' installation of pip. The installation scripts create a pip-build-* directory under /tmp and the source of the failure seems to be centered around that. It appears when the directory is first created, it's made with the proper permission mask. But after failure, I can see it's only user writable (not even readable or executable).
***************

d-w------- 4 myuser       eng      4096 Mar  1 00:56 pip-build-xh7onsny/

***************
Here's the section of the strace where it first creates the pip-build-* directory.
***************

    [pid 19771] lstat("/home/myuser/.cache/pip", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
    [pid 19771] geteuid()                   = 10345
    [pid 19771] access("/home/myuser/.cache/pip", W_OK) = 0
    [pid 19771] mkdir("/tmp/pip-build-xh7onsny", 0700) = 0
    [pid 19771] lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=28672, ...}) = 0
    [pid 19771] lstat("/tmp/pip-build-xh7onsny", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
    [pid 19771] getcwd("/nfs/home/myuser/lfs/sources/Python-3.6.4"..., 1024) = 46

************************
Here's the end of the strace that shows where it Error'ed out.
************************

[pid 19771] munmap(0x2ac5506c0000, 4096) = 0
[pid 19771] stat("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a58460) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 32768) = 32768
[pid 19771] lseek(4, 0, SEEK_CUR)       = 32768
[pid 19771] read(4, "e, extract_dir=None, format=None"..., 8192) = 7459
[pid 19771] read(4, "", 8192)           = 0
[pid 19771] close(4)                    = 0
[pid 19771] ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a59f40) = -1 EINVAL (Invalid argument)
[pid 19771] write(2, "Exception:\nTraceback (most recen"..., 1739Exception:
Traceback (most recent call last):
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 385, in run
    requirement_set.cleanup_files()
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 38, in __exit__
    self.cleanup()
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 42, in cleanup
    rmtree(self.name)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 212, in call
    raise attempt.get()
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/six.py", line 686, in reraise
    raise value
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/tmp/tmpojuc47gy/pip-9.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 476, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 474, in rmtree
    fd = os.open(path, os.O_RDONLY)
PermissionError: [Errno 13] Permission denied: '/tmp/pip-build-xh7onsny'
) = 1739
[pid 19771] lstat("/tmp/tmpojuc47gy", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 19771] open("/tmp/tmpojuc47gy", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=11959, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"runpy.py - locating and runni"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=11959, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"runpy.py - locating and runni"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__main__.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=88, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "import ensurepip\nimport sys\n\nif "..., 8192) = 88
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=6391, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "import os\nimport os.path\nimport "..., 8192) = 6391
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=6391, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "import os\nimport os.path\nimport "..., 8192) = 6391
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=26635, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Temporary files.\n\nThis module"..., 8192) = 8192
[pid 19771] read(4, "       continue    # try again\n "..., 8192) = 8192
[pid 19771] read(4, "\n        \"\"\"\n        Close the t"..., 8192) = 8192
[pid 19771] read(4, "emporaryFileArgs['mode']:\n      "..., 8192) = 2059
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=26635, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Temporary files.\n\nThis module"..., 8192) = 8192
[pid 19771] read(4, "       continue    # try again\n "..., 8192) = 8192
[pid 19771] read(4, "\n        \"\"\"\n        Close the t"..., 8192) = 8192
[pid 19771] read(4, "emporaryFileArgs['mode']:\n      "..., 8192) = 2059
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 8192) = 8192
[pid 19771] read(4, "    that are used to exclude fil"..., 8192) = 8192
[pid 19771] read(4, " = os.open(path, os.O_RDONLY)\n  "..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 8192) = 8192
[pid 19771] read(4, "    that are used to exclude fil"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] open("/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", O_RDONLY|0x80000 /* O_??? */) = 4
[pid 19771] ioctl(4, FIOCLEX)           = 0
[pid 19771] fstat(4, {st_mode=S_IFREG|0644, st_size=40227, ...}) = 0
[pid 19771] ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38a5b0d0) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] fcntl(4, 0x406 /* F_??? */, 0) = -1 EINVAL (Invalid argument)
[pid 19771] lseek(4, 0, SEEK_SET)       = 0
[pid 19771] lseek(4, 0, SEEK_CUR)       = 0
[pid 19771] read(4, "\"\"\"Utility functions for copying"..., 8192) = 8192
[pid 19771] read(4, "    that are used to exclude fil"..., 8192) = 8192
[pid 19771] close(4)                    = 0
[pid 19771] write(2, "Traceback (most recent call last"..., 1425Traceback (most recent call last):
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 807, in __exit__
    self.cleanup()
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 811, in cleanup
    _shutil.rmtree(self.name)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 480, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 402, in _rmtree_safe_fd
    onerror(os.listdir, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 399, in _rmtree_safe_fd
    names = os.listdir(topfd)
OSError: [Errno 22] Invalid argument: '/tmp/tmpojuc47gy'
) = 1425
[pid 19771] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x2ac548950ab0}, {0x2ac5485f8ca0, [], SA_RESTORER, 0x2ac548950ab0}, 8) = 0
[pid 19771] munmap(0x2ac54c1df000, 1257472) = 0
[pid 19771] munmap(0x2ac54f203000, 262144) = 0
[pid 19771] sigaltstack(NULL, {ss_sp=0xc877ce0, ss_flags=0, ss_size=8192}) = 0
[pid 19771] sigaltstack({ss_sp=0, ss_flags=SS_DISABLE, ss_size=0}, NULL) = 0
[pid 19771] close(3)                    = 0
[pid 19771] futex(0x2ac54b6f78ac, FUTEX_WAKE_PRIVATE, 2147483647) = 0
[pid 19771] exit_group(1)               = ?
Process 19770 resumed
Process 19771 detached
[pid 19770] <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 19771
[pid 19770] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 19770] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid 19770] wait4(-1, 0x7fff47da9a04, WNOHANG, NULL) = -1 ECHILD (No child processes)
[pid 19770] rt_sigreturn(0xffffffffffffffff) = 0
[pid 19770] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x3c31a30030}, {0x436f50, [], SA_RESTORER, 0x3c31a30030}, 8) = 0
[pid 19770] exit_group(1)               = ?
Process 16346 resumed
Process 19770 detached
[pid 16346] <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 19770
[pid 16346] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid 16346] rt_sigreturn(0xffffffff)    = 19770
[pid 16346] write(2, "make: *** [Makefile:1099: instal"..., 43make: *** [Makefile:1099: install] Error 1
) = 43

***************
Here's the stdout/stderr output from the 'make install' process. It was from another run, so the directories are slightly different.
***************

Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
Exception:
Traceback (most recent call last):
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 385, in run
    requirement_set.cleanup_files()
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 38, in __exit__
    self.cleanup()
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/utils/build.py", line 42, in cleanup
    rmtree(self.name)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 212, in call
    raise attempt.get()
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/six.py", line 686, in reraise
    raise value
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/tmp/tmpkmstr4wc/pip-9.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 476, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 474, in rmtree
    fd = os.open(path, os.O_RDONLY)
PermissionError: [Errno 13] Permission denied: '/tmp/pip-build-in_asosn'
Traceback (most recent call last):
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 807, in __exit__
    self.cleanup()
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/tempfile.py", line 811, in cleanup
    _shutil.rmtree(self.name)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 480, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 402, in _rmtree_safe_fd
    onerror(os.listdir, path, sys.exc_info())
  File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 399, in _rmtree_safe_fd
    names = os.listdir(topfd)
OSError: [Errno 22] Invalid argument: '/tmp/tmpkmstr4wc'
make: *** [Makefile:1109: altinstall] Error 1
It's worth noting that it actually does install the pip binaries to my $prefix/bin directory, but installing subsequent packages, like meson, fail in a similar fashion, so I'm presuming the Python 3.6 / pip installation didn't fully succeed. Seems to also comes from shutil.py. Here's the strace for meson installation.

write(2, "Traceback (most recent call last"..., 1805Traceback (most recent call last):
  File "/home/tools/lib/python3.6/shutil.py", line 399, in _rmtree_safe_fd
    names = os.listdir(topfd)
OSError: [Errno 22] Invalid argument: '/tmp/easy_install-0o0par1r'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 98, in <module>
    complete DSL.''')
  File "/home/tools/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/tools/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/tools/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/install.py", line 117, in do_egg_install
    cmd.run()
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 410, in run
    self.easy_install(spec, not self.no_deps)
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 669, in easy_instal
l
    rmtree(tmpdir)
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 2227, in rmtree
    return shutil.rmtree(path, ignore_errors, onerror)
  File "/home/tools/lib/python3.6/shutil.py", line 480, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/home/tools/lib/python3.6/shutil.py", line 402, in _rmtree_safe_fd
    onerror(os.listdir, path, sys.exc_info())
  File "/home/tools/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1677, in auto_chmod
    six.reraise(et, (ev[0], ev[1] + (" %s %s" % (func, arg))))
TypeError: 'OSError' object is not subscriptable
) = 1805
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x2b2b4caa4ab0}, {0x2b2b4c74cca0, [], SA_RESTORER, 0x2b2b4caa
4ab0}, 8) = 0

************************
I've tried changing the /tmp directory one under my own home directory, and the same Error occurs and also has the odd write only permissions on the pip-build-* directory. I'd appreciate any help in debugging this issue and getting Python 3.6.4 to properly install. Thank you!

Background: I have setup a separate, bootstrapped toolchain and binaries that are completely insulated from the host libraries on a Linux server at work, following much of the Linux From Scratch book. It's running an old Red Hat / CentOS 5 distribution with kernel 2.6.18, that can't be updated due to support for older CAD software. But I now have a fully working environment that has the latest Glibc supported by the kernel (2.19), GCC (7.3.0), binutils (2.30), etc. I've gotten everything I've thrown at it to build correctly, even X libraries and gtk applications, all directly referencing my set of libraries through an rpath.