The following steps are the initial instructions to clone the codebase locally and setup a virtualenv. Note that these are taken from the wlanpi-chat-bot package, but apply to any of the wlanpi python based packages.
- Clone repo:
git clone https://WLAN-Pi/wlanpi-chat-bot.git && cd wlanpi-chat-bot
- Create virtualenv:
python3 -m venv venv
- Activate venv:
source venv/bin/activate
- Update pip, setuptool, and wheel (this is only done once)
pip install -U pip setuptools wheel
- Install requirements
pip install -r requirements.txt
Ok, now should be read to run the code. This version of the chat-bot is packaged into a module. So, we need to instruction Python to run it as a module with the -m
option.
- If developing on a WLAN Pi that is already running wlanpi-chat-bot, stop the servie before running up our development instance
sudo systemctl stop wlanpi-chat-bot
# check it stopped
sudo systemctl status wlanpi-chat-bot
- We need to run chat-bot as sudo, which means we'll need to pass along the location of the Python environment to sudo like this:
sudo venv/bin/python3 -m chatbot
If you'd like to run chat-bot in debug mode for testing, run with the "--debug" option:
sudo venv/bin/python3 -m chatbot --debug
If you'd like to pass your chat-bot app token for testing, pass it in via the "--bot_token" option:
sudo venv/bin/python3 -m chatbot --bot_token
Further reading on executing modules with Python at https://docs.python.org/3/library/runpy.html.
New environment?
cd <root of repo>
python3 -m venv venv
source venv/bin/activate
pip install -U pip setuptools wheel
pip install -r requirements.txt
sudo systemctl stop wlanpi-chat-bot
sudo systemctl status wlanpi-chat-bot
sudo venv/bin/python3 -m chatbot
Is your development environment already setup?
cd <root of repo>
source venv/bin/activate
sudo systemctl stop wlanpi-chat-bot
sudo systemctl status wlanpi-chat-bot
sudo venv/bin/python3 -m chatbot