jceel / py-libzfs

Python libzfs bindings
16 stars 8 forks source link

disks() fails on ZFSPool #10

Closed rmehta closed 8 years ago

rmehta commented 8 years ago
>>> p
<libzfs.ZFSPool name 'p1' guid '16071419714433258085'>
>>> p.disks()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "libzfs.pyx", line 832, in libzfs.ZFSPool.disks.__get__ (libzfs.c:20780)
  File "libzfs.pyx", line 595, in libzfs.ZFSVdev.disks.__get__ (libzfs.c:16291)
  File "libzfs.pyx", line 582, in __get__ (libzfs.c:15951)
TypeError: Argument 'pool' has incorrect type (expected libzfs.ZFSPool, got dict)
jceel commented 8 years ago

What version are you on? I can't reproduce that on any Python version around, also line 582 corresponds to something else in HEAD.

rmehta commented 8 years ago

@jceel

pkg info py27-libzfs
py27-libzfs-1.0_3
Name           : py27-libzfs
Version        : 1.0_3
Installed on   : Wed Nov 11 02:54:15 IST 2015
Origin         : devel/py-libzfs
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : python devel
Licenses       : BSD2CLAUSE
Maintainer     : wg@FreeBSD.org
WWW            : https://github.com/freenas/py-libzfs
Comment        : Python libzfs bindings
Shared Libs required:
    libpython2.7.so.1
Annotations    :
    repo_type      : binary
    repository     : FreeBSD
Flat size      : 980KiB
Description    :
Python libzfs bindings using cython.

WWW: https://github.com/freenas/py-libzfs

FreeBSD Version

$ uname -a
FreeBSD freebsd-test 10.2-RELEASE FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12 15:26:37 UTC 2015     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

Installing setup.py gives me this:

[frappe@freebsd-test ~/frappe-bench]$ ./env/bin/pip install git+https://github.com/freenas/py-libzfs.git
Collecting git+https://github.com/freenas/py-libzfs.git
  Cloning https://github.com/freenas/py-libzfs.git to /tmp/pip-fmESGB-build
Installing collected packages: libzfs
  Running setup.py install for libzfs
    Complete output from command /usr/home/frappe/frappe-bench/env/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-fmESGB-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-xGwqfG-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/home/frappe/frappe-bench/env/include/site/python2.7/libzfs:
    running install
    running build
    running build_ext
    cythoning libzfs.pyx to libzfs.c
    building 'libzfs' extension
    creating build
    creating build/temp.freebsd-10.2-RELEASE-amd64-2.7
    cc -fno-strict-aliasing -O2 -pipe -fstack-protector -fno-strict-aliasing -DNDEBUG -fPIC -I/usr/src/cddl/lib/libumem -I/usr/src/sys/cddl/compat/opensolaris/ -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/cddl/compat/opensolaris/include -I/usr/src/cddl/compat/opensolaris/lib/libumem -I/usr/src/cddl/contrib/opensolaris/lib/libzpool/common -I/usr/src/sys/cddl/contrib/opensolaris/common/zfs -I/usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs -I/usr/src/sys/cddl/contrib/opensolaris/uts/common/sys -I/usr/src/cddl/contrib/opensolaris/head -I/usr/src/sys/cddl/contrib/opensolaris/uts/common -I/usr/src/cddl/contrib/opensolaris/lib/libnvpair -I/usr/src/cddl/contrib/opensolaris/lib/libuutil/common -I/usr/src/cddl/contrib/opensolaris/lib/libzfs/common -I/usr/src/cddl/contrib/opensolaris/lib/libzfs_core/common -I/usr/local/include/python2.7 -c libzfs.c -o build/temp.freebsd-10.2-RELEASE-amd64-2.7/libzfs.o -DNEED_SOLARIS_BOOLEAN -D_XPG6 -g -O0
    libzfs.c:239:10: fatal error: 'nvpair.h' file not found
    #include "nvpair.h"
             ^
    1 error generated.
    error: command 'cc' failed with exit status 1

    ----------------------------------------
Command "/usr/home/frappe/frappe-bench/env/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-fmESGB-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-xGwqfG-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/home/frappe/frappe-bench/env/include/site/python2.7/libzfs" failed with error code 1 in /tmp/pip-fmESGB-build
jceel commented 8 years ago

You're supposed to either have FreeBSD sources in /usr/src or pass path to them as FREEBSD_SRC environment variable. Try setting FREEBSD_SRC and trying again :)

py-libzfs port was updated yesterday (PORTREVISION=4), fresh pkgng packages whould be available next week.

rmehta commented 8 years ago

@jceel First time with FreeBSD. Should have checked the "Sources" box when setting up my VM :) Will try and download them. Thanks for the help.

btw, would be cool if you can add some docstrings. The API seems pretty Pythonic though, so not much trouble :wink: