Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ chmod -R o=-x ~/Dropbox
- Fork and clone then cd to this git repository
- Install [mise](https://mise.jdx.dev/) if you don't have it: `curl https://mise.run | sh`
- Run `mise install` — installs the pinned toolchain (python, [uv](https://docs.astral.sh/uv/), and the [rite](https://github.com/clintmod/rite) task runner)
- If mise isn't [activated in your shell](https://mise.jdx.dev/getting-started.html#activate-mise), prefix the commands below with `mise exec --` (e.g. `mise exec -- rite setup`)
- Run `rite setup` — creates `.venv` and installs the dev dependencies from `uv.lock`

Run `rite` (no arguments) to list all available tasks.
Expand Down
8 changes: 5 additions & 3 deletions Ritefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tasks:
aliases: [t]
deps: [setup]
cmds:
- uv run pytest --cov=. --cov-report xml:cov.xml --cov-report term-missing
- uv run pytest --cov=src --cov-report xml:cov.xml --cov-report term-missing

test:watch:
desc: Re-run tests on file changes
Expand All @@ -46,7 +46,9 @@ tasks:
aliases: [l]
deps: [setup]
cmds:
- uv run pylint *.py
# src/macprefs is listed explicitly: it has no .py extension, so the
# glob misses it, but pylint lints any file passed by name.
- uv run pylint src/*.py src/macprefs tests/*.py

build:
desc: Build the brew package from committed HEAD, install, verify, uninstall
Expand All @@ -66,7 +68,7 @@ tasks:
aliases: [p]
deps: [test]
cmds:
- uv run python publish.py
- uv run python src/publish.py

teardown:
desc: Remove the local dev environment (counterpart to setup)
Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/brew-build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# the real install) unless FORCE=1 is set.
set -euo pipefail

VERSION=$(python3 -c "import version; print(version.__version__.lstrip('v'))")
VERSION=$(PYTHONPATH=src python3 -c "import version; print(version.__version__.lstrip('v'))")
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT

Expand Down
2 changes: 1 addition & 1 deletion macprefs.template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Macprefs < Formula
depends_on "python@3.13"

def install
libexec.install Dir["*"]
libexec.install Dir["src/*"]
bin.write_exec_script libexec/"macprefs"
end

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ package = false
[tool.pytest.ini_options]
addopts = "--maxfail=2 -s --tb=native -v -m 'not integration'"
markers = ["integration: integration tests"]
pythonpath = ["src"]
testpaths = ["tests"]

[tool.pylint.main]
jobs = 1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion macprefs → src/macprefs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def restore(choices=[]):

def invoke_func(args):
if args.func is not None:
if args.name == 'backup' or args.name == 'restore':
if args.name in ('backup', 'restore'):
args.func(args.t)
else:
args.func()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions test_macprefs.py → tests/test_macprefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import utils

# load as module
macprefs = utils.execute_module('macprefs', 'macprefs')
macprefs = utils.execute_module('macprefs', 'src/macprefs')

@patch('sys.stdout', new_callable=StringIO)
def test_invoke_help(mock_stdout):
try:
sys.argv = ['macprefs', '-h']
# invoke as script
utils.execute_module('__main__', 'macprefs')
utils.execute_module('__main__', 'src/macprefs')
assert False, 'expected SystemExit'
except SystemExit as e:
assert_correct_std_out(e, mock_stdout)
Expand Down Expand Up @@ -48,7 +48,7 @@ def test_invoke_no_args(mock_stdout):
try:
sys.argv = ['macprefs']
# invoke as script
utils.execute_module('__main__', 'macprefs')
utils.execute_module('__main__', 'src/macprefs')
assert False, 'expected SystemExit'
except SystemExit as e:
assert_correct_std_out(e, mock_stdout)
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_intergration():
try:
sys.argv = ['macprefs', 'backup']
# invoke as script
utils.execute_module('__main__', 'macprefs')
utils.execute_module('__main__', 'src/macprefs')
assert False, 'expected SystemExit'
except SystemExit as e:
assert e.code == 0
Expand All @@ -137,7 +137,7 @@ def test_restore_intergration():
try:
sys.argv = ['macprefs', 'restore']
# invoke as script
utils.execute_module('__main__', 'macprefs')
utils.execute_module('__main__', 'src/macprefs')
assert False, 'expected SystemExit'
except SystemExit as e:
assert e.code == 0 '''
File renamed without changes.
2 changes: 1 addition & 1 deletion test_publish.py → tests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_invoke_help():
old_argv = sys.argv
sys.argv = ['publish', '-test']
# invoke as script
utils.execute_module('__main__', 'publish.py')
utils.execute_module('__main__', 'src/publish.py')
sys.argv = old_argv


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading