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.

Download

Download tarball releases from the Python Package Index:
http://pypi.python.org/pypi/pycups

or older releases from:
http://cyberelk.net/tim/data/pycups/

Source Code

The git repository is available at GitHub.

Bug Reporting

Report issues using GitHub.

Comments

86 responses to “pycups”

  1. Dmitri avatar

    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]

    1. tim avatar

      Which version of cups are you building it against?

  2. Dmitri avatar

    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”

    1. tim avatar

      There are some fixes since 1.9.61 for CUPS 1.6. I’ll make a new release soon.

  3. Dmitri avatar

    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]

    1. tim avatar

      You’ll need a newer version of pycups. I haven’t released one yet, but the git repository has the fixes.

  4. Dmitri avatar

    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. Gavin Jackson avatar

    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)

    1. Peter avatar
      Peter

      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.

      1. Tim avatar

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

        1. Gavin Jackson avatar

          Hi Tim,

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

          Cheers,
          Gav

          1. Tim avatar

            Thanks for reminding me. I’ve released 1.9.71 today.

        2. Gavin Jackson avatar

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

          1. Gavin Jackson avatar

            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

          2. Tim avatar

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

  8. Steve avatar
    Steve

    Seeing a massive number of the “undeclared (first use in this function)” errors when building on:
    Red Hat Enterprise Linux Server release 7.1 (Maipo)
    cups-libs-1.6.3-17.el7_1.1.x86_64
    cups-devel-1.6.3-17.el7_1.1.x86_64
    python-2.7.5-18.el7_1.1.x86_64
    python-devel-2.7.5-18.el7_1.1.x86_64

    Sample:
    $ python setup.py build
    running build
    running build_ext
    building ‘cups’ extension
    creating build
    creating build/temp.linux-x86_64-2.7
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DVERSION=”1.9.72″ -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:600:3: warning: ‘ppdSetConformance’ is deprecated (declared at /usr/include/cups/ppd.h:414) [-Wdeprecated-declarations]
    ppdSetConformance (level);
    ^
    cupsmodule.c: In function ‘initcups’:
    cupsmodule.c:1181:22: error: ‘HTTP_STATUS_ERROR’ undeclared (first use in this function)
    INT_CONSTANT_ALIAS(HTTP_STATUS_##name, “HTTP_”#name)
    ^
    cupsmodule.c:1116:51: note: in definition of macro ‘INT_CONSTANT_ALIAS’
    PyDict_SetItemString (d, #name, PyInt_FromLong (name)); \
    ^
    cupsmodule.c:1187:3: note: in expansion of macro ‘INT_HTTP_STATUS_CONSTANT’
    INT_HTTP_STATUS_CONSTANT (ERROR);
    ^
    cupsmodule.c:1181:22: note: each undeclared identifier is reported only once for each function it appears in
    INT_CONSTANT_ALIAS(HTTP_STATUS_##name, “HTTP_”#name)
    ^
    cupsmodule.c:1116:51: note: in definition of macro ‘INT_CONSTANT_ALIAS’
    PyDict_SetItemString (d, #name, PyInt_FromLong (name)); \
    ^

    1. Tim avatar

      Should be fixed now in master.

      1. Steve avatar
        Steve

        Thank you, built fine. Very much appreciate your time to fix.

  9. keshav avatar
    keshav

    Thank you for pycups. I’ve had a good time with it for the past few days. I am working on a small project that archives local print jobs for retrieval and analysis. To this end, I found a Redhat email post by you on “CUPS Configuration: Get-Notifications”.

    Could you please take some time to elaborate on `Connection.createSubscription()` method?

    Specifically, what do the parameters `uri`, `recipient_uri`, and `events` mean?

    1. Tim Waugh avatar

      Hi,

      As pycups is simply a wrapper around libcups, the best thing to look for is the CUPS documentation.

      If you can’t find what you need there, as CUPS is an implementation of IPP the next step is the IPP specification.

      Here’s a start for CUPS:
      http://www.cups.org/documentation.php/spec-ipp.html#CREATE_PRINTER_SUBSCRIPTION

  10. Gael C avatar
    Gael C

    Hi Tim,

    Thank you for pycups. I use it in several software and it’s work perfectly.
    I have a question. Is there a way to print several file if I want to specify different option (to change paper bac for example) for each file ?

    Perhaps cups.Connection.printFiles function reply to my question but how to specify options for 1rst document, options for second document, …

    Thank’s by advance for your answer.
    Have a good day.

    Gael

    1. Tim Waugh avatar

      No, I think you’d have to issue separate requests for that.

  11. beanpow avatar
    beanpow

    Hi Tim,
    thank you for pycups. i want to know how to use pycups,but i can’t open the website of the document?can you help me ?

    1. Tim Waugh avatar

      Unfortunately pythonhosted.org documentation can no longer be uploaded so I’ve removed it.

      To see the documentation, run ‘make doc’ once you have unpacked the tar file.

Leave a Reply to Dmitri Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.