Skip to content

Commit

Permalink
Switched to using Poetry script
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Lenihan committed Feb 3, 2025
1 parent 9f526fa commit 8cb42d8
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

all: build
build: aw-server aw-sync
python scripts/copy_rust_binaries.py target/$(targetdir)

DESTDIR :=
ifeq ($(SUDO_USER),)
Expand All @@ -23,6 +22,7 @@ endif

aw-server: set-version aw-webui
cargo build $(cargoflag) --bin aw-server
poetry install

aw-sync: set-version
cargo build $(cargoflag) --bin aw-sync
Expand Down Expand Up @@ -108,5 +108,5 @@ install:
install -m 644 aw-server.service $(DESTDIR)$(PREFIX)/lib/systemd/user/aw-server.service

clean:
python scripts/copy_rust_binaries.py --clean target/$(targetdir)
rm -rf __pycache__ python/__pycache__
cargo clean
7 changes: 7 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "aw-server-rust"
version = "0.1.0"
description = "Trayicon for ActivityWatch"
authors = ["Erik Bjäreholt <[email protected]>"]
license = "MPL-2.0"
package-mode = false
include = ["python/aw_server_rust.py"] # Explicitly include the script

[tool.poetry.scripts]
aw-server-rust = "aw_server_rust:main"

[tool.poetry.dependencies]
python = "^3.8"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
29 changes: 29 additions & 0 deletions python/aw_server_rust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
import sys
import subprocess
import glob

def find_rust_binary():
"""Finds the Rust binary in the target directory."""
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

if os.getenv("RELEASE", "") == "false":
target = "debug"
else:
target = "release"

rust_binary = os.path.join(repo_root, "target", target, "aw-server")

if os.path.exists(rust_binary):
return rust_binary

print(f"Error: Rust binary '{rust_binary}' not found. Did you run `cargo build --release`?", file=sys.stderr)
sys.exit(1)

def main():
"""Executes the Rust binary and forwards all arguments."""
rust_binary = find_rust_binary()
subprocess.run([rust_binary] + sys.argv[1:])

if __name__ == "__main__":
main()
63 changes: 0 additions & 63 deletions scripts/copy_rust_binaries.py

This file was deleted.

0 comments on commit 8cb42d8

Please sign in to comment.