mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-08 08:30:47 -09:00
package/python-memray: new package
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
e58321b680
commit
c2df8bab97
@@ -1224,6 +1224,7 @@ menu "External python modules"
|
||||
source "package/python-mbstrdecoder/Config.in"
|
||||
source "package/python-mdurl/Config.in"
|
||||
source "package/python-memory-profiler/Config.in"
|
||||
source "package/python-memray/Config.in"
|
||||
source "package/python-midiutil/Config.in"
|
||||
source "package/python-mimeparse/Config.in"
|
||||
source "package/python-minimalmodbus/Config.in"
|
||||
|
||||
19
package/python-memray/Config.in
Normal file
19
package/python-memray/Config.in
Normal file
@@ -0,0 +1,19 @@
|
||||
config BR2_PACKAGE_PYTHON_MEMRAY
|
||||
bool "python-memray"
|
||||
depends on BR2_USE_WCHAR # elfutils
|
||||
depends on !BR2_STATIC_LIBS # elfutils
|
||||
depends on BR2_TOOLCHAIN_HAS_THREADS # elfutils
|
||||
depends on BR2_TOOLCHAIN_HAS_SYNC_4 # elfutils/libdebuginfod
|
||||
depends on BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS
|
||||
select BR2_PACKAGE_ELFUTILS
|
||||
select BR2_PACKAGE_ELFUTILS_LIBDEBUGINFOD
|
||||
select BR2_PACKAGE_LIBUNWIND
|
||||
select BR2_PACKAGE_LZ4
|
||||
select BR2_PACKAGE_PYTHON3_ZLIB
|
||||
select BR2_PACKAGE_PYTHON_JINJA2 # runtime
|
||||
select BR2_PACKAGE_PYTHON_RICH # runtime
|
||||
select BR2_PACKAGE_PYTHON_TEXTUAL # runtime
|
||||
help
|
||||
A memory profiler for Python applications.
|
||||
|
||||
https://github.com/bloomberg/memray
|
||||
6
package/python-memray/python-memray.hash
Normal file
6
package/python-memray/python-memray.hash
Normal file
@@ -0,0 +1,6 @@
|
||||
# md5, sha256 from https://pypi.org/pypi/memray/json
|
||||
md5 b48d378a5e5ca043a210781a2023dbe6 memray-1.17.2.tar.gz
|
||||
sha256 eb75c075874a6eccddf361513d9d4a9223dd940580c6370a6ba5339bae5d0ba2 memray-1.17.2.tar.gz
|
||||
# Locally computed sha256 checksums
|
||||
sha256 c973dd08e49022a4017ffd457116b046ebe07fc71a644fd760d64183869ca97f LICENSE
|
||||
sha256 ef8a9b3247488f8901ca60de9b17b745d7bd67e5ec1e622f80d62364572200d8 src/vendor/libbacktrace/LICENSE
|
||||
22
package/python-memray/python-memray.mk
Normal file
22
package/python-memray/python-memray.mk
Normal file
@@ -0,0 +1,22 @@
|
||||
################################################################################
|
||||
#
|
||||
# python-memray
|
||||
#
|
||||
################################################################################
|
||||
|
||||
PYTHON_MEMRAY_VERSION = 1.17.2
|
||||
PYTHON_MEMRAY_SOURCE = memray-$(PYTHON_MEMRAY_VERSION).tar.gz
|
||||
PYTHON_MEMRAY_SITE = https://files.pythonhosted.org/packages/df/40/66e6ae86c0a22b8b998779fa8d6c0ab9ee63f0943198adcf714934286cbf
|
||||
PYTHON_MEMRAY_SETUP_TYPE = setuptools
|
||||
PYTHON_MEMRAY_LICENSE = Apache-2.0
|
||||
PYTHON_MEMRAY_LICENSE_FILES = LICENSE src/vendor/libbacktrace/LICENSE
|
||||
PYTHON_MEMRAY_DEPENDENCIES = host-python-cython host-python-pkgconfig lz4 elfutils libunwind
|
||||
|
||||
# Define cross-compile target for bundled & patched libbacktrace.
|
||||
PYTHON_MEMRAY_ENV = MEMRAY_LIBBACKTRACE_TARGET=$(GNU_TARGET_NAME)
|
||||
|
||||
# Sources must be compiled with -fPIC, otherwise linking with -flto
|
||||
# (which memray sets by default) fails.
|
||||
PYTHON_MEMRAY_ENV += CPPFLAGS="$(TARGET_CPPFLAGS) -fPIC"
|
||||
|
||||
$(eval $(python-package))
|
||||
10
support/testing/tests/package/sample_python_memray.py
Normal file
10
support/testing/tests/package/sample_python_memray.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# The test needs some code to profile, it does not have to be much.
|
||||
|
||||
def run(a):
|
||||
print(a[0])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# make sure there's at least a small allocation
|
||||
a = ['Hello World!']
|
||||
run(a)
|
||||
38
support/testing/tests/package/test_python_memray.py
Normal file
38
support/testing/tests/package/test_python_memray.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from tests.package.test_python import TestPythonPackageBase
|
||||
import os
|
||||
|
||||
|
||||
class TestPythonMemray(TestPythonPackageBase):
|
||||
__test__ = True
|
||||
config = TestPythonPackageBase.config + \
|
||||
"""
|
||||
BR2_PACKAGE_PYTHON3=y
|
||||
BR2_PACKAGE_PYTHON_MEMRAY=y
|
||||
"""
|
||||
sample_scripts = ["tests/package/sample_python_memray.py"]
|
||||
|
||||
def test_run(self):
|
||||
self.login()
|
||||
self.check_sample_scripts_exist()
|
||||
test_trace = "/tmp/trace.bin"
|
||||
test_flame = "/tmp/trace.html"
|
||||
|
||||
# profile the sample script
|
||||
cmd = "%s -m memray run -o %s %s" % (self.interpreter, test_trace, os.path.basename(self.sample_scripts[0]))
|
||||
output, exit_code = self.emulator.run(cmd, timeout=15)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertIn("Hello World!", output)
|
||||
|
||||
# generate statistics
|
||||
cmd = "%s -m memray stats %s" % (self.interpreter, test_trace)
|
||||
output, exit_code = self.emulator.run(cmd, timeout=15)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertTrue(any(filter(lambda line: "alloc" in line, output)))
|
||||
|
||||
# generate flamegraph
|
||||
cmd = "%s -m memray flamegraph -o %s %s" % (self.interpreter, test_flame, test_trace)
|
||||
output, exit_code = self.emulator.run(cmd, timeout=15)
|
||||
self.assertEqual(exit_code, 0)
|
||||
# rough plausibility check if the output file is HTML
|
||||
cmd = "grep -i '</html>' %s" % (test_flame,)
|
||||
self.assertEqual(exit_code, 0)
|
||||
Reference in New Issue
Block a user