Skip to content

Commit 8cb42d8

Browse files
author
Patrick Lenihan
committed
Switched to using Poetry script
1 parent 9f526fa commit 8cb42d8

File tree

5 files changed

+56
-65
lines changed

5 files changed

+56
-65
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

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

76
DESTDIR :=
87
ifeq ($(SUDO_USER),)
@@ -23,6 +22,7 @@ endif
2322

2423
aw-server: set-version aw-webui
2524
cargo build $(cargoflag) --bin aw-server
25+
poetry install
2626

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

110110
clean:
111-
python scripts/copy_rust_binaries.py --clean target/$(targetdir)
111+
rm -rf __pycache__ python/__pycache__
112112
cargo clean

poetry.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[tool.poetry]
2+
name = "aw-server-rust"
3+
version = "0.1.0"
4+
description = "Trayicon for ActivityWatch"
5+
authors = ["Erik Bjäreholt <[email protected]>"]
6+
license = "MPL-2.0"
7+
package-mode = false
8+
include = ["python/aw_server_rust.py"] # Explicitly include the script
9+
10+
[tool.poetry.scripts]
11+
aw-server-rust = "aw_server_rust:main"
12+
13+
[tool.poetry.dependencies]
14+
python = "^3.8"
15+
16+
[build-system]
17+
requires = ["poetry-core"]
18+
build-backend = "poetry.core.masonry.api"

python/aw_server_rust.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import sys
3+
import subprocess
4+
import glob
5+
6+
def find_rust_binary():
7+
"""Finds the Rust binary in the target directory."""
8+
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9+
10+
if os.getenv("RELEASE", "") == "false":
11+
target = "debug"
12+
else:
13+
target = "release"
14+
15+
rust_binary = os.path.join(repo_root, "target", target, "aw-server")
16+
17+
if os.path.exists(rust_binary):
18+
return rust_binary
19+
20+
print(f"Error: Rust binary '{rust_binary}' not found. Did you run `cargo build --release`?", file=sys.stderr)
21+
sys.exit(1)
22+
23+
def main():
24+
"""Executes the Rust binary and forwards all arguments."""
25+
rust_binary = find_rust_binary()
26+
subprocess.run([rust_binary] + sys.argv[1:])
27+
28+
if __name__ == "__main__":
29+
main()

scripts/copy_rust_binaries.py

-63
This file was deleted.

0 commit comments

Comments
 (0)