- Really start the monitor on pyudev.Monitor.poll()

- Force non-blocking IO in pyudev.Monitor to avoid blocking on receiving the device
- Set proper flags on pipe fs
- Handle irregular polling events properly
- Rename MonitorObserver GUI classes and deprecate the old ones
- Remove patches for #1170337 and #1230773 that are now part of upstream
- Switch to new packaging guidelines which renames python-pyudev to python2-pyudev
This commit is contained in:
David Shea 2015-09-14 14:10:17 -04:00
parent d4bc73df66
commit 1bbbad6812
6 changed files with 69 additions and 1520 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/pyudev-0.15.tar.gz
/pyudev-0.16.1.tar.gz
/pyudev-0.17.tar.gz

View File

@ -0,0 +1,23 @@
From 2aa590dcdeb8ced47e801b9fcef084959b8e2bc9 Mon Sep 17 00:00:00 2001
From: David Shea <dshea@redhat.com>
Date: Mon, 14 Sep 2015 13:34:17 -0400
Subject: [PATCH] Do not install the tests as a module.
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 1920cec..a8044e9 100644
--- a/setup.py
+++ b/setup.py
@@ -52,5 +52,5 @@
'Topic :: System :: Hardware',
'Topic :: System :: Operating System Kernels :: Linux',
],
- packages=setuptools.find_packages(),
+ packages=setuptools.find_packages(exclude=['tests.*', 'tests']),
)
--
2.4.3

View File

@ -1,23 +1,17 @@
Name: python-pyudev
Version: 0.16.1
Release: 4%{?dist}
%global srcname pyudev
Name: python-%{srcname}
Version: 0.17
Release: 1%{?dist}
Summary: A libudev binding
License: LGPLv2+
URL: http://pypi.python.org/pypi/pyudev
Source0: http://pypi.python.org/packages/source/p/pyudev/pyudev-%{version}.tar.gz
Source0: http://pypi.python.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.gz
# Based on 0113ccdbba1aef69f3f890fd72622f24d79d907a in github.com/lunaryorn/pyudev.git
Patch0: pyudev-0.16.1-global-libudev.patch
# Based on af9ba7b27478274a2f5f9676de662b079a3a8c22 in github.com/dashea/pyudev.git
Patch1: pyudev-eintr-retry.patch
Patch0: 0001-Do-not-install-the-tests-as-a-module.patch
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python-setuptools
%description
pyudev is a LGPL licensed, pure Python binding for libudev, the device
and hardware management and information library for Linux. It supports
@ -30,8 +24,29 @@ PyPy 1.5 or newer. It is tested against udev 151 or newer, earlier
versions of udev as found on dated Linux systems may work, but are not
officially supported.
%package -n python3-pyudev
%package -n python2-%{srcname}
Summary: A libudev binding
%{?python_provide:%python_provide python2-%{srcname}}
BuildRequires: python2-devel
BuildRequires: python-setuptools
%description -n python2-%{srcname}
pyudev is a LGPL licensed, pure Python binding for libudev, the device
and hardware management and information library for Linux. It supports
almost all libudev functionality, you can enumerate devices, query device
properties and attributes or monitor devices, including asynchronous
monitoring with threads, or within the event loops of Qt, Glib or wxPython.
The binding supports CPython 2 (2.6 or newer) and 3 (3.1 or newer), and
PyPy 1.5 or newer. It is tested against udev 151 or newer, earlier
versions of udev as found on dated Linux systems may work, but are not
officially supported.
%package -n python3-%{srcname}
Summary: A libudev binding
%{?python_provide:%python_provide python2-%{srcname}}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
@ -48,52 +63,39 @@ versions of udev as found on dated Linux systems may work, but are not
officially supported.
%prep
%setup -qc
mv pyudev-%{version} python2
pushd python2
%autosetup -n %{srcname}-%{version}
rm -rf pyudev.egg-info
%patch0 -p1 -b .global-libudev
%patch1 -p1 -b .eintr-retry
# Copy common doc files to the top directory
cp -pr COPYING README.rst CHANGES.rst ../
popd
cp -a python2 python3
%build
pushd python2
%{__python2} setup.py build
popd
pushd python3
%{__python3} setup.py build
popd
%py2_build
%py3_build
%install
pushd python2
%{__python2} setup.py install --skip-build --root $RPM_BUILD_ROOT
popd
%py2_install
%py3_install
pushd python3
%{__python3} setup.py install --skip-build --root $RPM_BUILD_ROOT
popd
%files
%files -n python2-%{srcname}
%license COPYING
%doc README.rst CHANGES.rst
%{python2_sitelib}/pyudev
%{python2_sitelib}/pyudev-%{version}-*.egg-info
%files -n python3-pyudev
%files -n python3-%{srcname}
%license COPYING
%doc README.rst CHANGES.rst
%{python3_sitelib}/pyudev
%{python3_sitelib}/pyudev-%{version}-*.egg-info
%changelog
* Mon Sep 14 2015 David Shea <dshea@redhat.com> - 0.17.1-1
- Really start the monitor on pyudev.Monitor.poll()
- Force non-blocking IO in pyudev.Monitor to avoid blocking on receiving the device
- Set proper flags on pipe fs
- Handle irregular polling events properly
- Rename MonitorObserver GUI classes and deprecate the old ones
- Remove patches for #1170337 and #1230773 that are now part of upstream
- Switch to new packaging guidelines which renames python-pyudev to python2-pyudev
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.16.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

File diff suppressed because it is too large Load Diff

View File

@ -1,102 +0,0 @@
diff -purN pyudev-0.16.1.orig/pyudev/monitor.py pyudev-0.16.1/pyudev/monitor.py
--- pyudev-0.16.1.orig/pyudev/monitor.py 2015-06-12 09:36:21.427469657 -0400
+++ pyudev-0.16.1/pyudev/monitor.py 2015-06-12 09:37:05.483447685 -0400
@@ -34,7 +34,7 @@ import select
from threading import Thread
from contextlib import closing
-from pyudev._util import ensure_byte_string
+from pyudev._util import ensure_byte_string, eintr_retry_call
from pyudev.core import Device
@@ -337,7 +337,7 @@ class Monitor(object):
.. versionadded:: 0.16
"""
- rlist, _, _ = select.select([self], [], [], timeout)
+ rlist, _, _ = eintr_retry_call(select.select, [self], [], [], timeout)
if self in rlist:
return self._receive_device()
else:
@@ -407,7 +407,7 @@ class Monitor(object):
with closing(select.epoll()) as notifier:
notifier.register(self, select.EPOLLIN)
while True:
- events = notifier.poll()
+ events = eintr_retry_call(notifier.poll)
for event in events:
device = self._receive_device()
yield device.action, device
@@ -503,14 +503,14 @@ class MonitorObserver(Thread):
# and on the monitor
notifier.register(self.monitor, select.EPOLLIN)
while True:
- for fd, _ in notifier.poll():
+ for fd, _ in eintr_retry_call(notifier.poll):
if fd == self._stop_event_source:
# in case of a stop event, close our pipe side, and
# return from the thread
os.close(self._stop_event_source)
return
else:
- device = self.monitor.poll(timeout=0)
+ device = eintr_retry_call(self.monitor.poll, timeout=0)
if device:
self._callback(device)
@@ -530,7 +530,7 @@ class MonitorObserver(Thread):
return
try:
# emit a stop event to the thread
- os.write(self._stop_event_sink, b'\x01')
+ eintr_retry_call(os.write, self._stop_event_sink, b'\x01')
finally:
# close the out-of-thread side of the pipe
os.close(self._stop_event_sink)
diff -purN pyudev-0.16.1.orig/pyudev/_util.py pyudev-0.16.1/pyudev/_util.py
--- pyudev-0.16.1.orig/pyudev/_util.py 2015-06-12 09:36:21.428469657 -0400
+++ pyudev-0.16.1/pyudev/_util.py 2015-06-12 09:36:45.923457440 -0400
@@ -32,6 +32,7 @@ from __future__ import (print_function,
import os
import sys
import stat
+import errno
if sys.version_info[0] == 2:
@@ -141,3 +142,34 @@ def get_device_type(filename):
return 'block'
else:
raise ValueError('not a device file: {0!r}'.format(filename))
+
+
+def eintr_retry_call(func, *args, **kwargs):
+ """
+ Handle interruptions to an interruptible system call.
+
+ Run an interruptible system call in a loop and retry if it raises EINTR.
+ The signal calls that my raise EINTR prior to Python 3.5 are listed in
+ PEP 0475. Any calls to these functions must be wrapped in eintr_retry_call
+ in order to handle EINTR returns in older versions of Python.
+
+ This function is based on _eintr_retry_call in python's subprocess.py.
+ """
+
+ # select.error inherits from Exception instead of OSError in Python 2
+ import select
+
+ while True:
+ try:
+ return func(*args, **kwargs)
+ except (OSError, IOError, select.error) as e:
+ # If this is not an IOError or OSError, it's the old select.error
+ # type, which means that the errno is only accessible via subscript
+ if isinstance(e, (OSError, IOError)):
+ error_code = e.errno
+ else:
+ error_code = e[0]
+
+ if error_code == errno.EINTR:
+ continue
+ raise

View File

@ -1 +1 @@
4034de584b6d9efcbfc590a047c63285 pyudev-0.16.1.tar.gz
0450afde50383538a987d16450853fb1 pyudev-0.17.tar.gz