Skip to main content

Pure-Python bindings to glibc (based on ctypes)

Project description

Pure-Python bindings to glibc (based on ctypes)

.. image::

.. image::

.. image::


* Free software: LGPLv3 license
* Works on python 2.7+ and python 3.2+ and pypy
* Currently exposes 23 low-level glibc functions (see below), 10 data types and
118 constants. All useful glibc features are in scope (patches welcome!)
* ``from glibc import ...`` -- direct access to glibc constants, functions and
types via lazy imports, fast startup, low memory overhead, efficient calls to
* Translates error codes according to documentation (manual pages) of each
supported function. Raises OSError with appropriate values and a customized,
easy-to-understand error message.
* Uses declarative "bindings", easy to verify for correctness, easy to add more
types, functions and constants. Built-in tests verify the value of each
constant, size and offset of each structure / union field and the size of the
whole structure / union.
* Adds high-level abstractions on top of raw functions (,
pyglibc.signalfd, pyglibc.selectors, pyglibc.pthread_sigmask, pyglibc.pipe,
pyglibc.subreaper) so that using them is easier and more pythonic.
* This code is entirely optional and users can still call the low-level
C-equivalents directly.
* Where possible, existing Python APIs are followed so that glibc_select and
glibc_selectors are drop-in replacements for the select and selectors modules
from Python's standard library.


The following glibc functions are supported

=========================== =================================
Name Remarks
=========================== =================================
``close(2)`` Same as os.close()
``dup(2)`` Same as os.dup()
``dup2(2)`` Same as os.dup2()
``dup3(2)`` Same as os.dup(flags=)
``epoll_create(2)`` Similar to select.epoll()
``epoll_create1(2)`` Similar to select.epoll()
``epoll_ctl(2)`` Similar to select.epoll.{register,unregister,modify}
``epoll_wait(2)`` Similar to select.epoll.poll()
``pipe(2)`` Same as os.pipe
``read(2)`` Unlike, this one makes no copies

0.6.1 (2014-11-20)

* Small change to internal APIs (no need to upgrade or there are no public API

0.6 (2014-11-09)

* Functions from the pthread library are now supported
* Added functions: ``read(2)``, ``pause(2)``, ``eventfd(2)``,
``eventfd_read(2)``, ``eventfd_write(2)``, ``clock_getres(2)``,
``clock_gettime(2)`` and ``clock_settime(2)``.
* Added constants: ``NSIG``, ``EFD_CLOEXEC``, ``EFD_NONBLOCK``,
* Added new module :mod:`` that contains a Python 2.7+ version of the from Python 3.4. This module contains a pure-python version of the
``epoll`` class. It may be used in place of the module from the standard
library if additional features are desired in a cross-python-version portable
* Added new module :mod:`pyglibc.selectors` that contains a Python 2.7+ version
of the from Python 3.4. As with, it can be used
in place of the original.
* Added new module :mod:`pyglibc._signalfd` that exposes ``signalfd(2)`` in a
much more pythonic way. Use signalfd as a file, as a context manager, inspect
it in pdb, all easily without having to browse through manual pages. It is
exposed as ``pyglibc.signalfd`` for easier importing.
* Added new module :mod:`pyglibc._pthread_sigmask` that exposes
``pthread_sigmask(2)`` in a much more pythonic way, making it a perfect
companion for the ``signalfd()`` class. It is exposed as
``pyglibc.pthread_sigmask`` for easier importing.
* Added new module :mod:`pyglibc._pipe` that expoes ``pipe2(2)`` in the same
way as Python 3.4 does via the ``os.pipe()`` and ``os.pipe2()`` functions.
* Added new module :mod:`pyglibc._subreaper` that adds pythonic API to
``prctl(PR_{GET,SET}_CHILD_SUBREAPER, ...)``. This module exposes a single
instance called ``subreaper``.

0.5 (2014-10-22)

* Added tests for structure / union size and offset of each field
* New feature, type aliases for non-compound types like ``time_t``.
* Added functions: ``prctl(2)``, ``timerfd_create(2)``, ``timerfd_settime(2)``,
* Added constants: ``PR_SET_PDEATHSIG``, ``PR_GET_PDEATHSIG``,
* Added structures: ``struct itimerspec``, ``struct timespec`` and
``struct timeval``.
* Added type alias for ``time_t`` and ``suseconds_t``

0.4 (2014-10-21)

* Started tracking changes relevant to other people.
* First release with tests for constants and type sizes.
* Fixed issues with ``struct epoll_event`` (size mismatch).
* Added functions: ``close(2)``.
* Added constants: ``FD_SETSIZE``, ``EPOLLRDNORM``, ``EPOLLRDBAND``,
* Improved bundled demos (not part of release)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glibc-0.6.1.tar.gz (97.7 kB view hashes)

Uploaded source

Built Distribution

glibc-0.6.1-py2.py3-none-any.whl (35.2 kB view hashes)

Uploaded 2 7

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page