From b030d8fc113736b479e84246b6b36d5f698a2da3 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 19 Jan 2016 15:55:52 +0700 Subject: [PATCH] ceph-detect-init: make all must setup.py install When make all runs in the ceph-detect-init module, it does a "setup.py build" which is not used. Replace it with a python setup.py install in a virtualenv so that tests can add the virtualenv/bin to their PATH and call ceph-detect-init from sources as they would if it was installed. Part of run-tox.sh is moved to tools/setup-virtualenv.sh so that it can be re-used by ceph-disk and other python modules. Signed-off-by: Loic Dachary --- src/ceph-detect-init/.gitignore | 2 +- src/ceph-detect-init/Makefile.am | 8 +++++--- src/ceph-detect-init/run-tox.sh | 18 ++++-------------- src/ceph-disk/tests/ceph-disk.sh | 16 +++------------- src/tools/Makefile.am | 2 ++ src/tools/setup-virtualenv.sh | 31 +++++++++++++++++++++++++++++++ 6 files changed, 46 insertions(+), 31 deletions(-) create mode 100755 src/tools/setup-virtualenv.sh diff --git a/src/ceph-detect-init/.gitignore b/src/ceph-detect-init/.gitignore index 0b4b8149360ff..dfb9bc7b56781 100644 --- a/src/ceph-detect-init/.gitignore +++ b/src/ceph-detect-init/.gitignore @@ -6,7 +6,7 @@ *.egg-info *.egg dist -build +virtualenv wheelhouse* *.log *.trs diff --git a/src/ceph-detect-init/Makefile.am b/src/ceph-detect-init/Makefile.am index 932f7555aaad7..45196a54b8807 100644 --- a/src/ceph-detect-init/Makefile.am +++ b/src/ceph-detect-init/Makefile.am @@ -53,11 +53,13 @@ EXTRA_DIST += \ ceph-detect-init/tests/test_all.py \ ceph-detect-init/tox.ini -ceph-detect-init-all: - cd $(srcdir)/ceph-detect-init ; python setup.py build +ceph-detect-init-all: ceph-detect-init/virtualenv + +ceph-detect-init/virtualenv: + cd $(srcdir)/ceph-detect-init ; ../tools/setup-virtualenv.sh ; virtualenv/bin/python setup.py develop ceph-detect-init-clean: - cd $(srcdir)/ceph-detect-init ; python setup.py clean ; rm -fr wheelhouse .tox build .coverage *.egg-info + cd $(srcdir)/ceph-detect-init ; python setup.py clean ; rm -fr wheelhouse .tox virtualenv .coverage *.egg-info ceph-detect-init-install-data: cd $(srcdir)/ceph-detect-init ; \ diff --git a/src/ceph-detect-init/run-tox.sh b/src/ceph-detect-init/run-tox.sh index 206938e287677..6a8e0735d5550 100755 --- a/src/ceph-detect-init/run-tox.sh +++ b/src/ceph-detect-init/run-tox.sh @@ -1,7 +1,7 @@ #!/bin/bash # # Copyright (C) 2015 SUSE LINUX GmbH -# Copyright (C) 2015 +# Copyright (C) 2016 # # Author: Owen Synge # Author: Loic Dachary @@ -19,18 +19,8 @@ # run from the ceph-detect-init directory or from its parent test -d ceph-detect-init && cd ceph-detect-init -trap "rm -fr make-check" EXIT -virtualenv make-check -. make-check/bin/activate -# older versions of pip will not install wrap_console scripts -# when using wheel packages -pip --log make-check/log.txt install --upgrade 'pip >= 6.1' -if test -d wheelhouse ; then - export NO_INDEX=--no-index -fi -pip --log make-check/log.txt install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse --upgrade distribute -pip --log make-check/log.txt install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse 'tox >=1.9' -tox > make-check/tox.out 2>&1 +source virtualenv/bin/activate +tox > virtualenv/tox.out 2>&1 status=$? -grep -v InterpreterNotFound < make-check/tox.out +grep -v InterpreterNotFound < virtualenv/tox.out exit $status diff --git a/src/ceph-disk/tests/ceph-disk.sh b/src/ceph-disk/tests/ceph-disk.sh index 7732a73eb51c7..f00432afbd71d 100644 --- a/src/ceph-disk/tests/ceph-disk.sh +++ b/src/ceph-disk/tests/ceph-disk.sh @@ -36,19 +36,9 @@ function teardown_btrfs() { PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' export PATH=..:.:$PATH # make sure program from sources are prefered +export PATH=../ceph-detect-init/virtualenv/bin:$PATH +export PATH=virtualenv/bin:$PATH DIR=test-ceph-disk -if virtualenv virtualenv-$DIR && test -d ceph-detect-init ; then - . virtualenv-$DIR/bin/activate - ( - # older versions of pip will not install wrap_console scripts - # when using wheel packages - pip install --upgrade 'pip >= 6.1' - if test -d ceph-detect-init/wheelhouse ; then - wheelhouse="--no-index --use-wheel --find-links=ceph-detect-init/wheelhouse" - fi - pip --log virtualenv-$DIR/log.txt install $wheelhouse --editable ceph-detect-init - ) -fi : ${CEPH_DISK:=ceph-disk} OSD_DATA=$DIR/osd MON_ID=a @@ -200,7 +190,7 @@ function test_path() { } function test_no_path() { - ( export PATH=..:${VIRTUAL_ENV}/bin:/usr/bin:/bin ; test_activate_dir ) || return 1 + ( export PATH=../ceph-detect-init/virtualenv/bin:virtualenv/bin:..:/usr/bin:/bin ; test_activate_dir ) || return 1 } function test_mark_init() { diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am index e14f3f8e8b294..0976bee5361ab 100644 --- a/src/tools/Makefile.am +++ b/src/tools/Makefile.am @@ -45,3 +45,5 @@ noinst_HEADERS += \ tools/rados/PoolDump.h \ tools/cephfs/DataScan.h +EXTRA_DIST += \ + tools/setup-virtualenv.sh diff --git a/src/tools/setup-virtualenv.sh b/src/tools/setup-virtualenv.sh new file mode 100755 index 0000000000000..f1c3f9ac852ed --- /dev/null +++ b/src/tools/setup-virtualenv.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Copyright (C) 2016 +# +# Author: Loic Dachary +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library Public License for more details. +# + +rm -fr virtualenv +virtualenv virtualenv +. virtualenv/bin/activate +# older versions of pip will not install wrap_console scripts +# when using wheel packages +pip --log virtualenv/log.txt install --upgrade 'pip >= 6.1' +if test -d wheelhouse ; then + export NO_INDEX=--no-index +fi +pip --log virtualenv/log.txt install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse --upgrade distribute +pip --log virtualenv/log.txt install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse 'tox >=1.9' +if test -f requirements.txt ; then + pip --log virtualenv/log.txt install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse -r requirements.txt +fi -- 2.39.5