Subject: bug#16569: Python package doesn't install ctypes module

From: Sree Harsha Totakura <[email-masked]>
Date: Mon, 27 Jan 2014 12:36:57 +0100

Hi,

Python (both versions 2.7.6 and 3.3) installed through Guix do not
contain/install ctypes module.
> $ guix package --list-installed ;;; note: source file
> /usr/local/share/guile/site/2.0/srfi/srfi-37.scm ;;;       newer
> than compiled /usr/local/share/guile/site/2.0/srfi/srfi-37.go hello
> 2.9	out	/nix/store/jgvkvznlsvwax0hc29f5br508ivphks1-hello-2.9 
> gnutls	3.2.4	out
> /nix/store/r64154hy14lzdxgp8gy8kk99kh4mw7hf-gnutls-3.2.4 libgcrypt
> 1.6.0	out
> /nix/store/5ad1sv3fr8bjh1db9jwf0z130gbb584a-libgcrypt-1.6.0 ncdc
> 1.18.1	out	/nix/store/95i40hzr1scgszdsqa9xc38mighczx5g-ncdc-1.18.1 
> $ guix package -i python ;;; note: source file
> /usr/local/share/guile/site/2.0/srfi/srfi-37.scm ;;;       newer
> than compiled /usr/local/share/guile/site/2.0/srfi/srfi-37.go The
> following package will be installed: python-3.3.3	out
> /nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3
> 
> substitute-binary: ;;; note: source file
> /usr/local/share/guile/site/2.0/srfi/srfi-37.scm substitute-binary:
> ;;;       newer than compiled
> /usr/local/share/guile/site/2.0/srfi/srfi-37.go 5 packages in
> profile The following environment variable definitions may be
> needed: export
> PYTHONPATH="/home/totakura/.guix-profile/lib/python3.3/site-packages"
>
> 
$ export
PYTHONPATH="/home/totakura/.guix-profile/lib/python3.3/site-packages"
> $ which python3.3 /home/totakura/.guix-profile/bin/python3.3 $
> python3.3 Python 3.3.3 (default, Dec 30 2013, 01:48:16) [GCC 4.8.2]
> on linux Type "help", "copyright", "credits" or "license" for more
> information.
>>>> import ctypes
> Traceback (most recent call last): File "<stdin>", line 1, in
> <module> File
> "/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.py",
> line 7, in <module> from _ctypes import Union, Structure, Array 
> ImportError: No module named '_ctypes'
>>>> 
> $ cd /nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3 $
> pwd /nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3 $ find
> ./ -name "*ctypes*" 
> ./lib/python3.3/test/__pycache__/test_ctypes.cpython-33.pyo 
> ./lib/python3.3/test/__pycache__/test_ctypes.cpython-33.pyc 
> ./lib/python3.3/test/test_ctypes.py ./lib/python3.3/ctypes 
> ./lib/python3.3/ctypes/macholib/README.ctypes 
> ./lib/python3.3/lib-dynload/_ctypes_test.cpython-33m.so 
> ./lib/python3.3/multiprocessing/__pycache__/sharedctypes.cpython-33.pyc
>
> 
./lib/python3.3/multiprocessing/__pycache__/sharedctypes.cpython-33.pyo
> ./lib/python3.3/multiprocessing/sharedctypes.py $

On my debian system, python was able to find ctypes module after
searching through these paths:
> stat("/usr/lib/python2.7/ctypes", {st_mode=S_IFDIR|0755,
> st_size=4096, ...}) = 0 stat("/usr/lib/python2.7/ctypes",
> {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 
> stat("/usr/lib/python2.7/ctypes/os", 0x7fff3be9e430) = -1 ENOENT
> (No such file or directory) open("/usr/lib/python2.7/ctypes/os.so",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/osmodule.so", O_RDONLY) = -1 ENOENT
> (No such file or directory) open("/usr/lib/python2.7/ctypes/os.py",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/os.pyc", O_RDONLY) = -1 ENOENT (No
> such file or directory) stat("/usr/lib/python2.7/ctypes/sys",
> 0x7fff3be9e430) = -1 ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/sys.so", O_RDONLY) = -1 ENOENT (No
> such file or directory) 
> open("/usr/lib/python2.7/ctypes/sysmodule.so", O_RDONLY) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/sys.py", O_RDONLY) = -1 ENOENT (No
> such file or directory) open("/usr/lib/python2.7/ctypes/sys.pyc",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> stat("/usr/lib/python2.7/ctypes/_ctypes", 0x7fff3be9e430) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/_ctypes.so", O_RDONLY) = -1 ENOENT
> (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/_ctypesmodule.so", O_RDONLY) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/_ctypes.py", O_RDONLY) = -1 ENOENT
> (No such file or directory) 
> open("/usr/lib/python2.7/ctypes/_ctypes.pyc", O_RDONLY) = -1 ENOENT
> (No such file or directory) stat("_ctypes", 0x7fff3be9e430)
> = -1 ENOENT (No such file or directory) open("_ctypes.so",
> O_RDONLY)            = -1 ENOENT (No such file or directory) 
> open("_ctypesmodule.so", O_RDONLY)      = -1 ENOENT (No such file
> or directory) open("_ctypes.py", O_RDONLY)            = -1 ENOENT
> (No such file or directory) open("_ctypes.pyc", O_RDONLY)
> = -1 ENOENT (No such file or directory) 
> stat("/usr/lib/python2.7/_ctypes", 0x7fff3be9e430) = -1 ENOENT (No
> such file or directory) open("/usr/lib/python2.7/_ctypes.so",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/_ctypesmodule.so", O_RDONLY) = -1 ENOENT
> (No such file or directory) open("/usr/lib/python2.7/_ctypes.py",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/_ctypes.pyc", O_RDONLY) = -1 ENOENT (No
> such file or directory) 
> stat("/usr/lib/python2.7/plat-linux2/_ctypes", 0x7fff3be9e430) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/plat-linux2/_ctypes.so", O_RDONLY) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/plat-linux2/_ctypesmodule.so", O_RDONLY) =
> -1 ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/plat-linux2/_ctypes.py", O_RDONLY) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/plat-linux2/_ctypes.pyc", O_RDONLY) = -1
> ENOENT (No such file or directory) 
> stat("/usr/lib/python2.7/lib-tk/_ctypes", 0x7fff3be9e430) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/lib-tk/_ctypes.so", O_RDONLY) = -1 ENOENT
> (No such file or directory) 
> open("/usr/lib/python2.7/lib-tk/_ctypesmodule.so", O_RDONLY) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/lib-tk/_ctypes.py", O_RDONLY) = -1 ENOENT
> (No such file or directory) 
> open("/usr/lib/python2.7/lib-tk/_ctypes.pyc", O_RDONLY) = -1 ENOENT
> (No such file or directory) 
> stat("/usr/lib/python2.7/lib-dynload/_ctypes", 0x7fff3be9e430) = -1
> ENOENT (No such file or directory) 
> open("/usr/lib/python2.7/lib-dynload/_ctypes.so", O_RDONLY) = 4

With the Guix installed python I observe this through strace:
> rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0 ioctl(0,
> SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) =
> 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 
> rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fb581e85870},
> {0x7fb57a520760, [], SA_RESTORER|SA_RESTART, 0x7fb581e85870}, 8) =
> 0 stat(".", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3",
> {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes",
> {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.cpython-33m.so",
> 0x7fff05ac1650) = -1 ENOENT (No such file or directory) 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.abi3.so",
> 0x7fff05ac1650) = -1 ENOENT (No such file or directory) 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.so",
> 0x7fff05ac1650) = -1 ENOENT (No such file or directory) 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.py",
> {st_mode=S_IFREG|0444, st_size=17043, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.py",
> {st_mode=S_IFREG|0444, st_size=17043, ...}) = 0 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__pycache__/__init__.cpython-33.pyc",
> O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0444, st_size=29315, ...})
> = 0 lseek(3, 0, SEEK_CUR)                   = 0 fstat(3,
> {st_mode=S_IFREG|0444, st_size=29315, ...}) = 0 read(3,
> "\236\f\r\nh\321\300R\223B\0\0c\0\0\0\0\0\0\0\0\0\0\0\0\r\0\0\0@\0\0"...,
> 29316) = 29315 read(3, "", 1)                          = 0 close(3)
> = 0 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.py",
> O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0444, st_size=17043, ...})
> = 0 lseek(3, 0, SEEK_CUR)                   = 0 fstat(3,
> {st_mode=S_IFREG|0444, st_size=17043, ...}) = 0 read(3,
> "\"\"\"create and manipulate C data "..., 17044) = 17043 read(3,
> "", 1)                          = 0 close(3)
> = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.py",
> {st_mode=S_IFREG|0444, st_size=17043, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__pycache__",
> {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__pycache__/__init__.cpython-33.pyc.140417554480296",
> O_WRONLY|O_CREAT|O_EXCL, 0644) = -1 EACCES (Permission denied) 
> stat(".", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3",
> {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/plat-linux",
> {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/lib-dynload",
> {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 
> stat("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/site-packages",
> {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 write(2, "Traceback
> (most recent call last"..., 35Traceback (most recent call last): )
> = 35 write(2, "  File \"<stdin>\", line 1, in <mo"..., 38  File
> "<stdin>", line 1, in <module> ) = 38 open("<stdin>", O_RDONLY)
> = -1 ENOENT (No such file or directory) open("<stdin>", O_RDONLY)
> = -1 ENOENT (No such file or directory) 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python33.zip/<stdin>",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/<stdin>",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/plat-linux/<stdin>",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/lib-dynload/<stdin>",
> O_RDONLY) = -1 ENOENT (No such file or directory) 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/site-packages/<stdin>",
> O_RDONLY) = -1 ENOENT (No such file or directory) write(2, "  File
> \"/nix/store/b50aj7l8qhaxy"..., 120  File
> "/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.py",
> line 7, in <module> ) = 120 
> open("/nix/store/b50aj7l8qhaxys65z57wcqhkyi22ni2i-python-3.3.3/lib/python3.3/ctypes/__init__.py",
> O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0444, st_size=17043, ...})
> = 0 ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff05ac1220) = -1
> ENOTTY (Inappropriate ioctl for device) fstat(3,
> {st_mode=S_IFREG|0444, st_size=17043, ...}) = 0 lseek(3, 0,
> SEEK_CUR)                   = 0 dup(3)
> = 4 fcntl(4, F_GETFL)                       = 0x8000 (flags
> O_RDONLY|O_LARGEFILE) fstat(4, {st_mode=S_IFREG|0444,
> st_size=17043, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE,
> MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb58257d000 lseek(4, 0,
> SEEK_CUR)                   = 0 read(4, "\"\"\"create and
> manipulate C data "..., 4096) = 4096 close(4)
> = 0 munmap(0x7fb58257d000, 4096)            = 0 lseek(3, 0,
> SEEK_SET)                   = 0 lseek(3, 0, SEEK_CUR)
> = 0 read(3, "\"\"\"create and manipulate C data "..., 8192) = 8192 
> close(3)                                = 0 write(2, "    from
> _ctypes import Union, S"..., 48    from _ctypes import Union,
> Structure, Array ) = 48 write(2, "ImportError: No module named
> '_c"..., 39ImportError: No module named '_ctypes' ) = 39

Sree