Skip to content

Commit

Permalink
Move to poetry.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dunn committed Apr 9, 2024
1 parent f60e1a4 commit 1f9712e
Show file tree
Hide file tree
Showing 35 changed files with 2,371 additions and 1,298 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ repos:
# Errors
- "--select=PLE"
- "--select=F"
- "--select=E"
# Syntax error
- "--select=E999"
# Mostly have auto fixes available
Expand All @@ -105,12 +106,18 @@ repos:
- "--select=E714"
- "--select=E711"
- "--select=E713"
- "--select=FURB"

# Autofixable quote rules
- "--select=Q"
- "--select=E722"
# Fix bad escape sequence
- "--select=W605"
# Import
- "--select=I"
# Bandit
#- "--select=S"

# Run the formatter.
- id: ruff-format

Expand Down
38 changes: 4 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,6 @@ ${ROOT_DIR}/.isolated_venv: # Create the virtualenv in the project folder
update: # Fetch new code into this project folder
git pull

.PHONY: dev-make-venv
dev-make-venv: ${ROOT_DIR}/.venv ${ROOT_DIR}/.isolated_venv # Make the virtualenv in this project folder.
@echo "Making venv if not present"

.PHONY: dev-install
dev-install: dev-make-venv # Install Kaithem and all it's dependencies in the Venv.
@cd ${ROOT_DIR}
@.venv/bin/python -m pip install --upgrade -r requirements.txt
@.venv/bin/python -m pip install --editable .

.PHONY: dev-run
dev-run: # Run the kaithem app.
@cd ${ROOT_DIR}
@pw-jack .venv/bin/python -m kaithem

.PHONY: dev-run-isolated
dev-run-isolated: # Run the kaithem app.
@cd ${ROOT_DIR}
@pw-jack .isolated_venv/bin/python -m kaithem

.PHONY: dev-update-dependencies
dev-update-dependencies: dev-make-venv # Install latest version of dependencies into the venv. New versions might break something!
@cd ${ROOT_DIR}
@.isolated_venv/bin/python -m pip install --upgrade -r direct_dependencies.txt
@.isolated_venv/bin/python -m pip freeze -l > requirements.txt
# If kaithem itself installed here, avoid circular nonsense
@sed -i '/.*kaithem.*/d' ./requirements.txt
@.venv/bin/python -m pip install --force --upgrade -r requirements.txt



.PHONY: root-install-zrok
root-install-zrok: # Install or update Zrok for remote access
Expand All @@ -120,10 +90,10 @@ user-set-global-pipewire-conf:
@systemctl --user restart pipewire wireplumber

.PHONY: user-install-kaithem
user-install-kaithem: # Install kaithem to run as your user. Note that it only runs when you are logged in.
user-start-kaithem-at-boot: # Install kaithem to run as your user. Note that it only runs when you are logged in.
@cd ${ROOT_DIR}
@echo "Kaithem will be installed to /home/${USER}/kaithem/.venv"
@bash ./scripts/install-kaithem.sh
@echo "Kaithem will be installed with a systemd user service."
@bash ./scripts/install-kaithem-service.sh

.PHONY: user-max-volume-at-boot
user-max-volume-at-boot: #Install a service that sets the max volume when you log in.
Expand All @@ -150,7 +120,7 @@ user-kaithem-status: # Get the status of the running kaithem instance

.PHONY: root-install-system-dependencies
root-install-system-dependencies: # Install non-python libraries using apt
@sudo apt install python3-virtualenv scrot mpv lm-sensors python3-netifaces python3-gst-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-bad swh-plugins tap-plugins caps gstreamer1.0-plugins-ugly fluidsynth libfluidsynth3 gstreamer1.0-pocketsphinx x42-plugins gstreamer1.0-opencv gstreamer1.0-vaapi python3-opencv gstreamer1.0-pipewire
@sudo apt install python3-virtualenv pipx scrot mpv lm-sensors python3-netifaces python3-gst-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-bad swh-plugins tap-plugins caps gstreamer1.0-plugins-ugly fluidsynth libfluidsynth3 gstreamer1.0-pocketsphinx x42-plugins gstreamer1.0-opencv gstreamer1.0-vaapi python3-opencv gstreamer1.0-pipewire

.PHONY: root-use-pipewire-jack
root-use-pipewire-jack: # Make JACK clients work with pipewire
Expand Down
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
![Makefile Badge](badges/makefile.png)
![Ten Year Project](badges/ten-years.png)
![Pytest](badges/pytest.png)
![Ruff](badges/ruff.png)
![Poetry](badges/poetry.png)

Kaithem is Linux home/commercial automation server written in pure Python(3.10 and up). Not tested outside of Linux. Resource usage is low enough to run well on the Raspberry Pi.

Expand All @@ -30,6 +32,8 @@ cd KaithemAutomation
Now you have the repo cloned, all the relevant commands are in the Makefile.
This is an interpreted package, but we use Make anyway to keep commands in one handy place.

NOTE: Formerly, the makefile would use a script to create a virtual environment, now we let pipx
handle it all.

### Install system packages

Expand All @@ -42,15 +46,27 @@ make root-install-system-dependencies


### Install kaithem in the project folder virtualenv

Now that you have the system dependencies, you should have pipx from your package manager.

```bash
# Show the menu of Kaithem commands
make help

# Grab Pip dependencies and install into this cloned project folder
make dev-install
# Kaithem now uses Poetry as a Python builder
pipx install poetry

# This line tells Poetry that Kaithem should use your
# globally installed system packages. This is important
# Because GStreamer is normally installed that way

poetry config virtualenvs.options.system-site-packages true --local

# If you already have a .venv in your folder, it
# May be best to start over.
poetry install -v

# Poetry will run it in the virtualenv
poetry run python dev_run.py

# Run the file(Launches dev_run in a virtualenv)
make dev-run
```

Then visit http://localhost:8002 and log in with your normal Linux username and password.
Expand Down
Binary file added badges/poetry.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 0 additions & 122 deletions default.nix

This file was deleted.

0 comments on commit 1f9712e

Please sign in to comment.