Virtualenv - projects using different versions of modules
Install
Python 3.6
-
sudo add-apt-repository ppa:deadsnakes/ppa
-
sudo apt-get update
-
sudo apt-get install python3.6
-
sudo curl https://bootstrap.pypa.io/get-pip.py | sudo python3.6
Update line depending on available:
-
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
-
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
-
sudo update-alternatives --config python3
-
sudo pip3 install virtualenv virtualenvwrapper
add the following to the end of ~/.bashrc
-
# ADDED RJM for virtualenv
-
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
-
export WORKON_HOME=~/virtualenvs
-
source /usr/local/bin/virtualenvwrapper.sh
Setup new project
-
mkvirtualenv dockJob
Work on project
-
workon dockJob
Deactivate
-
deactivate
Other notes
I have had to install nose and rednose in virtualenvs because they refer to python and were leaving the virtualenv
I had problem with depdancies that was caused by modules not specfying the version of pytz required. To resolve I had to remove than manually install the one I wanted.
-
sudo pip install -r ./src/requirments.txt
Ref:
http://exponential.io/blog/2015/02/10/install-virtualenv-and-virtualenv…
http://docs.python-guide.org/en/latest/dev/virtualenvs/
pip check version
-
pip show modulename
Simple web server
Used for SOA Component Viewer
-
python -m http.server 8000
Python3 might be a different executable:
-
python3 -m http.server 8000
Running individual unit test
In my superclass put:
-
from nose.plugins.attrib import attr
-
def wipd(f):
-
return attr('wip')(f)
Import wipd from the class
for tests to be run add annotation:
-
@wipd
-
def test_basicTest(self):
-
self.assertFalse(True)
Also works against class
-
@wipd
-
class test_objectStoresTenantAware(local_helpers):
-
-
def test_basicTest(self):
-
self.assertFalse(True)
continous test script looks like:
-
#!/bin/bash
-
-
echo 'To test one file pass filename as first param'
-
echo 'e.g. sudo ./continous_test.sh test_JobExecution.py'
-
-
if [ $# -eq 0 ]; then
-
until ack -f --python ./object_store_abstraction ./tests | entr -d nosetests --rednose ./tests; do sleep 1; done
-
else
-
echo "Only testing tagged - ${1}"
-
until ack -f --python ./object_store_abstraction ./tests | entr -d nosetests --rednose -a ${1}; do sleep 1; done
-
fi
and can be run
./continous_test wpi