From 0138ba59ac4047af92ad149ce7e5ddc0d9b417d9 Mon Sep 17 00:00:00 2001 From: "Andrii Doroshenko (Xrayez)" Date: Thu, 28 May 2020 16:48:19 +0300 Subject: [PATCH] SCons: use `OrderedDict` to ensure insertion order of modules The insertion order for dictionaries is only a language feature for Python 3.6/3.7+ implementations, and not prior to that. This ensures that the engine won't be rebuilt if the order of detected modules changes in any way, as the `OrderedDict` should guarantee inerstion order. --- SConstruct | 7 ++++--- methods.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 9e9298eaa75..5af851a9b28 100644 --- a/SConstruct +++ b/SConstruct @@ -7,6 +7,7 @@ import glob import os import pickle import sys +from collections import OrderedDict # Local import methods @@ -177,7 +178,7 @@ for k in platform_opts.keys(): opts.Add(o) # Detect modules. -modules_detected = {} +modules_detected = OrderedDict() module_search_paths = ["modules"] # Built-in path. if ARGUMENTS.get("custom_modules"): @@ -450,11 +451,11 @@ if selected_platform in platform_list: sys.path.remove(tmppath) sys.modules.pop('detect') - modules_enabled = {} + modules_enabled = OrderedDict() env.module_icons_paths = [] env.doc_class_path = {} - for name, path in sorted(modules_detected.items()): + for name, path in modules_detected.items(): if not env["module_" + name + "_enabled"]: continue sys.path.insert(0, path) diff --git a/methods.py b/methods.py index 56ead148e3b..fbcac799612 100644 --- a/methods.py +++ b/methods.py @@ -2,6 +2,7 @@ import os import re import glob import subprocess +from collections import OrderedDict from compat import iteritems, isbasestring, decode_utf8 @@ -131,7 +132,7 @@ def parse_cg_file(fname, uniforms, sizes, conditionals): def detect_modules(at_path): - module_list = {} # name : path + module_list = OrderedDict() # name : path modules_glob = os.path.join(at_path, "*") files = glob.glob(modules_glob)