python3-yappi: upgrade 1.4.0 -> 1.6.0; fix ptests

* Switch to the python_setuptools_build_meta PEP-517 backend
* Refactor and submit 0001-Fix-imports-for-ptests.patch
  - split out the Windows -> Unix line endings conversion
  - https://github.com/sumerc/yappi/pull/164
* Drop 0002-add-3.11-to-the-setup.patch; upstream added 3.11 and 3.12
* Drop install of yappi.py in ptest; use site-packages as intended
* Drop complex run-ptest and simply run 'pytest --automake'
* Move out of "problems" group to "slow" group in ptest-packageslists-meta-python.inc
  - can now build meta-python-image-ptest-python3-yappi
  - tests take about 45 seconds

https://github.com/sumerc/yappi/blob/1.6.0/CHANGELOG

1.6.0 (2023-12-07)

- Drop support 2.7-3.5 and clean backward compatible code (pull/152)
- Add Python 3.12 wheels

1.5.1 (2023-12-06)

- Add support for Python 3.12
- Fix child callgrind functions disappear

Signed-off-by: Tim Orling <ticotimo@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Tim Orling 2023-12-24 09:05:56 -08:00 committed by Khem Raj
parent 813fb0def8
commit f8d66f3174
No known key found for this signature in database
GPG Key ID: BB053355919D3314
7 changed files with 175 additions and 149 deletions

View File

@ -56,6 +56,7 @@ PTESTS_FAST_META_PYTHON = "\
PTESTS_SLOW_META_PYTHON = "\
python3-lz4 \
python3-yappi \
"
PTESTS_PROBLEMS_META_PYTHON ="\
@ -84,6 +85,5 @@ PTESTS_PROBLEMS_META_PYTHON ="\
python3-whoosh \
python3-ujson \
python3-xlrd \
python3-yappi \
python3-yarl \
"

View File

@ -1,44 +1,23 @@
From 0dedc1c573ddc4e87475eb03c64555cd54a72e92 Mon Sep 17 00:00:00 2001
From: Trevor Gamblin <trevor.gamblin@windriver.com>
Date: Mon, 7 Jun 2021 09:40:20 -0400
Subject: [PATCH] Fix imports for tests
From 0136ca731cba8b056b3f2ff0e7df3953b94f1e87 Mon Sep 17 00:00:00 2001
From: Tim Orling <tim.orling@konsulko.com>
Date: Sun, 24 Dec 2023 09:41:57 -0800
Subject: [PATCH 1/2] test_functionality: convert line endings to Unix
Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
Convert the Windows line endings with dos2unix to be like the
other files in tests/*
Upstream-Status: Submitted [https://github.com/sumerc/yappi/pull/164]
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
Upstream-Status: Pending
tests/test_functionality.py | 3822 +++++++++++++++++------------------
1 file changed, 1911 insertions(+), 1911 deletions(-)
tests/test_asyncio.py | 2 +-
tests/test_asyncio_context_vars.py | 2 +-
tests/test_functionality.py | 2 +-
tests/test_hooks.py | 2 +-
tests/test_tags.py | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
--- a/tests/test_asyncio.py
+++ b/tests/test_asyncio.py
@@ -2,7 +2,7 @@ import unittest
import yappi
import asyncio
import threading
-from utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
+from .utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
async def async_sleep(sec):
--- a/tests/test_asyncio_context_vars.py
+++ b/tests/test_asyncio_context_vars.py
@@ -5,7 +5,7 @@ import contextvars
import functools
import time
import os
-import utils
+import tests.utils as utils
import yappi
async_context_id = contextvars.ContextVar('async_context_id')
diff --git a/tests/test_functionality.py b/tests/test_functionality.py
index 0e99c47..38bbe67 100644
--- a/tests/test_functionality.py
+++ b/tests/test_functionality.py
@@ -1,1916 +1,1916 @@
@@ -1,1911 +1,1911 @@
-import os
-import sys
-import time
@ -47,7 +26,7 @@ Upstream-Status: Pending
-import yappi
-import _yappi
-import utils
-import multiprocessing # added to fix http://bugs.python.org/issue15881 for > Py2.6
-import multiprocessing
-import subprocess
-
-_counter = 0
@ -318,10 +297,10 @@ Upstream-Status: Pending
- def test_profile_decorator(self):
-
- def aggregate(func, stats):
- fname = "tests/%s.profile" % (func.__name__)
- fname = f"tests/{func.__name__}.profile"
- try:
- stats.add(fname)
- except IOError:
- except OSError:
- pass
- stats.save(fname)
- raise Exception("messing around")
@ -1232,7 +1211,7 @@ Upstream-Status: Pending
- # TODO: I put dummy() to fix below, remove the comments after a while.
- self.assertTrue( # FIX: I see this fails sometimes?
- tsm is not None,
- 'Could not find "_MainThread". Found: %s' % (', '.join(utils.get_stat_names(tstats))))
- f"Could not find \"_MainThread\". Found: {', '.join(utils.get_stat_names(tstats))}")
-
- def test_ctx_stats(self):
- from threading import Thread
@ -1312,7 +1291,7 @@ Upstream-Status: Pending
- # TODO: I put dummy() to fix below, remove the comments after a while.
- self.assertTrue( # FIX: I see this fails sometimes
- tsmain is not None,
- 'Could not find "_MainThread". Found: %s' % (', '.join(utils.get_stat_names(stats))))
- f"Could not find \"_MainThread\". Found: {', '.join(utils.get_stat_names(stats))}")
- self.assertTrue(1.0 > tst2.ttot >= 0.5)
- self.assertTrue(1.0 > tst1.ttot >= 0.5)
-
@ -1369,7 +1348,7 @@ Upstream-Status: Pending
- ts = []
- for i in (0.01, 0.05, 0.1):
- t = threading.Thread(target=burn_cpu, args=(i, ))
- t.name = "burn_cpu-%s" % str(i)
- t.name = f"burn_cpu-{str(i)}"
- t.start()
- ts.append(t)
- for t in ts:
@ -1396,10 +1375,7 @@ Upstream-Status: Pending
- def test_producer_consumer_with_queues(self):
- # we currently just stress yappi, no functionality test is done here.
- yappi.start()
- if utils.is_py3x():
- from queue import Queue
- else:
- from Queue import Queue
- from queue import Queue
- from threading import Thread
- WORKER_THREAD_COUNT = 50
- WORK_ITEM_COUNT = 2000
@ -1458,7 +1434,6 @@ Upstream-Status: Pending
- fsh = utils.find_stat_by_name(stats, "handler")
- self.assertTrue(fsh is not None)
-
- @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
- def test_concurrent_futures(self):
- yappi.start()
- from concurrent.futures import ThreadPoolExecutor
@ -1468,7 +1443,6 @@ Upstream-Status: Pending
- time.sleep(1.0)
- yappi.stop()
-
- @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
- def test_barrier(self):
- yappi.start()
- b = threading.Barrier(2, timeout=1)
@ -1962,8 +1936,8 @@ Upstream-Status: Pending
+import unittest
+import yappi
+import _yappi
+import tests.utils as utils
+import multiprocessing # added to fix http://bugs.python.org/issue15881 for > Py2.6
+import utils
+import multiprocessing
+import subprocess
+
+_counter = 0
@ -2234,10 +2208,10 @@ Upstream-Status: Pending
+ def test_profile_decorator(self):
+
+ def aggregate(func, stats):
+ fname = "tests/%s.profile" % (func.__name__)
+ fname = f"tests/{func.__name__}.profile"
+ try:
+ stats.add(fname)
+ except IOError:
+ except OSError:
+ pass
+ stats.save(fname)
+ raise Exception("messing around")
@ -3007,8 +2981,8 @@ Upstream-Status: Pending
+
+ def test_issue_32(self):
+ '''
+ Start yappi from different thread and we get Internal Error(15) as
+ the current_ctx_id() called while enumerating the threads in start()
+ Start yappi from different thread and we get Internal Error(15) as
+ the current_ctx_id() called while enumerating the threads in start()
+ and as it does not swap to the enumerated ThreadState* the THreadState_GetDict()
+ returns wrong object and thus sets an invalid id for the _ctx structure.
+
@ -3148,7 +3122,7 @@ Upstream-Status: Pending
+ # TODO: I put dummy() to fix below, remove the comments after a while.
+ self.assertTrue( # FIX: I see this fails sometimes?
+ tsm is not None,
+ 'Could not find "_MainThread". Found: %s' % (', '.join(utils.get_stat_names(tstats))))
+ f"Could not find \"_MainThread\". Found: {', '.join(utils.get_stat_names(tstats))}")
+
+ def test_ctx_stats(self):
+ from threading import Thread
@ -3228,7 +3202,7 @@ Upstream-Status: Pending
+ # TODO: I put dummy() to fix below, remove the comments after a while.
+ self.assertTrue( # FIX: I see this fails sometimes
+ tsmain is not None,
+ 'Could not find "_MainThread". Found: %s' % (', '.join(utils.get_stat_names(stats))))
+ f"Could not find \"_MainThread\". Found: {', '.join(utils.get_stat_names(stats))}")
+ self.assertTrue(1.0 > tst2.ttot >= 0.5)
+ self.assertTrue(1.0 > tst1.ttot >= 0.5)
+
@ -3285,7 +3259,7 @@ Upstream-Status: Pending
+ ts = []
+ for i in (0.01, 0.05, 0.1):
+ t = threading.Thread(target=burn_cpu, args=(i, ))
+ t.name = "burn_cpu-%s" % str(i)
+ t.name = f"burn_cpu-{str(i)}"
+ t.start()
+ ts.append(t)
+ for t in ts:
@ -3312,10 +3286,7 @@ Upstream-Status: Pending
+ def test_producer_consumer_with_queues(self):
+ # we currently just stress yappi, no functionality test is done here.
+ yappi.start()
+ if utils.is_py3x():
+ from queue import Queue
+ else:
+ from Queue import Queue
+ from queue import Queue
+ from threading import Thread
+ WORKER_THREAD_COUNT = 50
+ WORK_ITEM_COUNT = 2000
@ -3374,7 +3345,6 @@ Upstream-Status: Pending
+ fsh = utils.find_stat_by_name(stats, "handler")
+ self.assertTrue(fsh is not None)
+
+ @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
+ def test_concurrent_futures(self):
+ yappi.start()
+ from concurrent.futures import ThreadPoolExecutor
@ -3384,7 +3354,6 @@ Upstream-Status: Pending
+ time.sleep(1.0)
+ yappi.stop()
+
+ @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
+ def test_barrier(self):
+ yappi.start()
+ b = threading.Barrier(2, timeout=1)
@ -3871,25 +3840,6 @@ Upstream-Status: Pending
+ # import sys;sys.argv = ['', 'BasicUsage.test_run_as_script']
+ # import sys;sys.argv = ['', 'MultithreadedScenarios.test_subsequent_profile']
+ unittest.main()
--- a/tests/test_hooks.py
+++ b/tests/test_hooks.py
@@ -5,7 +5,7 @@ import unittest
import time
import yappi
-import utils
+import tests.utils as utils
def a():
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -2,7 +2,7 @@ import unittest
import yappi
import threading
import time
-from utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
+from .utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
class MultiThreadTests(YappiUnitTestCase):
--
2.34.1

View File

@ -0,0 +1,101 @@
From 28eac38566327091221aabbc164ea8e433c66e7e Mon Sep 17 00:00:00 2001
From: Tim Orling <tim.orling@konsulko.com>
Date: Sun, 24 Dec 2023 09:27:50 -0800
Subject: [PATCH 2/2] Fix import of tests.utils to enable pytest
Running the test cases with pytest leads to importlib errors
because the "utils" module cannot be found.
Upstream-Status: Submitted [https://github.com/sumerc/yappi/pull/164]
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
tests/test_asyncio.py | 2 +-
tests/test_asyncio_context_vars.py | 2 +-
tests/test_functionality.py | 2 +-
tests/test_gevent.py | 2 +-
tests/test_hooks.py | 2 +-
tests/test_tags.py | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py
index 8e9e631..bb36f4a 100644
--- a/tests/test_asyncio.py
+++ b/tests/test_asyncio.py
@@ -2,7 +2,7 @@ import unittest
import yappi
import asyncio
import threading
-from utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
+from tests.utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
async def async_sleep(sec):
diff --git a/tests/test_asyncio_context_vars.py b/tests/test_asyncio_context_vars.py
index 5bd750c..9a253c0 100644
--- a/tests/test_asyncio_context_vars.py
+++ b/tests/test_asyncio_context_vars.py
@@ -5,7 +5,7 @@ import contextvars
import functools
import time
import os
-import utils
+import tests.utils as utils
import yappi
async_context_id = contextvars.ContextVar('async_context_id')
diff --git a/tests/test_functionality.py b/tests/test_functionality.py
index 38bbe67..8098f17 100644
--- a/tests/test_functionality.py
+++ b/tests/test_functionality.py
@@ -5,7 +5,7 @@ import threading
import unittest
import yappi
import _yappi
-import utils
+import tests.utils as utils
import multiprocessing
import subprocess
diff --git a/tests/test_gevent.py b/tests/test_gevent.py
index ed9e6ae..502af5f 100644
--- a/tests/test_gevent.py
+++ b/tests/test_gevent.py
@@ -2,7 +2,7 @@ import unittest
import _yappi
import yappi
import threading
-from utils import (
+from tests.utils import (
YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io, burn_io_gevent
)
diff --git a/tests/test_hooks.py b/tests/test_hooks.py
index 297c643..8c387fc 100644
--- a/tests/test_hooks.py
+++ b/tests/test_hooks.py
@@ -5,7 +5,7 @@ import unittest
import time
import yappi
-import utils
+import tests.utils as utils
def a():
diff --git a/tests/test_tags.py b/tests/test_tags.py
index b0b531d..b5a4016 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -2,7 +2,7 @@ import unittest
import yappi
import threading
import time
-from utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
+from tests.utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
class MultiThreadTests(YappiUnitTestCase):
--
2.34.1

View File

@ -1,26 +0,0 @@
From 38afdacf526410f970afc58e147c7377c6c7112c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=BCmer=20Cip?= <sumer.cip@platform.sh>
Date: Fri, 25 Nov 2022 15:58:03 +0300
Subject: [PATCH 2/2] add 3.11 to the setup
---
Upstream-Status: Pending
setup.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/setup.py b/setup.py
index d006787..96e2a66 100644
--- a/setup.py
+++ b/setup.py
@@ -56,6 +56,7 @@ CLASSIFIERS = [
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
+ 'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Operating System :: OS Independent',
'Topic :: Software Development :: Libraries',
--
2.30.2

View File

@ -1,3 +1,3 @@
#!/bin/sh
pytest -o log_cli=true -o log_cli_level=INFO | sed -e 's/\[...%\]//g'| sed -e 's/PASSED/PASS/g'| sed -e 's/FAILED/FAIL/g'|sed -e 's/SKIPED/SKIP/g'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS"){printf "%s: %s\n", $NF, $0}else{print}}'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS") {$NF="";print $0}else{print}}'
pytest --automake

View File

@ -1,36 +0,0 @@
SUMMARY = "Yet Another Python Profiler"
HOMEPAGE = "https://github.com/sumerc/yappi"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=71c208c9a4fd864385eb69ad4caa3bee"
SRC_URI[sha256sum] = "504b5d8fc7433736cb5e257991d2e7f2946019174f1faec7b2fe947881a17fc0"
SRC_URI += " \
file://run-ptest \
file://0001-Fix-imports-for-ptests.patch \
file://0002-add-3.11-to-the-setup.patch \
"
inherit pypi setuptools3 ptest
RDEPENDS:${PN} += "\
${PYTHON_PN}-datetime \
${PYTHON_PN}-pickle \
${PYTHON_PN}-threading \
"
RDEPENDS:${PN}-ptest += " \
${PYTHON_PN}-gevent \
${PYTHON_PN}-multiprocessing \
${PYTHON_PN}-pytest \
${PYTHON_PN}-profile \
${PYTHON_PN}-zopeinterface \
"
do_install_ptest() {
install -d ${D}${PTEST_PATH}/tests
cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
cp -f ${S}/yappi/yappi.py ${D}/${PTEST_PATH}/
}

View File

@ -0,0 +1,37 @@
SUMMARY = "Yet Another Python Profiler"
HOMEPAGE = "https://github.com/sumerc/yappi"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=71c208c9a4fd864385eb69ad4caa3bee"
SRC_URI[sha256sum] = "a9aaf72009d8c03067294151ee0470ac7a6dfa7b33baab40b198d6c1ef00430a"
SRC_URI += " \
file://run-ptest \
file://0001-test_functionality-convert-line-endings-to-Unix.patch \
file://0002-Fix-import-of-tests.utils-to-enable-pytest.patch \
"
inherit pypi python_setuptools_build_meta ptest
RDEPENDS:${PN} += "\
python3-datetime \
python3-pickle \
python3-threading \
"
RDEPENDS:${PN}-ptest += " \
python3-gevent \
python3-multiprocessing \
python3-pytest \
python3-profile \
python3-unittest-automake-output \
python3-zopeinterface \
"
do_install_ptest() {
install -d ${D}${PTEST_PATH}/tests
cp -rf ${S}/tests ${D}${PTEST_PATH}
cp -f ${S}/run_tests.py ${D}${PTEST_PATH}
}