From 0addcb74bdd05585e28063eea1cb21db10d0ff63 Mon Sep 17 00:00:00 2001 From: Peter Hodge Date: Sun, 21 Dec 2025 06:46:36 +1000 Subject: [PATCH 1/2] README: document how to use uv to manage virtual environments --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 3edc52a..bc1ee87 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,23 @@ # HOMELY https://homely.readthedocs.io/ + + +## Developing + +Homely's `pyproject.toml` is managed using uv. + +To create a virtualenv for development: + + uv venv [ -p some_python ] --seed path/to/virtualenv + source path/to/virtualenv/bin/activate + pip install --upgrade pip # this may be required on older versions of python like 3.10 + pip install -e . --group dev + +To quickly run tests: + + source path/to/virtualenv/bin/activate + pytest test/test_some_feature.py + + # NOTE: the virtualenv must be manually activated because of the way that some tests use + # subprocesses. From e6988580b30824cc2baeb688b2c76069c8cee162 Mon Sep 17 00:00:00 2001 From: Peter Hodge Date: Mon, 29 Dec 2025 16:33:16 +1000 Subject: [PATCH 2/2] Replace simplejson with stdlib json --- homely/_engine2.py | 7 +++---- homely/_utils.py | 9 ++++----- pyproject.toml | 1 - test/test_engine2.py | 9 ++++----- uv.lock | 8 -------- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/homely/_engine2.py b/homely/_engine2.py index 78373a6..a56879d 100644 --- a/homely/_engine2.py +++ b/homely/_engine2.py @@ -1,8 +1,7 @@ +import json import os from typing import Optional -import simplejson - from homely._errors import CleanupConflict, CleanupObstruction, HelperError from homely._ui import note, warn from homely._utils import (ENGINE2_CONFIG_PATH, FactConfig, RepoInfo, @@ -219,7 +218,7 @@ def __init__(self, cfgpath, quick=False): if os.path.isfile(cfgpath): with open(cfgpath, 'r') as f: raw = f.read() - data = simplejson.loads(raw) + data = json.loads(raw) if not isinstance(data, dict): raise Exception("Invalid json in %s" % cfgpath) for item in data.get('cleaners', []): @@ -251,7 +250,7 @@ def _savecfg(self): paths_postponed=list(self._postponed), paths_created=list(self._created), ) - dumped = simplejson.dumps(data, indent=' ' * 4) + dumped = json.dumps(data, indent=' ' * 4) with open(self._cfgpath, 'w') as f: f.write(dumped) diff --git a/homely/_utils.py b/homely/_utils.py index e1d25bf..c633030 100644 --- a/homely/_utils.py +++ b/homely/_utils.py @@ -1,4 +1,5 @@ import contextlib +import json import os import re import shutil @@ -11,8 +12,6 @@ from os.path import exists, join from typing import Union -import simplejson - from homely._asyncioutils import _runasync from homely._errors import JsonError from homely._vcs import Repo, fromdict @@ -219,9 +218,9 @@ def __init__(self): data = f.read() if not len(data): return - self.jsondata = simplejson.loads(data) + self.jsondata = json.loads(data) self.checkjson() - except simplejson.JSONDecodeError: + except json.JSONDecodeError: raise JsonError("%s does not contain valid JSON" % self.jsonpath) def checkjson(self): @@ -244,7 +243,7 @@ def writejson(self): if not os.path.exists(parentdir): os.makedirs(parentdir, mode=0o755) # write the config file now - dumped = simplejson.dumps(self.jsondata, indent=' ' * 4) + dumped = json.dumps(self.jsondata, indent=' ' * 4) with open(self.jsonpath, 'w') as f: f.write(dumped) diff --git a/pyproject.toml b/pyproject.toml index 619a208..f8b6a25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ version = "0.20.2" dependencies = [ "python-daemon==2.3.0", "requests==2.25.1", - "simplejson==3.17.2", "click==7.1.2", ] diff --git a/test/test_engine2.py b/test/test_engine2.py index 1402092..fe8f572 100644 --- a/test/test_engine2.py +++ b/test/test_engine2.py @@ -1,8 +1,7 @@ +import json import os import sys -import simplejson - from homely._test import contents, gettmpfilepath @@ -583,14 +582,14 @@ def test_writefile_usage(tmpdir): data = {"z": [3, 4, 5, True], "y": "Hello world", "x": None} with writefile(f3) as f: if sys.version_info[0] < 3: - f.write(simplejson.dumps(data, ensure_ascii=False)) + f.write(json.dumps(data, ensure_ascii=False)) else: - f.write(simplejson.dumps(data)) + f.write(json.dumps(data)) e.cleanup(e.RAISE) del e assert os.path.exists(f3) with open(f3, 'r') as f: - assert simplejson.loads(f.read()) == data + assert json.loads(f.read()) == data # prove that the WriteFile() disappearing results in the file being removed e = Engine(cfgpath) diff --git a/uv.lock b/uv.lock index d732903..44c0562 100644 --- a/uv.lock +++ b/uv.lock @@ -199,7 +199,6 @@ dependencies = [ { name = "click" }, { name = "python-daemon" }, { name = "requests" }, - { name = "simplejson" }, ] [package.dev-dependencies] @@ -218,7 +217,6 @@ requires-dist = [ { name = "click", specifier = "==7.1.2" }, { name = "python-daemon", specifier = "==2.3.0" }, { name = "requests", specifier = "==2.25.1" }, - { name = "simplejson", specifier = "==3.17.2" }, ] [package.metadata.requires-dev] @@ -681,12 +679,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl", hash = "sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922", size = 1201486, upload-time = "2025-05-27T00:56:49.664Z" }, ] -[[package]] -name = "simplejson" -version = "3.17.2" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/49/45/a16db4f0fa383aaf0676fb7e3c660304fe390415c243f41a77c7f917d59b/simplejson-3.17.2.tar.gz", hash = "sha256:75ecc79f26d99222a084fbdd1ce5aad3ac3a8bd535cd9059528452da38b68841", size = 83210, upload-time = "2020-07-16T18:34:44.852Z" } - [[package]] name = "six" version = "1.17.0"