diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30003bcf..d6f84152 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,16 @@ name: Build image, lint, and run tests -on: [push] +on: + push: + pull_request: + branches: ["master"] jobs: build: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: [3.12] steps: - uses: actions/checkout@v4 @@ -29,6 +32,32 @@ jobs: source .venv/bin/activate pytest + build_tmp: + runs-on: ubuntu-latest + steps: + - uses: pguyot/arm-runner-action@v2 + id: build_image + with: + base_image: https://downloads.raspberrypi.com/raspios_armhf/images/raspios_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf.img.xz + bootpartition: 1 + rootpartition: 2 + image_additional_mb: 4000 + commands: | + ls + + - name: Compress the release image + run: | + sudo fdisk -l + sudo ls /etc/xdg/autostart/ + mv ${{ steps.build_image.outputs.image }} go-note-go.img + xz -0 -T 0 -v go-note-go.img + - name: Upload release image + uses: actions/upload-artifact@v4 + with: + name: Release image + path: go-note-go.img.xz + + build_image: runs-on: ubuntu-latest steps: @@ -44,7 +73,9 @@ jobs: sudo apt update echo "Installing dependencies!" - sudo apt install -y git firefox-esr xvfb portaudio19-dev libatlas-base-dev redis-server espeak rustc python3-dev libopenblas-dev iptables iptables-persistent + sudo apt install -y git firefox-esr xvfb portaudio19-dev libatlas-base-dev redis-server \ + espeak rustc python3-dev libopenblas-dev iptables iptables-persistent cmake autoconf \ + build-essential gfortran echo "Installing Go Note Go!" mkdir -p /home/pi/code/github/dbieber @@ -55,15 +86,16 @@ jobs: git checkout $GITHUB_SHA echo "Setting up Python environment" - python3 -m venv env - ./env/bin/pip install -e . # Install Python dependencies + python3 -m venv .venv + ./.venv/bin/pip install uv + ./.venv/bin/python3 -m uv pip install -e . # Install Python dependencies echo "Start on boot" sudo cat /etc/rc.local sudo sed '/^exit 0/i \ sudo -u pi mkdir -p /home/pi/out \ bash /home/pi/code/github/dbieber/GoNoteGo/scripts/install_settings.sh \ - /home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf \ + /home/pi/code/github/dbieber/GoNoteGo/.venv/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf \ ' /etc/rc.local > ./rc.local.modified && sudo mv ./rc.local.modified /etc/rc.local sudo chmod +x /etc/rc.local @@ -233,15 +265,16 @@ jobs: cat /etc/dhcpcd.conf cat /etc/dnsmasq.conf python -m http.server + python3 -m http.server sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE sudo iptables -t nat -L sudo cat /etc/wpa_supplicant/wpa_supplicant.conf sudo nano /etc/wpa_supplicant/wpa_supplicant.conf nano /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings/secure_settings.py - /home/pi/code/github/dbieber/GoNoteGo/env/bin/python - /home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf - /home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisorctl -u go -p notego status - /home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisorctl -u go -p notego restart all + /home/pi/code/github/dbieber/GoNoteGo/.venv/bin/python + /home/pi/code/github/dbieber/GoNoteGo/.venv/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf + /home/pi/code/github/dbieber/GoNoteGo/.venv/bin/supervisorctl -u go -p notego status + /home/pi/code/github/dbieber/GoNoteGo/.venv/bin/supervisorctl -u go -p notego restart all cd /home/pi/code/github/dbieber/GoNoteGo/ EOF diff --git a/.gitignore b/.gitignore index 7ead14c9..2cc22e88 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ screenshot-*.png geckodriver.log scratch env +.venv tmp-say auth_url build diff --git a/gonotego/command_center/system_commands.py b/gonotego/command_center/system_commands.py index d423f0a7..a046ed3d 100644 --- a/gonotego/command_center/system_commands.py +++ b/gonotego/command_center/system_commands.py @@ -118,7 +118,7 @@ def update(): @register_command('restart') def restart(): - shell('./env/bin/supervisorctl -u go -p notego restart all') + shell('./.venv/bin/supervisorctl -u go -p notego restart all') @register_command('reboot') diff --git a/gonotego/supervisord.conf b/gonotego/supervisord.conf index 89783b6d..10c8ba75 100644 --- a/gonotego/supervisord.conf +++ b/gonotego/supervisord.conf @@ -23,33 +23,33 @@ username=go password=notego [program:GoNoteGo-audio-listener] -command=/home/pi/code/github/dbieber/GoNoteGo/env/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/audio/runner.py +command=/home/pi/code/github/dbieber/GoNoteGo/.venv/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/audio/runner.py directory=/home/pi user=root [program:GoNoteGo-command-center] environment=XDG_RUNTIME_DIR="/run/user/1000" -command=/home/pi/code/github/dbieber/GoNoteGo/env/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/command_center/runner.py +command=/home/pi/code/github/dbieber/GoNoteGo/.venv/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/command_center/runner.py directory=/home/pi user=pi [program:GoNoteGo-text-listener] -command=/home/pi/code/github/dbieber/GoNoteGo/env/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/text/runner.py +command=/home/pi/code/github/dbieber/GoNoteGo/.venv/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/text/runner.py directory=/home/pi user=root [program:GoNoteGo-transcription] environment=GOOGLE_APPLICATION_CREDENTIALS="/home/pi/secrets/google_credentials.json",LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 -command=/home/pi/code/github/dbieber/GoNoteGo/env/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/transcription/runner.py +command=/home/pi/code/github/dbieber/GoNoteGo/.venv/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/transcription/runner.py directory=/home/pi user=pi [program:GoNoteGo-uploader] -command=/home/pi/code/github/dbieber/GoNoteGo/env/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/uploader/runner.py +command=/home/pi/code/github/dbieber/GoNoteGo/.venv/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/uploader/runner.py directory=/home/pi user=pi [program:GoNoteGo-settings-server] -command=/home/pi/code/github/dbieber/GoNoteGo/env/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings_server/runner.py +command=/home/pi/code/github/dbieber/GoNoteGo/.venv/bin/python /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings_server/runner.py directory=/home/pi user=pi diff --git a/gonotego/uploader/blob/blob_uploader.py b/gonotego/uploader/blob/blob_uploader.py index 4f3325b6..d633d70e 100644 --- a/gonotego/uploader/blob/blob_uploader.py +++ b/gonotego/uploader/blob/blob_uploader.py @@ -20,5 +20,9 @@ def upload_blob(filepath, client): dropbox_path = f'/{filepath}' with open(filepath, 'rb') as f: unused_file_metadata = client.files_upload(f.read(), dropbox_path) # noqa - link_metadata = client.sharing_create_shared_link(dropbox_path) + try: + link_metadata = client.sharing_create_shared_link(dropbox_path) + except dropbox.exceptions.ApiError as e: + print(e) + return None return link_metadata.url.replace('www.', 'dl.').replace('?dl=0', '') diff --git a/installation.md b/installation.md index e9fb62bc..97784389 100644 --- a/installation.md +++ b/installation.md @@ -4,6 +4,8 @@ These instructions assume you're starting from a clean install of Raspbian, and that your Raspberry Pi is connected to an external monitor. Once you are set up, an external monitor will no longer be necessary. +Update 2024: Newer, better instructions are in the works. Stay tuned! + 1. Clone GoNoteGo ```bash @@ -39,9 +41,9 @@ sudo apt install firefox-esr xvfb portaudio19-dev libatlas-base-dev redis-server cd /home/pi/code/github/dbieber/GoNoteGo mkdir out pip3 install virtualenv -/home/pi/.local/bin/virtualenv env -p python3 -./env/bin/pip install grpcio -U --no-binary=grpcio -./env/bin/pip install -e . +/home/pi/.local/bin/virtualenv .venv -p python3 +./.venv/bin/pip install grpcio -U --no-binary=grpcio +./.venv/bin/pip install -e . ``` 5. Start on boot @@ -50,7 +52,7 @@ pip3 install virtualenv sudo nano /etc/rc.local ``` Add this line to rc.local: - `/home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf` + `/home/pi/code/github/dbieber/GoNoteGo/.venv/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf` 6. Install geckodriver to /usr/local/bin diff --git a/pyproject.toml b/pyproject.toml index 9094d1cf..17a30b29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,24 +19,24 @@ classifiers = [ ] dependencies = [ - 'absl-py', - 'apscheduler', - 'dropbox', - 'fire>=0.4.0', - 'flask', - 'keyboard', - 'numpy', - 'openai', - 'parsedatetime', - 'python-dateutil', - 'redis', + 'absl-py<=2.1.0', + 'apscheduler<=3.10.4', + 'dropbox<=12.0.2', + 'fire<=0.7.0', + 'flask<=3.0.3', + 'keyboard<=0.13.5', + 'numpy<=2.1.3', + # 'openai<=1.52.2', + 'parsedatetime<=2.6', + 'python-dateutil<=2.8.2', + 'redis<=4.3.4', # selenium 4.0 breaks with arm geckodriver. 'selenium==3.141.0', - 'setuptools-rust', - 'sounddevice', + 'setuptools-rust<=1.5.2', + 'sounddevice<=0.4.5', 'soundfile', - 'supervisor', - 'twython', + 'supervisor<=4.2.4', + 'twython<=3.9.1', "urllib3==1.26.16", # For compatibility with selenium==3.141.0 ] @@ -62,5 +62,5 @@ lint.ignore = ["E722"] exclude = ["scratch"] [build-system] -requires = ["setuptools>=43.0.0", "wheel"] +requires = ["setuptools>=43.0.0", "setuptools-rust", "wheel"] build-backend = "setuptools.build_meta"