Skip to content

Commit

Permalink
debugging conviences
Browse files Browse the repository at this point in the history
  • Loading branch information
kentslaney committed Jan 23, 2024
1 parent 340a8e5 commit f7964e5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions misc/git/debug.patch
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"],
Expand All @@ -96,3 +96,6 @@ index c9807b9..b3a915b 100644
tests_require=[
"pytest",
"future",
- "numpy",
+ #"numpy",
])
32 changes: 22 additions & 10 deletions misc/memcached_server
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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} <port>\n' "$prog"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion misc/runbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f7964e5

Please sign in to comment.