pycups

This page is about the Python bindings for the CUPS API, known as pycups. It was written for use with system-config-printer, but can be put to other uses as well.

I work on this module as part of my job at Red Hat.

Download

Download tarball releases from:
http://cyberelk.net/tim/data/pycups/

or from the Python Package Index:
http://pypi.python.org/pypi/pycups

Source Code

Fetch the source like this:

git clone git://git.fedorahosted.org/git/pycups.git

or browse it using gitweb.

New releases are announced at freshmeat.

Documentation

Documentation is produced using epydoc and hosted at the pycups PyPI page.

Bug Reporting

Report bugs using the trac interface.

Discussion

Discussion of pycups is welcome on the system-config-printer mailing list.

77 Responses to “pycups”

  1. Dmitri says:

    can someone help me out?
    http://forums.gentoo.org/viewtopic-t-931628.html
    I can not figure out how to fix it.
    [code]
    building ‘cups’ extension
    creating build
    creating build/temp.linux-x86_64-2.7
    x86_64-pc-linux-gnu-gcc -pthread -march=core2 -mtune=generic -Os -pipe -msse3 -msse4 -mcx16 -msahf -mpopcnt -DVERSION=”1.9.61″ -fPIC -DVERSION=”1.9.61″ -I/usr/include/python2.7 -c cupsmodule.c -o build/temp.linux-x86_64-2.7/cupsmodule.o
    cupsmodule.c: In function ‘cups_ppdSetConformance':
    cupsmodule.c:413:3: warning: ‘ppdSetConformance’ is deprecated (declared at /usr/include/cups/ppd.h:414) [-Wdeprecated-declarations]
    cupsmodule.c: In function ‘initcups':
    cupsmodule.c:853:3: error: ‘CUPS_SERVER_REMOTE_PRINTERS’ undeclared (first use in this function)
    cupsmodule.c:853:3: note: each undeclared identifier is reported only once for each function it appears in
    error: command ‘x86_64-pc-linux-gnu-gcc’ failed with exit status 1
    [/code]

  2. Dmitri says:

    net-print/cups-1.6.0 USE=”X acl dbus filters pam python ssl threads usb -avahi -debug -gnutls -java -kerberos (-selinux) -static-libs -systemd -xinetd -zeroconf”

  3. Dmitri says:

    thanks.
    UPD:
    I just updated CUPS from SVN and it did not help any.

    [code]
    emerge -v pycups

    These are the packages that would be merged, in order:

    Calculating dependencies… done!
    [ebuild N ] dev-python/pycups-1.9.61 USE=”-doc -examples” 0 kB

    Total: 1 package (1 new), Size of downloads: 0 kB

    >>> Verifying ebuild manifests

    >>> Emerging (1 of 1) dev-python/pycups-1.9.61
    * pycups-1.9.61.tar.bz2 SHA256 SHA512 WHIRLPOOL size 😉 … [ ok ]
    >>> Unpacking source…
    >>> Unpacking pycups-1.9.61.tar.bz2 to /var/tmp/portage/dev-python/pycups-1.9.61/work
    >>> Source unpacked in /var/tmp/portage/dev-python/pycups-1.9.61/work
    >>> Preparing source in /var/tmp/portage/dev-python/pycups-1.9.61/work/pycups-1.9.61 …
    >>> Source prepared.
    >>> Configuring source in /var/tmp/portage/dev-python/pycups-1.9.61/work/pycups-1.9.61 …
    >>> Source configured.
    >>> Compiling source in /var/tmp/portage/dev-python/pycups-1.9.61/work/pycups-1.9.61 …
    python2.7 setup.py build
    running build
    running build_ext
    building ‘cups’ extension
    creating build
    creating build/temp.linux-x86_64-2.7
    x86_64-pc-linux-gnu-gcc -pthread -march=core2 -mtune=generic -Os -pipe -msse3 -msse4 -mcx16 -msahf -mpopcnt -DVERSION=”1.9.61″ -fPIC -DVERSION=”1.9.61″ -I/usr/include/python2.7 -c cupsmodule.c -o build/temp.linux-x86_64-2.7/cupsmodule.o
    cupsmodule.c: In function ‘cups_ppdSetConformance’:
    cupsmodule.c:413:3: warning: ‘ppdSetConformance’ is deprecated (declared at /usr/include/cups/ppd.h:414) [-Wdeprecated-declarations]
    cupsmodule.c: In function ‘initcups’:
    cupsmodule.c:853:3: error: ‘CUPS_SERVER_REMOTE_PRINTERS’ undeclared (first use in this function)
    cupsmodule.c:853:3: note: each undeclared identifier is reported only once for each function it appears in
    error: command ‘x86_64-pc-linux-gnu-gcc’ failed with exit status 1
    * ERROR: dev-python/pycups-1.9.61 failed (compile phase):
    * Building failed
    *
    * Call stack:
    * ebuild.sh, line 85: Called src_compile
    * environment, line 5288: Called distutils_src_compile
    * environment, line 1296: Called die
    * The specific snippet of code:
    * “$(PYTHON)” “${setup_file#*|}” “${_DISTUTILS_GLOBAL_OPTIONS[@]}” build “$@” || die “Building failed”;
    *
    * If you need support, post the output of `emerge –info ‘=dev-python/pycups-1.9.61’`,
    * the complete build log and the output of `emerge -pqv ‘=dev-python/pycups-1.9.61’`.
    * The complete build log is located at ‘/var/tmp/portage/dev-python/pycups-1.9.61/temp/build.log’.
    * The ebuild environment file is located at ‘/var/tmp/portage/dev-python/pycups-1.9.61/temp/environment’.
    * Working directory: ‘/var/tmp/portage/dev-python/pycups-1.9.61/work/pycups-1.9.61′
    * S: ‘/var/tmp/portage/dev-python/pycups-1.9.61/work/pycups-1.9.61′

    >>> Failed to emerge dev-python/pycups-1.9.61, Log file:

    >>> ‘/var/tmp/portage/dev-python/pycups-1.9.61/temp/build.log’

    * Messages for package dev-python/pycups-1.9.61:

    * ERROR: dev-python/pycups-1.9.61 failed (compile phase):
    * Building failed
    *
    * Call stack:
    * ebuild.sh, line 85: Called src_compile
    * environment, line 5288: Called distutils_src_compile
    * environment, line 1296: Called die
    * The specific snippet of code:
    * “$(PYTHON)” “${setup_file#*|}” “${_DISTUTILS_GLOBAL_OPTIONS[@]}” build “$@” || die “Building failed”;
    *
    * If you need support, post the output of `emerge –info ‘=dev-python/pycups-1.9.61’`,
    * the complete build log and the output of `emerge -pqv ‘=dev-python/pycups-1.9.61’`.
    * The complete build log is located at ‘/var/tmp/portage/dev-python/pycups-1.9.61/temp/build.log’.
    * The ebuild environment file is located at ‘/var/tmp/portage/dev-python/pycups-1.9.61/temp/environment’.
    * Working directory: ‘/var/tmp/portage/dev-python/pycups-1.9.61/work/pycups-1.9.61′
    * S: ‘/var/tmp/portage/dev-python/pycups-1.9.61/work/pycups-1.9.61′

    [/code]

  4. Dmitri says:

    pycups successfully compiled with cups-1.5.3

  5. […] why not just use pycups or pkipplib? pycups is tightly coupled with CUPS itself. You need to have CUPS binaries installed […]

  6. […] enable Airprint, we will use the airprint-generate.py. For this, we also need the pycups library. I have used version 1.9.62 but I guess that newer version will also […]

  7. Hello, I get the following errors when building againt cups-devel-1.4.2-67.el6.x86_64 on Red Hat Enterprise Linux Server release 6.6 (Santiago) python 3.4.2.

    Cheers,
    Gav


    cupsmodule.c:1315: error: ‘IPP_OP_RELEASE_HELD_NEW_JOBS’ undeclared (first use in this function)

    cupsmodule.c:1316: error: ‘IPP_OP_DEACTIVATE_PRINTER’ undeclared (first use in this function)

    • Peter says:

      Hi, I’ve been installing cups with pycups without an issue for a couple months, but since early December, we’ve been running into this issue when we perform the command: sudo pip install pycups.

      A lot of errors appear similar to this:

      cupsmodule.c:1282:3: error: ‘IPP_OP_PRINT_URI’ undeclared
      cupsmodule.c:1284:3: error: ‘IPP_OP_CREATE_JOB’ undeclared

      etc. etc. The errors seem to all have to do with IPP_OP_something something.

      Any assistance would be greatly appreciated.

      • Tim says:

        These ‘IPP_* undeclared’ errors are fixed in pycups-1.9.71.

        • Hi Tim,

          Thanks for that – any ideas when we will see a 1.9.71 release on pypi?

          Cheers,
          Gav

        • Thanks Tim! I’ll update when I get back to work on Monday!

          • Hey Tim,

            Sorry still getting IPP_ undeclared problems with pycups 1.7.1 (same config as above)

            Running setup.py bdist_wheel for pycups
            Destination directory: /home/gavinj/wheelhouse
            Complete output from command /home/gavinj/pyvenv_libtest/bin/python3 -c “import setuptools;__file__=’/home/gavinj/pyvenv_libtest/build/pycups/setup.py';exec(compile(open(__file__).read().replace(‘\r\n’, ‘\n’), __file__, ‘exec’))” bdist_wheel -d /home/gavinj/wheelhouse:
            running bdist_wheel

            running build

            running build_ext

            building ‘cups’ extension

            creating build

            creating build/temp.linux-x86_64-3.4

            gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -I/usr/include/expat21 -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DVERSION=”1.9.71″ -I/home/gavinj/pyvenv_libtest/include -I/usr/include/python3.4m -c cupsmodule.c -o build/temp.linux-x86_64-3.4/cupsmodule.o

            cupsmodule.c: In function ‘PyInit_cups’:

            cupsmodule.c:1350: error: ‘IPP_UPGRADE_REQUIRED’ undeclared (first use in this function)

            cupsmodule.c:1350: error: (Each undeclared identifier is reported only once

            cupsmodule.c:1350: error: for each function it appears in.)

            cupsmodule.c:1446: error: ‘IPP_CANCEL_DOCUMENT’ undeclared (first use in this function)

            cupsmodule.c:1447: error: ‘IPP_GET_DOCUMENT_ATTRIBUTES’ undeclared (first use in this function)

            cupsmodule.c:1448: error: ‘IPP_GET_DOCUMENTS’ undeclared (first use in this function)

            cupsmodule.c:1449: error: ‘IPP_DELETE_DOCUMENT’ undeclared (first use in this function)

            cupsmodule.c:1450: error: ‘IPP_SET_DOCUMENT_ATTRIBUTES’ undeclared (first use in this function)

            cupsmodule.c:1451: error: ‘IPP_CANCEL_JOBS’ undeclared (first use in this function)

            cupsmodule.c:1452: error: ‘IPP_CANCEL_MY_JOBS’ undeclared (first use in this function)

            cupsmodule.c:1453: error: ‘IPP_RESUBMIT_JOB’ undeclared (first use in this function)

            cupsmodule.c:1454: error: ‘IPP_CLOSE_JOB’ undeclared (first use in this function)

            cupsmodule.c:1455: error: ‘IPP_IDENTIFY_PRINTER’ undeclared (first use in this function)

            error: command ‘gcc’ failed with exit status 1

          • Tim says:

            Oops, sorry. I released 1.9.72 yesterday to fix this.

Leave a reply

Comments are moderated. Comments that are inappropriate, offensive, vulgar, badly written or insulting will be deleted or edited to make the author look silly.