]> git.pld-linux.org Git - packages/python-greenlet.git/commitdiff
Version: 0.4.2, python3 support added
authorJacek Konieczny <j.konieczny@eggsoft.pl>
Fri, 21 Feb 2014 07:32:44 +0000 (08:32 +0100)
committerJacek Konieczny <j.konieczny@eggsoft.pl>
Fri, 21 Feb 2014 09:37:26 +0000 (10:37 +0100)
– Patches removed – it is not clear what they were supposed to fix, they
are not used upstream and they were dropped in Fedora too.

– License updated – part of the code is licensed under MIT, other part
under PSF.

– Use currently built module when running the benchmark

get-rid-of-ts_origin.patch [deleted file]
i686-register-fixes.patch [deleted file]
python-greenlet.spec

diff --git a/get-rid-of-ts_origin.patch b/get-rid-of-ts_origin.patch
deleted file mode 100644 (file)
index 0840b5f..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-diff -up greenlet-0.3.1/greenlet.c.get-rid-of-ts_origin greenlet-0.3.1/greenlet.c
---- greenlet-0.3.1/greenlet.c.get-rid-of-ts_origin     2010-04-05 17:24:25.000000000 -0400
-+++ greenlet-0.3.1/greenlet.c  2011-10-19 13:59:30.485035920 -0400
-@@ -116,10 +116,8 @@ extern PyTypeObject PyGreenlet_Type;
- /* The current greenlet in this thread state (holds a reference) */
- static PyGreenlet* ts_current = NULL;
--/* Holds a reference to the switching-from stack during the slp switch */
--static PyGreenlet* ts_origin = NULL;
- /* Holds a reference to the switching-to stack during the slp switch */
--static PyGreenlet* ts_target = NULL;
-+static PyGreenlet* volatile ts_target = NULL;
- /* NULL if error, otherwise args tuple to pass around during slp switch */
- static PyObject* ts_passaround_args = NULL;
- static PyObject* ts_passaround_kwargs = NULL;
-@@ -257,6 +255,7 @@ static int g_save(PyGreenlet* g, char* s
- static void slp_restore_state(void)
- {
-       PyGreenlet* g = ts_target;
-+      PyGreenlet* owner = ts_current;
-       
-       /* Restore the heap copy back into the C stack */
-       if (g->stack_saved != 0) {
-@@ -265,30 +264,32 @@ static void slp_restore_state(void)
-               g->stack_copy = NULL;
-               g->stack_saved = 0;
-       }
--      if (ts_current->stack_stop == g->stack_stop)
--              g->stack_prev = ts_current->stack_prev;
--      else
--              g->stack_prev = ts_current;
-+      if (owner->stack_start == NULL)
-+              owner = owner->stack_prev; /* greenlet is dying, skip it */
-+      while (owner && owner->stack_stop <= g->stack_stop)
-+              owner = owner->stack_prev; /* find greenlet with more stack */
-+      g->stack_prev = owner;
- }
- static int slp_save_state(char* stackref)
- {
-       /* must free all the C stack up to target_stop */
-       char* target_stop = ts_target->stack_stop;
--      assert(ts_current->stack_saved == 0);
--      if (ts_current->stack_start == NULL)
--              ts_current = ts_current->stack_prev;  /* not saved if dying */
-+      PyGreenlet* owner = ts_current;
-+      assert(owner->stack_saved == 0);
-+      if (owner->stack_start == NULL)
-+              owner = owner->stack_prev;  /* not saved if dying */
-       else
--              ts_current->stack_start = stackref;
-+              owner->stack_start = stackref;
-       
--      while (ts_current->stack_stop < target_stop) {
-+      while (owner->stack_stop < target_stop) {
-               /* ts_current is entierely within the area to free */
--              if (g_save(ts_current, ts_current->stack_stop))
-+              if (g_save(owner, owner->stack_stop))
-                       return -1;  /* XXX */
--              ts_current = ts_current->stack_prev;
-+              owner = owner->stack_prev;
-       }
--      if (ts_current != ts_target) {
--              if (g_save(ts_current, target_stop))
-+      if (owner != ts_target) {
-+              if (g_save(owner, target_stop))
-                       return -1;  /* XXX */
-       }
-       return 0;
-@@ -337,11 +338,11 @@ static int g_switchstack(void)
-       */
-       int err;
-       {   /* save state */
-+              PyGreenlet* current = ts_current;
-               PyThreadState* tstate = PyThreadState_GET();
--              ts_current->recursion_depth = tstate->recursion_depth;
--              ts_current->top_frame = tstate->frame;
-+              current->recursion_depth = tstate->recursion_depth;
-+              current->top_frame = tstate->frame;
-       }
--      ts_origin = ts_current;
-       err = _PyGreenlet_slp_switch();
-       if (err < 0) {   /* error */
-               Py_XDECREF(ts_passaround_args);
-@@ -351,13 +352,15 @@ static int g_switchstack(void)
-               ts_passaround_kwargs = NULL;
-       }
-       else {
-+              PyGreenlet* target = ts_target;
-+              PyGreenlet* origin = ts_current;
-               PyThreadState* tstate = PyThreadState_GET();
--              tstate->recursion_depth = ts_target->recursion_depth;
--              tstate->frame = ts_target->top_frame;
--              ts_target->top_frame = NULL;
--              ts_current = ts_target;
--              Py_INCREF(ts_target);
--              Py_DECREF(ts_origin);
-+              tstate->recursion_depth = target->recursion_depth;
-+              tstate->frame = target->top_frame;
-+              target->top_frame = NULL;
-+              ts_current = target;
-+              Py_INCREF(target);
-+              Py_DECREF(origin);
-       }
-       return err;
- }
diff --git a/i686-register-fixes.patch b/i686-register-fixes.patch
deleted file mode 100644 (file)
index b7a26d0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-# HG changeset patch
-# User Alexey Borzenkov <snaury@gmail.com>
-# Date 1313701525 -14400
-# Node ID 25bf29f4d3b79b026c1c05787bb741a8e7ef2229
-# Parent  c0bf397a723d4b61d7ef78cf575dea4c0fdb527e
-Fix compilation and register problems on some i386 configurations
-
-diff -r c0bf397a723d4b61d7ef78cf575dea4c0fdb527e -r 25bf29f4d3b79b026c1c05787bb741a8e7ef2229 platform/switch_x86_unix.h
---- a/platform/switch_x86_unix.h       Thu Aug 18 02:44:20 2011 +0400
-+++ b/platform/switch_x86_unix.h       Fri Aug 19 01:05:25 2011 +0400
-@@ -2,6 +2,8 @@
-  * this is the internal transfer function.
-  *
-  * HISTORY
-+ * 19-Aug-11  Alexey Borzenkov  <snaury@gmail.com>
-+ *      Correctly save ebp, ebx and cw
-  * 07-Sep-05 (py-dev mailing list discussion)
-  *      removed 'ebx' from the register-saved.  !!!! WARNING !!!!
-  *      It means that this file can no longer be compiled statically!
-@@ -34,18 +36,13 @@
- static int
- slp_switch(void)
- {
-+    void *ebp, *ebx;
-+    unsigned short cw;
-     register int *stackref, stsizediff;
--    /* !!!!WARNING!!!! need to add "ebx" in the next line, as well as in the
--     * last line of this function, if this header file is meant to be compiled
--     * non-dynamically!
--     */
--    __asm__ volatile ("" : : :
--      "esi",
--      "edi"
--#ifdef __MINGW32__
--    , "ebx"
--#endif
--    );
-+    __asm__ volatile ("" : : : "esi", "edi");
-+    __asm__ volatile ("fstcw %0" : "=m" (cw));
-+    __asm__ volatile ("movl %%ebp, %0" : "=m" (ebp));
-+    __asm__ volatile ("movl %%ebx, %0" : "=m" (ebx));
-     __asm__ ("movl %%esp, %0" : "=g" (stackref));
-     {
-         SLP_SAVE_STATE(stackref, stsizediff);
-@@ -57,13 +54,10 @@
-             );
-         SLP_RESTORE_STATE();
-     }
--    __asm__ volatile ("" : : :
--      "esi",
--      "edi"
--#ifdef __MINGW32__
--    , "ebx"
--#endif
--    );
-+    __asm__ volatile ("movl %0, %%ebx" : : "m" (ebx));
-+    __asm__ volatile ("movl %0, %%ebp" : : "m" (ebp));
-+    __asm__ volatile ("fldcw %0" : : "m" (cw));
-+    __asm__ volatile ("" : : : "esi", "edi");
-     return 0;
- }
index 4dbb9cf8b104ee9cadcaafc3824b424a0c6e4bfc..ae71875824c062a70e13008503ce590a97fab79d 100644 (file)
@@ -1,25 +1,43 @@
-#
+
+# TODO:
+#      one of two happens when building 'with python2_tests':
+#      - FAIL: test_threaded_adv_leak (tests.test_leaks.ArgRefcountTests)
+#      or:
+#       - PYTHONPATH=/home/users/jajcus/rpm/BUILD/greenlet-0.4.2/build/lib.linux-i686-2.7 /usr/bin/python benchmarks/chain.py
+#         python: Objects/object.c:2453: _PyTrash_thread_deposit_object: Assertion `((((((((PyObject*)(op))->ob_type)))->tp_flags & ((1L<<14))) != 0) && ((((PyObject*)(op))->ob_type)->tp_is_gc == ((void *)0) || (((PyObject*)(op))->ob_type)->tp_is_gc(op)))' failed.
+#         Result:Aborted
+
 # Conditional build:
 %bcond_without tests   # do not perform "make test"
+%bcond_without python2 # CPython 2.x module
+%bcond_without python3 # CPython 3.x module
+%bcond_without python2_tests # CPython 2.x module tests
+
+%if %{without tests}
+%undefine      with_python2_tests
+%endif
 
 %define        module  greenlet
 Summary:       Lightweight in-process concurrent programming
 Name:          python-%{module}
-Version:       0.3.1
-Release:       1
-License:       MIT
-Group:         Development/Libraries
+Version:       0.4.2
+Release:       0.1
+License:       MIT & PSF
+Group:         Libraries/Python
 URL:           http://pypi.python.org/pypi/greenlet
-Source0:       http://pypi.python.org/packages/source/g/greenlet/%{module}-%{version}.tar.gz
-# Source0-md5: 8d75d7f3f659e915e286e1b0fa0e1c4d
-# Based on https://bitbucket.org/ambroff/greenlet/changeset/2d5b17472757
-# slightly fixed up to apply cleanly. Avoid rhbz#746771
-Patch1:                get-rid-of-ts_origin.patch
-# Apply https://bitbucket.org/ambroff/greenlet/changeset/25bf29f4d3b7
-# to fix the i686 crash in rhbz#746771
-Patch2:                i686-register-fixes.patch
+Source0:       http://pypi.python.org/packages/source/g/greenlet/%{module}-%{version}.zip
+# Source0-md5: 580a8a5e833351f7abdaedb1a877f7ac
+%if %{with python2}
 BuildRequires: python-devel
 BuildRequires: python-setuptools
+%endif
+%if %{with python3}
+BuildRequires: python3-2to3
+BuildRequires: python3-devel
+BuildRequires: python3-distribute
+BuildRequires: python3-modules
+%endif
+BuildRequires: rpmbuild(macros) >= 1.219
 BuildRequires: rpm-pythonprov
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -37,48 +55,91 @@ Requires:   %{name} = %{version}-%{release}
 %description devel
 This package contains header files required for C modules development.
 
+%package -n python3-%{module}
+Summary:       Lightweight in-process concurrent programming
+Group:         Libraries/Python
+
+%description -n python3-%{module}
+The greenlet package is a spin-off of Stackless, a version of CPython
+that supports micro-threads called "tasklets". Tasklets run
+pseudo-concurrently (typically in a single or a few OS-level threads)
+and are synchronized with data exchanges on "channels".
+
+%package -n python3-%{module}-devel
+Summary:       C development headers for python3-greenlet
+Group:         Development/Libraries
+Requires:      python3-%{module} = %{version}-%{release}
+
+%description -n python3-%{module}-devel
+This package contains header files required for C modules development.
+
 %prep
 %setup -q -n greenlet-%{version}
-%patch1 -p1
-%patch2 -p1
 
 %build
+%if %{with python2}
 CC="%{__cc}" \
 CFLAGS="%{rpmcflags}" \
 %{__python} setup.py build
 
-%if %{with tests}
-# FIXME!!
-# The checks segfault on ppc64. So this arch
-# is essentially not supported until this is fixed
-%ifnarch ppc ppc64 s390 s390x
-# Run the upstream test suite:
+%if %{with python2_tests}
 %{__python} setup.py test
 
 # Run the upstream benchmarking suite to further exercise the code:
-PYTHONPATH=$(pwd) %{__python} benchmarks/chain.py
-PYTHONPATH=$(pwd) %{__python} benchmarks/switch.py
+PYTHONPATH=$(echo $(pwd)/build/lib.*-2.?) %{__python} benchmarks/chain.py
+%endif
+%endif
+
+%if %{with python3}
+# CC/CFLAGS is only for arch packages - remove on noarch packages
+CC="%{__cc}" \
+CFLAGS="%{rpmcflags}" \
+%{__python3} setup.py build %{?with_tests:test}
+
+%if %{with tests}
+# Run the upstream benchmarking suite to further exercise the code:
+mkdir -p benchmarks-3
+2to3-3.3 -o benchmarks-3 -n -w --no-diffs benchmarks
+PYTHONPATH=$(echo $(pwd)/build/lib.*-3.?) %{__python3} benchmarks-3/chain.py
 %endif
 %endif
 
 %install
-rm -rf $RPM_BUILD_ROOT
-%{__python} setup.py install \
-       --skip-build \
+%if %{with python2}
+%{__python} setup.py \
+       install --skip-build \
        --optimize=2 \
        --root=$RPM_BUILD_ROOT
 
 %py_postclean
+%endif
+
+%if %{with python3}
+%{__python3} setup.py \
+       install --skip-build \
+       --optimize=2 \
+       --root=$RPM_BUILD_ROOT
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(644,root,root,755)
-%doc doc/greenlet.txt README benchmarks AUTHORS NEWS
+%doc doc/greenlet.txt README.rst benchmarks AUTHORS NEWS LICENSE
 %attr(755,root,root) %{py_sitedir}/%{module}.so
 %{py_sitedir}/%{module}*.egg-info
 
 %files devel
 %defattr(644,root,root,755)
 %{_includedir}/python%{py_ver}/greenlet
+
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc doc/greenlet.txt README.rst benchmarks AUTHORS NEWS LICENSE
+%attr(755,root,root) %{py3_sitedir}/%{module}.*.so
+%{py3_sitedir}/%{module}*.egg-info
+
+%files -n python3-%{module}-devel
+%defattr(644,root,root,755)
+%{_includedir}/python%{py3_ver}*/greenlet
This page took 0.122748 seconds and 4 git commands to generate.