truenas / py-libzfs

Python libzfs bindings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't install libzfs on FreeBSD 12.0

Corvan opened this issue · comments

Hey,

in order to work on iocage/iocage#831, I decided to set up a development environment on FreeBSD. But I can't install libzfs

(venv) lars@freebsd:/home/lars/PycharmProjects/iocage git:(master*) $ sudo pip install git+https://github.com/freenas/py-libzfs.git#egg=libzfs

Collecting libzfs from git+https://github.com/freenas/py-libzfs.git#egg=libzfs
  Cloning https://github.com/freenas/py-libzfs.git to /tmp/pip-install-4ml0h6te/libzfs
Installing collected packages: libzfs
  Running setup.py install for libzfs ... error
    Complete output from command /home/lars/PycharmProjects/iocage/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4ml0h6te/libzfs/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-7gsagzn5/install-record.txt --single-version-externally-managed --compile --install-headers /home/lars/PycharmProjects/iocage/venv/include/site/python3.7/libzfs:
    WARNING: '' not a valid package name; please use only .-separated package names in setup.py
    running install
    running build
    running build_py
    creating build
    creating build/lib.freebsd-12.0-RELEASE-p2-amd64-3.7
    copying setup.py -> build/lib.freebsd-12.0-RELEASE-p2-amd64-3.7
    running build_ext
    cythoning libzfs.pyx to libzfs.c
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    # SUCH DAMAGE.
    #
    
    include "config.pxi"
    ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:29:0: 'config.pxi' not found
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    cimport nvpair
    cimport zfs
    from types cimport *
    
    
    IF HAVE_LZC_BOOKMARK:
      ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:36:3: Compile-time name 'HAVE_LZC_BOOKMARK' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    cdef extern from "libzfs.h" nogil:
        cdef enum:
            MAXNAMELEN
            MAXPATHLEN
    
        IF HAVE_ZFS_MAXNAMELEN or HAVE_ZPOOL_MAXNAMELEN:
          ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:53:7: Compile-time name 'HAVE_ZFS_MAXNAMELEN' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    cdef extern from "libzfs.h" nogil:
        cdef enum:
            MAXNAMELEN
            MAXPATHLEN
    
        IF HAVE_ZFS_MAXNAMELEN or HAVE_ZPOOL_MAXNAMELEN:
                                 ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:53:30: Compile-time name 'HAVE_ZPOOL_MAXNAMELEN' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        IF HAVE_ZFS_MAXNAMELEN or HAVE_ZPOOL_MAXNAMELEN:
            cdef enum:
                ZFS_MAXNAMELEN
                ZPOOL_MAXNAMELEN
    
        IF HAVE_EZFS_SCRUB_PAUSED:
          ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:58:7: Compile-time name 'HAVE_EZFS_SCRUB_PAUSED' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        extern int zpool_create(libzfs_handle_t *, const char *, nvpair.nvlist_t *,
            nvpair.nvlist_t *, nvpair.nvlist_t *)
        extern int zpool_destroy(zpool_handle_t *, const char *)
        extern int zpool_add(zpool_handle_t *, nvpair.nvlist_t *)
    
        IF HAVE_ZPOOL_SCAN == 3:
          ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:185:7: Compile-time name 'HAVE_ZPOOL_SCAN' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
            int forceunmount
    
        extern int zfs_rename(zfs_handle_t *, const char *, const char *,
            renameflags_t flags)
    
        IF HAVE_SENDFLAGS_T_COMPRESS:
          ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:426:7: Compile-time name 'HAVE_SENDFLAGS_T_COMPRESS' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        ctypedef int (*snapfilter_cb_t)(zfs_handle_t *, void *)
    
        extern int zfs_send(zfs_handle_t *, const char *, const char *,
            sendflags_t *, int, snapfilter_cb_t, void *, nvpair.nvlist_t **) nogil
    
        IF HAVE_ZFS_SEND_ONE == 4:
          ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:459:7: Compile-time name 'HAVE_ZFS_SEND_ONE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        IF HAVE_ZFS_SEND_ONE == 4:
            extern int zfs_send_one(zfs_handle_t *, const char *, int, int) nogil
        ELSE:
            extern int zfs_send_one(zfs_handle_t *, const char *, int) nogil
    
        IF HAVE_ZFS_SEND_RESUME or HAVE_ZFS_SEND_RESUME_TOKEN_TO_NVLIST:
          ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:464:7: Compile-time name 'HAVE_ZFS_SEND_RESUME' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        IF HAVE_ZFS_SEND_ONE == 4:
            extern int zfs_send_one(zfs_handle_t *, const char *, int, int) nogil
        ELSE:
            extern int zfs_send_one(zfs_handle_t *, const char *, int) nogil
    
        IF HAVE_ZFS_SEND_RESUME or HAVE_ZFS_SEND_RESUME_TOKEN_TO_NVLIST:
                                  ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:464:31: Compile-time name 'HAVE_ZFS_SEND_RESUME_TOKEN_TO_NVLIST' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        ctypedef enum diff_flags_t:
            ZFS_DIFF_PARSEABLE = 0x1,
            ZFS_DIFF_TIMESTAMP = 0x2,
            ZFS_DIFF_CLASSIFY = 0x4
    
        IF HAVE_ZFS_RECEIVE == 7:
          ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:495:7: Compile-time name 'HAVE_ZFS_RECEIVE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
            ZFS_DIFF_CLASSIFY = 0x4
    
        IF HAVE_ZFS_RECEIVE == 7:
            extern int zfs_receive(libzfs_handle_t *, const char *, recvflags_t *,
                int, nvpair.nvlist_t *, nvpair.nvlist_t *, void *) # XXX: last argument should be avl_tree_t *
        ELIF HAVE_ZFS_RECEIVE == 6:
            ^
    ------------------------------------------------------------
    
    ./pxd/libzfs.pxd:498:9: Compile-time name 'HAVE_ZFS_RECEIVE' not defined
    
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    from libc.stdlib cimport free, realloc
    
    GLOBAL_CONTEXT_LOCK = threading.Lock()
    
    
    include "config.pxi"
    ^
    ------------------------------------------------------------
    
    libzfs.pyx:48:0: 'config.pxi' not found
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        DRYRUN = 5
        PARSABLE = 6
        PROGRESS = 7
        LARGEBLOCK = 8
        EMBED_DATA = 9
        IF HAVE_SENDFLAGS_T_COMPRESS:
          ^
    ------------------------------------------------------------
    
    libzfs.pyx:254:7: Compile-time name 'HAVE_SENDFLAGS_T_COMPRESS' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        DIRECTORY = '/'
        SYMLINK = '@'
        SOCKET = '='
    
    
    IF HAVE_ZFS_MAX_DATASET_NAME_LEN:
      ^
    ------------------------------------------------------------
    
    libzfs.pyx:274:3: Compile-time name 'HAVE_ZFS_MAX_DATASET_NAME_LEN' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                'oldpath': getattr(self, 'oldpath', None)
            }
    
    
    
    IF HAVE_LZC_SEND_FLAG_EMBED_DATA:
      ^
    ------------------------------------------------------------
    
    libzfs.pyx:323:3: Compile-time name 'HAVE_LZC_SEND_FLAG_EMBED_DATA' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                flags.force = True
    
            if nomount:
                flags.nomount = True
    
            IF HAVE_RECVFLAGS_T_RESUMABLE:
              ^
    ------------------------------------------------------------
    
    libzfs.pyx:770:11: Compile-time name 'HAVE_RECVFLAGS_T_RESUMABLE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    
            IF HAVE_RECVFLAGS_T_RESUMABLE:
                if resumable:
                    flags.resumable = True
    
            IF HAVE_ZFS_RECEIVE == 7:
              ^
    ------------------------------------------------------------
    
    libzfs.pyx:774:11: Compile-time name 'HAVE_ZFS_RECEIVE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                if props:
                    props_nvl = NVList(otherdict=props)
                    c_props_nvl = props_nvl.handle
    
                with nogil:
                    IF HAVE_ZFS_RECEIVE == 6:
                      ^
    ------------------------------------------------------------
    
    libzfs.pyx:799:19: Compile-time name 'HAVE_ZFS_RECEIVE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                    out.append('log')
                    out.append(topology.get('log'))
    
            return out
    
        IF HAVE_SENDFLAGS_T_TYPEDEF and HAVE_ZFS_SEND_RESUME:
          ^
    ------------------------------------------------------------
    
    libzfs.pyx:903:7: Compile-time name 'HAVE_SENDFLAGS_T_TYPEDEF' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                    out.append('log')
                    out.append(topology.get('log'))
    
            return out
    
        IF HAVE_SENDFLAGS_T_TYPEDEF and HAVE_ZFS_SEND_RESUME:
                                       ^
    ------------------------------------------------------------
    
    libzfs.pyx:903:36: Compile-time name 'HAVE_ZFS_SEND_RESUME' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                    ret = libzfs.zfs_send_resume(self.handle, &cflags, c_fd, c_token)
    
                if ret != 0:
                    raise ZFSException(self.errno, self.errstr)
    
        IF HAVE_ZFS_SEND_RESUME_TOKEN_TO_NVLIST:
          ^
    ------------------------------------------------------------
    
    libzfs.pyx:921:7: Compile-time name 'HAVE_ZFS_SEND_RESUME_TOKEN_TO_NVLIST' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                elapsed = (int(time.time()) - self.stat[10]) or 1
                pass_exam = self.stat[9] or 1
                rate = pass_exam / elapsed
                return int((total - examined) / rate)
    
        IF HAVE_POOL_SCAN_STAT_T_PAUSE:
          ^
    ------------------------------------------------------------
    
    libzfs.pyx:1673:7: Compile-time name 'HAVE_POOL_SCAN_STAT_T_PAUSE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
                    return None
    
                if not self.bytes_to_scan:
                    return 0
    
                IF HAVE_POOL_SCAN_STAT_T_PAUSE:
                  ^
    ------------------------------------------------------------
    
    libzfs.pyx:1707:15: Compile-time name 'HAVE_POOL_SCAN_STAT_T_PAUSE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    
        def start_scrub(self):
            cdef int ret
    
            with nogil:
                IF HAVE_ZPOOL_SCAN == 3:
                  ^
    ------------------------------------------------------------
    
    libzfs.pyx:2157:15: Compile-time name 'HAVE_ZPOOL_SCAN' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    
        def stop_scrub(self):
            cdef int ret
    
            with nogil:
                IF HAVE_ZPOOL_SCAN == 3:
                  ^
    ------------------------------------------------------------
    
    libzfs.pyx:2171:15: Compile-time name 'HAVE_ZPOOL_SCAN' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    
            if fromname:
                cfromname = fromname
    
            with nogil:
                IF HAVE_LZC_SEND_SPACE == 4:
                  ^
    ------------------------------------------------------------
    
    libzfs.pyx:2446:15: Compile-time name 'HAVE_LZC_SEND_SPACE' not defined
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
            cflags.largeblock = 1
    
        if SendFlag.EMBED_DATA in flags:
            cflags.embed_data = 1
    
        IF HAVE_SENDFLAGS_T_COMPRESS:
          ^
    ------------------------------------------------------------
    
    libzfs.pyx:2997:7: Compile-time name 'HAVE_SENDFLAGS_T_COMPRESS' not defined
    
    building 'libzfs' extension
    creating build/temp.freebsd-12.0-RELEASE-p2-amd64-3.7
    cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector -fno-strict-aliasing -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/home/lars/PycharmProjects/iocage/venv/include -I/usr/local/include/python3.7m -c libzfs.c -o build/temp.freebsd-12.0-RELEASE-p2-amd64-3.7/libzfs.o -DNEED_SOLARIS_BOOLEAN -D_XPG6 -g
    libzfs.c:1:2: error: Do not use this file, it is the result of a failed Cython compilation.
    #error Do not use this file, it is the result of a failed Cython compilation.
     ^
    1 error generated.
    error: command 'cc' failed with exit status 1
    
    ----------------------------------------
Command "/home/lars/PycharmProjects/iocage/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4ml0h6te/libzfs/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-7gsagzn5/install-record.txt --single-version-externally-managed --compile --install-headers /home/lars/PycharmProjects/iocage/venv/include/site/python3.7/libzfs" failed with error code 1 in /tmp/pip-install-4ml0h6te/libzfs/

My FreeBSd is the following:

(venv) lars@freebsd:/home/lars/PycharmProjects/iocage git:(master*) $ freebsd-version                                                         
12.0-RELEASE-p2
(venv) lars@freebsd:/home/lars/PycharmProjects/iocage git:(master*) $ uname -a       
FreeBSD freebsd 12.0-RELEASE-p2 FreeBSD 12.0-RELEASE-p2 GENERIC  amd64

Could you please help me?

Best regards
Lars

Hello @Corvan, so the library should install fine if you use the installation instructions in the readme file. However we can certainly look into pip. I think the configure script is not being run which in turn results in missing files and the build fails. So for the time being please look at the readme instructions till we verify and fix this. Thank you!

Ok, I'll try that, thank you

So it really was the problem, that the configure script was not run by pip before installing.

Yes that indeed was the issue. I'll be looking this today/tomorrow as well to see if we could perhaps do something about pip. If yes, I'll reference this issue with my PR ;) Thank you for bringing this to us!

Cool, thx for looking into it.