From f7964e5f4bebbe3b2502f0a8b114956159bf74f3 Mon Sep 17 00:00:00 2001 From: Kent Slaney Date: Mon, 22 Jan 2024 17:57:24 -0800 Subject: [PATCH] debugging conviences --- Makefile | 2 +- misc/git/debug.patch | 7 +++++-- misc/memcached_server | 32 ++++++++++++++++++++++---------- misc/runbench.py | 2 +- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index d1363d8d..0b6a7ff9 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ pytest: pytest tests/ clean: - rm -fr build cython_debug libmc/*.so libmc/*.cpp + rm -fr build cython_debug libmc/*.so libmc/*.cpp .eggs diff --git a/misc/git/debug.patch b/misc/git/debug.patch index a5360a6e..b8c94569 100644 --- a/misc/git/debug.patch +++ b/misc/git/debug.patch @@ -1,5 +1,5 @@ diff --git a/setup.py b/setup.py -index c9807b9..b3a915b 100644 +index afc15c1..98f8465 100644 --- a/setup.py +++ b/setup.py @@ -5,23 +5,43 @@ import sys @@ -74,7 +74,7 @@ index c9807b9..b3a915b 100644 setup( name="libmc", -@@ -121,16 +160,18 @@ setup( +@@ -121,18 +160,20 @@ setup( ], # Support for the basestring type is new in Cython 0.20. setup_requires=["Cython >= 0.20"], @@ -96,3 +96,6 @@ index c9807b9..b3a915b 100644 tests_require=[ "pytest", "future", +- "numpy", ++ #"numpy", + ]) diff --git a/misc/memcached_server b/misc/memcached_server index e074d66a..f8bcdf5b 100755 --- a/misc/memcached_server +++ b/misc/memcached_server @@ -71,19 +71,24 @@ function capture() function virtualize() { if [ ! -e venv ]; then - dbg="${1:-`which python-dbg || which python3-dbg`}" - if ! $dbg -m pip list | grep -w virtualenv &> /dev/null; then - $dbg -m pip install virtualenv + py="${1:-`which python 2>/dev/null`}" + if ! $py -m pip list | grep -w virtualenv &> /dev/null; then + $py -m pip install virtualenv fi - $dbg -m virtualenv --python="$dbg" --seeder=pip venv; + $py -m virtualenv --python="$py" --seeder=pip venv; source venv/bin/activate pip install -U pip - pip install Cython setuptools future pytest greenify gevent numpy + pip install Cython setuptools future pytest greenify gevent else source venv/bin/activate fi } +function src_dir() +{ + cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd +} + case "$1" in start) if [ -n "$2" ]; then @@ -148,11 +153,10 @@ case "$1" in capture $@ ;; cy-debug) - DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - cd "$DIR/.." + cd "`src_dir`/.." git apply misc/git/debug.patch --recount &> /dev/null || true source misc/git/pre-commit - virtualize + virtualize "`which python-dbg || which python3-dbg`" dbg="`which python-dbg || which python3-dbg`" #make clean $dbg setup.py build_ext --inplace @@ -164,11 +168,19 @@ case "$1" in fi ;; run-test) - cd "$( dirname "${BASH_SOURCE[0]}" )/.." &> /dev/null - virtualize "`which python 2>/dev/null`" + cd "`src_dir`/.." + virtualize shift python setup.py test -a "-k $*" ;; + bench) + cd "`src_dir`/.." + virtualize + make clean + python setup.py build_ext --inplace + python -m pip install pylibmc python-memcached + python misc/runbench.py + ;; *) printf 'Usage: %s {start|stop|restart} \n' "$prog" exit 1 diff --git a/misc/runbench.py b/misc/runbench.py index a37124c5..b4eef634 100644 --- a/misc/runbench.py +++ b/misc/runbench.py @@ -234,7 +234,7 @@ def make_pylibmc_client(servers, **kw): ), Participant(name='python-memcached', factory=lambda: Prefix(__import__('memcache').Client(servers), 'memcache1')), Participant( - name='libmc(md6 / ketama / nodelay / nonblocking, from douban)', + name='libmc(md5 / ketama / nodelay / nonblocking, from douban)', factory=lambda: Prefix(__import__('libmc').Client(servers, comp_threshold=4000), 'libmc1') ), Participant(