diff options
author | Bernhard M. Wiedemann <bwiedemann@suse.de> | 2018-05-26 04:28:33 +0200 |
---|---|---|
committer | Bernhard M. Wiedemann <bwiedemann@suse.de> | 2018-05-27 05:00:58 +0200 |
commit | 542fed8979766904214c0e3fc0580319ced4f6b6 (patch) | |
tree | 1ffe670f1dc4fbe279d6f3cdafee26deaa09d7ee /numpy/distutils | |
parent | 69503ff29819727df6d81847e6646c5fe8dc1a95 (diff) | |
download | numpy-542fed8979766904214c0e3fc0580319ced4f6b6.tar.gz |
Sort input file list
so that the python-scikit-learn openSUSE package
that uses config.add_extension(name, "path/to/*.cpp", ...)
builds in a reproducible way
in spite of indeterministic filesystem readdir order
and http://bugs.python.org/issue30461
See https://reproducible-builds.org/ for why this is good.
Diffstat (limited to 'numpy/distutils')
-rw-r--r-- | numpy/distutils/misc_util.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index cb7414a04..41f0b1f61 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -256,6 +256,11 @@ def minrelpath(path): return '' return os.sep.join(l) +def sorted_glob(fileglob): + """sorts output of python glob for http://bugs.python.org/issue30461 + to allow extensions to have reproducible build results""" + return sorted(glob.glob(fileglob)) + def _fix_paths(paths, local_path, include_non_existing): assert is_sequence(paths), repr(type(paths)) new_paths = [] @@ -263,8 +268,8 @@ def _fix_paths(paths, local_path, include_non_existing): for n in paths: if is_string(n): if '*' in n or '?' in n: - p = glob.glob(n) - p2 = glob.glob(njoin(local_path, n)) + p = sorted_glob(n) + p2 = sorted_glob(njoin(local_path, n)) if p2: new_paths.extend(p2) elif p: @@ -528,7 +533,7 @@ def _get_headers(directory_list): # get *.h files from list of directories headers = [] for d in directory_list: - head = glob.glob(os.path.join(d, "*.h")) #XXX: *.hpp files?? + head = sorted_glob(os.path.join(d, "*.h")) #XXX: *.hpp files?? headers.extend(head) return headers @@ -882,7 +887,7 @@ class Configuration(object): caller_level = 1): l = subpackage_name.split('.') subpackage_path = njoin([self.local_path]+l) - dirs = [_m for _m in glob.glob(subpackage_path) if os.path.isdir(_m)] + dirs = [_m for _m in sorted_glob(subpackage_path) if os.path.isdir(_m)] config_list = [] for d in dirs: if not os.path.isfile(njoin(d, '__init__.py')): |