summaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2025-05-05 03:43:14 +0100
committerGitHub <noreply@github.com>2025-05-05 03:43:14 +0100
commit614b631ee2649de67a830a39393af416acee58a8 (patch)
tree8d3b7b316ba3459519bc01a1104df4c279b398a4 /lib/python
parent5611a4006493eb0ec7cf815d4a7a24a671a16df6 (diff)
Ensure `qmk_userspace_paths` maintains detected order (#25204)
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/qmk/userspace.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/python/qmk/userspace.py b/lib/python/qmk/userspace.py
index 1c2a97f9c1..881490f796 100644
--- a/lib/python/qmk/userspace.py
+++ b/lib/python/qmk/userspace.py
@@ -12,29 +12,30 @@ from qmk.json_encoders import UserspaceJSONEncoder
12 12
13 13
14def qmk_userspace_paths(): 14def qmk_userspace_paths():
15 test_dirs = set() 15 test_dirs = []
16 16
17 # If we're already in a directory with a qmk.json and a keyboards or layouts directory, interpret it as userspace 17 # If we're already in a directory with a qmk.json and a keyboards or layouts directory, interpret it as userspace
18 if environ.get('ORIG_CWD') is not None: 18 if environ.get('ORIG_CWD') is not None:
19 current_dir = Path(environ['ORIG_CWD']) 19 current_dir = Path(environ['ORIG_CWD'])
20 while len(current_dir.parts) > 1: 20 while len(current_dir.parts) > 1:
21 if (current_dir / 'qmk.json').is_file(): 21 if (current_dir / 'qmk.json').is_file():
22 test_dirs.add(current_dir) 22 test_dirs.append(current_dir)
23 current_dir = current_dir.parent 23 current_dir = current_dir.parent
24 24
25 # If we have a QMK_USERSPACE environment variable, use that 25 # If we have a QMK_USERSPACE environment variable, use that
26 if environ.get('QMK_USERSPACE') is not None: 26 if environ.get('QMK_USERSPACE') is not None:
27 current_dir = Path(environ['QMK_USERSPACE']).expanduser() 27 current_dir = Path(environ['QMK_USERSPACE']).expanduser()
28 if current_dir.is_dir(): 28 if current_dir.is_dir():
29 test_dirs.add(current_dir) 29 test_dirs.append(current_dir)
30 30
31 # If someone has configured a directory, use that 31 # If someone has configured a directory, use that
32 if cli.config.user.overlay_dir is not None: 32 if cli.config.user.overlay_dir is not None:
33 current_dir = Path(cli.config.user.overlay_dir).expanduser().resolve() 33 current_dir = Path(cli.config.user.overlay_dir).expanduser().resolve()
34 if current_dir.is_dir(): 34 if current_dir.is_dir():
35 test_dirs.add(current_dir) 35 test_dirs.append(current_dir)
36 36
37 return list(test_dirs) 37 # remove duplicates while maintaining the current order
38 return list(dict.fromkeys(test_dirs))
38 39
39 40
40def qmk_userspace_validate(path): 41def qmk_userspace_validate(path):