TheHassanSaud commited on
Commit
f34b24f
·
1 Parent(s): 33e8f48

Upload folder using huggingface_hub (part 9)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +16 -0
  2. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/install_clib.py +40 -0
  3. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/install_data.py +24 -0
  4. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/install_headers.py +25 -0
  5. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/sdist.py +27 -0
  6. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/conv_template.py +329 -0
  7. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/core.py +215 -0
  8. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/cpuinfo.py +683 -0
  9. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/exec_command.py +315 -0
  10. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/extension.py +101 -0
  11. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/__init__.py +1035 -0
  12. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/absoft.py +156 -0
  13. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/arm.py +71 -0
  14. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/compaq.py +120 -0
  15. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/environment.py +88 -0
  16. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/fujitsu.py +46 -0
  17. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/g95.py +42 -0
  18. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/gnu.py +555 -0
  19. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/hpux.py +41 -0
  20. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/ibm.py +97 -0
  21. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/intel.py +211 -0
  22. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/lahey.py +45 -0
  23. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/mips.py +54 -0
  24. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/nag.py +87 -0
  25. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/none.py +28 -0
  26. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/nv.py +53 -0
  27. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/pathf95.py +33 -0
  28. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/pg.py +128 -0
  29. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/sun.py +51 -0
  30. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/vast.py +52 -0
  31. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/from_template.py +261 -0
  32. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fujitsuccompiler.py +28 -0
  33. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/intelccompiler.py +106 -0
  34. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/lib2def.py +116 -0
  35. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/line_endings.py +77 -0
  36. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/log.py +111 -0
  37. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/mingw/gfortran_vs2003_hack.c +6 -0
  38. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/mingw32ccompiler.py +597 -0
  39. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/misc_util.py +2484 -0
  40. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/msvc9compiler.py +63 -0
  41. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/msvccompiler.py +76 -0
  42. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/npy_pkg_config.py +441 -0
  43. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/numpy_distribution.py +17 -0
  44. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/pathccompiler.py +21 -0
  45. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/system_info.py +0 -0
  46. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/__init__.py +0 -0
  47. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_build_ext.py +74 -0
  48. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_ccompiler_opt.py +808 -0
  49. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_ccompiler_opt_conf.py +176 -0
  50. pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_exec_command.py +217 -0
.gitattributes CHANGED
@@ -989,3 +989,19 @@ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/_core/_multiarray_
989
  pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
990
  pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/_core/_simd.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
991
  pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/_core/lib/libnpymath.a filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
989
  pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
990
  pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/_core/_simd.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
991
  pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/_core/lib/libnpymath.a filter=lfs diff=lfs merge=lfs -text
992
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/f2py/__pycache__/crackfortran.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
993
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/fft/_pocketfft_umath.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
994
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/lib/__pycache__/_function_base_impl.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
995
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/lib/__pycache__/_npyio_impl.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
996
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/linalg/__pycache__/_linalg.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
997
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/linalg/_umath_linalg.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
998
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/ma/__pycache__/core.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
999
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/_bounded_integers.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1000
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/_common.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1001
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/_generator.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1002
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/_mt19937.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1003
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/_pcg64.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1004
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/_philox.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1005
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/bit_generator.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1006
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/random/mtrand.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1007
+ pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/testing/_private/__pycache__/utils.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/install_clib.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from distutils.core import Command
3
+ from distutils.ccompiler import new_compiler
4
+ from numpy.distutils.misc_util import get_cmd
5
+
6
+ class install_clib(Command):
7
+ description = "Command to install installable C libraries"
8
+
9
+ user_options = []
10
+
11
+ def initialize_options(self):
12
+ self.install_dir = None
13
+ self.outfiles = []
14
+
15
+ def finalize_options(self):
16
+ self.set_undefined_options('install', ('install_lib', 'install_dir'))
17
+
18
+ def run (self):
19
+ build_clib_cmd = get_cmd("build_clib")
20
+ if not build_clib_cmd.build_clib:
21
+ # can happen if the user specified `--skip-build`
22
+ build_clib_cmd.finalize_options()
23
+ build_dir = build_clib_cmd.build_clib
24
+
25
+ # We need the compiler to get the library name -> filename association
26
+ if not build_clib_cmd.compiler:
27
+ compiler = new_compiler(compiler=None)
28
+ compiler.customize(self.distribution)
29
+ else:
30
+ compiler = build_clib_cmd.compiler
31
+
32
+ for l in self.distribution.installed_libraries:
33
+ target_dir = os.path.join(self.install_dir, l.target_dir)
34
+ name = compiler.library_filename(l.name)
35
+ source = os.path.join(build_dir, name)
36
+ self.mkpath(target_dir)
37
+ self.outfiles.append(self.copy_file(source, target_dir)[0])
38
+
39
+ def get_outputs(self):
40
+ return self.outfiles
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/install_data.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ have_setuptools = ('setuptools' in sys.modules)
3
+
4
+ from distutils.command.install_data import install_data as old_install_data
5
+
6
+ #data installer with improved intelligence over distutils
7
+ #data files are copied into the project directory instead
8
+ #of willy-nilly
9
+ class install_data (old_install_data):
10
+
11
+ def run(self):
12
+ old_install_data.run(self)
13
+
14
+ if have_setuptools:
15
+ # Run install_clib again, since setuptools does not run sub-commands
16
+ # of install automatically
17
+ self.run_command('install_clib')
18
+
19
+ def finalize_options (self):
20
+ self.set_undefined_options('install',
21
+ ('install_lib', 'install_dir'),
22
+ ('root', 'root'),
23
+ ('force', 'force'),
24
+ )
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/install_headers.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from distutils.command.install_headers import install_headers as old_install_headers
3
+
4
+ class install_headers (old_install_headers):
5
+
6
+ def run (self):
7
+ headers = self.distribution.headers
8
+ if not headers:
9
+ return
10
+
11
+ prefix = os.path.dirname(self.install_dir)
12
+ for header in headers:
13
+ if isinstance(header, tuple):
14
+ # Kind of a hack, but I don't know where else to change this...
15
+ if header[0] == 'numpy._core':
16
+ header = ('numpy', header[1])
17
+ if os.path.splitext(header[1])[1] == '.inc':
18
+ continue
19
+ d = os.path.join(*([prefix]+header[0].split('.')))
20
+ header = header[1]
21
+ else:
22
+ d = self.install_dir
23
+ self.mkpath(d)
24
+ (out, _) = self.copy_file(header, d)
25
+ self.outfiles.append(out)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/command/sdist.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ if 'setuptools' in sys.modules:
3
+ from setuptools.command.sdist import sdist as old_sdist
4
+ else:
5
+ from distutils.command.sdist import sdist as old_sdist
6
+
7
+ from numpy.distutils.misc_util import get_data_files
8
+
9
+ class sdist(old_sdist):
10
+
11
+ def add_defaults (self):
12
+ old_sdist.add_defaults(self)
13
+
14
+ dist = self.distribution
15
+
16
+ if dist.has_data_files():
17
+ for data in dist.data_files:
18
+ self.filelist.extend(get_data_files(data))
19
+
20
+ if dist.has_headers():
21
+ headers = []
22
+ for h in dist.headers:
23
+ if isinstance(h, str): headers.append(h)
24
+ else: headers.append(h[1])
25
+ self.filelist.extend(headers)
26
+
27
+ return
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/conv_template.py ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ takes templated file .xxx.src and produces .xxx file where .xxx is
4
+ .i or .c or .h, using the following template rules
5
+
6
+ /**begin repeat -- on a line by itself marks the start of a repeated code
7
+ segment
8
+ /**end repeat**/ -- on a line by itself marks it's end
9
+
10
+ After the /**begin repeat and before the */, all the named templates are placed
11
+ these should all have the same number of replacements
12
+
13
+ Repeat blocks can be nested, with each nested block labeled with its depth,
14
+ i.e.
15
+ /**begin repeat1
16
+ *....
17
+ */
18
+ /**end repeat1**/
19
+
20
+ When using nested loops, you can optionally exclude particular
21
+ combinations of the variables using (inside the comment portion of the inner loop):
22
+
23
+ :exclude: var1=value1, var2=value2, ...
24
+
25
+ This will exclude the pattern where var1 is value1 and var2 is value2 when
26
+ the result is being generated.
27
+
28
+
29
+ In the main body each replace will use one entry from the list of named replacements
30
+
31
+ Note that all #..# forms in a block must have the same number of
32
+ comma-separated entries.
33
+
34
+ Example:
35
+
36
+ An input file containing
37
+
38
+ /**begin repeat
39
+ * #a = 1,2,3#
40
+ * #b = 1,2,3#
41
+ */
42
+
43
+ /**begin repeat1
44
+ * #c = ted, jim#
45
+ */
46
+ @a@, @b@, @c@
47
+ /**end repeat1**/
48
+
49
+ /**end repeat**/
50
+
51
+ produces
52
+
53
+ line 1 "template.c.src"
54
+
55
+ /*
56
+ *********************************************************************
57
+ ** This file was autogenerated from a template DO NOT EDIT!!**
58
+ ** Changes should be made to the original source (.src) file **
59
+ *********************************************************************
60
+ */
61
+
62
+ #line 9
63
+ 1, 1, ted
64
+
65
+ #line 9
66
+ 1, 1, jim
67
+
68
+ #line 9
69
+ 2, 2, ted
70
+
71
+ #line 9
72
+ 2, 2, jim
73
+
74
+ #line 9
75
+ 3, 3, ted
76
+
77
+ #line 9
78
+ 3, 3, jim
79
+
80
+ """
81
+
82
+ __all__ = ['process_str', 'process_file']
83
+
84
+ import os
85
+ import sys
86
+ import re
87
+
88
+ # names for replacement that are already global.
89
+ global_names = {}
90
+
91
+ # header placed at the front of head processed file
92
+ header =\
93
+ """
94
+ /*
95
+ *****************************************************************************
96
+ ** This file was autogenerated from a template DO NOT EDIT!!!! **
97
+ ** Changes should be made to the original source (.src) file **
98
+ *****************************************************************************
99
+ */
100
+
101
+ """
102
+ # Parse string for repeat loops
103
+ def parse_structure(astr, level):
104
+ """
105
+ The returned line number is from the beginning of the string, starting
106
+ at zero. Returns an empty list if no loops found.
107
+
108
+ """
109
+ if level == 0 :
110
+ loopbeg = "/**begin repeat"
111
+ loopend = "/**end repeat**/"
112
+ else :
113
+ loopbeg = "/**begin repeat%d" % level
114
+ loopend = "/**end repeat%d**/" % level
115
+
116
+ ind = 0
117
+ line = 0
118
+ spanlist = []
119
+ while True:
120
+ start = astr.find(loopbeg, ind)
121
+ if start == -1:
122
+ break
123
+ start2 = astr.find("*/", start)
124
+ start2 = astr.find("\n", start2)
125
+ fini1 = astr.find(loopend, start2)
126
+ fini2 = astr.find("\n", fini1)
127
+ line += astr.count("\n", ind, start2+1)
128
+ spanlist.append((start, start2+1, fini1, fini2+1, line))
129
+ line += astr.count("\n", start2+1, fini2)
130
+ ind = fini2
131
+ spanlist.sort()
132
+ return spanlist
133
+
134
+
135
+ def paren_repl(obj):
136
+ torep = obj.group(1)
137
+ numrep = obj.group(2)
138
+ return ','.join([torep]*int(numrep))
139
+
140
+ parenrep = re.compile(r"\(([^)]*)\)\*(\d+)")
141
+ plainrep = re.compile(r"([^*]+)\*(\d+)")
142
+ def parse_values(astr):
143
+ # replaces all occurrences of '(a,b,c)*4' in astr
144
+ # with 'a,b,c,a,b,c,a,b,c,a,b,c'. Empty braces generate
145
+ # empty values, i.e., ()*4 yields ',,,'. The result is
146
+ # split at ',' and a list of values returned.
147
+ astr = parenrep.sub(paren_repl, astr)
148
+ # replaces occurrences of xxx*3 with xxx, xxx, xxx
149
+ astr = ','.join([plainrep.sub(paren_repl, x.strip())
150
+ for x in astr.split(',')])
151
+ return astr.split(',')
152
+
153
+
154
+ stripast = re.compile(r"\n\s*\*?")
155
+ named_re = re.compile(r"#\s*(\w*)\s*=([^#]*)#")
156
+ exclude_vars_re = re.compile(r"(\w*)=(\w*)")
157
+ exclude_re = re.compile(":exclude:")
158
+ def parse_loop_header(loophead) :
159
+ """Find all named replacements in the header
160
+
161
+ Returns a list of dictionaries, one for each loop iteration,
162
+ where each key is a name to be substituted and the corresponding
163
+ value is the replacement string.
164
+
165
+ Also return a list of exclusions. The exclusions are dictionaries
166
+ of key value pairs. There can be more than one exclusion.
167
+ [{'var1':'value1', 'var2', 'value2'[,...]}, ...]
168
+
169
+ """
170
+ # Strip out '\n' and leading '*', if any, in continuation lines.
171
+ # This should not effect code previous to this change as
172
+ # continuation lines were not allowed.
173
+ loophead = stripast.sub("", loophead)
174
+ # parse out the names and lists of values
175
+ names = []
176
+ reps = named_re.findall(loophead)
177
+ nsub = None
178
+ for rep in reps:
179
+ name = rep[0]
180
+ vals = parse_values(rep[1])
181
+ size = len(vals)
182
+ if nsub is None :
183
+ nsub = size
184
+ elif nsub != size :
185
+ msg = "Mismatch in number of values, %d != %d\n%s = %s"
186
+ raise ValueError(msg % (nsub, size, name, vals))
187
+ names.append((name, vals))
188
+
189
+
190
+ # Find any exclude variables
191
+ excludes = []
192
+
193
+ for obj in exclude_re.finditer(loophead):
194
+ span = obj.span()
195
+ # find next newline
196
+ endline = loophead.find('\n', span[1])
197
+ substr = loophead[span[1]:endline]
198
+ ex_names = exclude_vars_re.findall(substr)
199
+ excludes.append(dict(ex_names))
200
+
201
+ # generate list of dictionaries, one for each template iteration
202
+ dlist = []
203
+ if nsub is None :
204
+ raise ValueError("No substitution variables found")
205
+ for i in range(nsub):
206
+ tmp = {name: vals[i] for name, vals in names}
207
+ dlist.append(tmp)
208
+ return dlist
209
+
210
+ replace_re = re.compile(r"@(\w+)@")
211
+ def parse_string(astr, env, level, line) :
212
+ lineno = "#line %d\n" % line
213
+
214
+ # local function for string replacement, uses env
215
+ def replace(match):
216
+ name = match.group(1)
217
+ try :
218
+ val = env[name]
219
+ except KeyError:
220
+ msg = 'line %d: no definition of key "%s"'%(line, name)
221
+ raise ValueError(msg) from None
222
+ return val
223
+
224
+ code = [lineno]
225
+ struct = parse_structure(astr, level)
226
+ if struct :
227
+ # recurse over inner loops
228
+ oldend = 0
229
+ newlevel = level + 1
230
+ for sub in struct:
231
+ pref = astr[oldend:sub[0]]
232
+ head = astr[sub[0]:sub[1]]
233
+ text = astr[sub[1]:sub[2]]
234
+ oldend = sub[3]
235
+ newline = line + sub[4]
236
+ code.append(replace_re.sub(replace, pref))
237
+ try :
238
+ envlist = parse_loop_header(head)
239
+ except ValueError as e:
240
+ msg = "line %d: %s" % (newline, e)
241
+ raise ValueError(msg)
242
+ for newenv in envlist :
243
+ newenv.update(env)
244
+ newcode = parse_string(text, newenv, newlevel, newline)
245
+ code.extend(newcode)
246
+ suff = astr[oldend:]
247
+ code.append(replace_re.sub(replace, suff))
248
+ else :
249
+ # replace keys
250
+ code.append(replace_re.sub(replace, astr))
251
+ code.append('\n')
252
+ return ''.join(code)
253
+
254
+ def process_str(astr):
255
+ code = [header]
256
+ code.extend(parse_string(astr, global_names, 0, 1))
257
+ return ''.join(code)
258
+
259
+
260
+ include_src_re = re.compile(r"(\n|\A)#include\s*['\"]"
261
+ r"(?P<name>[\w\d./\\]+[.]src)['\"]", re.I)
262
+
263
+ def resolve_includes(source):
264
+ d = os.path.dirname(source)
265
+ with open(source) as fid:
266
+ lines = []
267
+ for line in fid:
268
+ m = include_src_re.match(line)
269
+ if m:
270
+ fn = m.group('name')
271
+ if not os.path.isabs(fn):
272
+ fn = os.path.join(d, fn)
273
+ if os.path.isfile(fn):
274
+ lines.extend(resolve_includes(fn))
275
+ else:
276
+ lines.append(line)
277
+ else:
278
+ lines.append(line)
279
+ return lines
280
+
281
+ def process_file(source):
282
+ lines = resolve_includes(source)
283
+ sourcefile = os.path.normcase(source).replace("\\", "\\\\")
284
+ try:
285
+ code = process_str(''.join(lines))
286
+ except ValueError as e:
287
+ raise ValueError('In "%s" loop at %s' % (sourcefile, e)) from None
288
+ return '#line 1 "%s"\n%s' % (sourcefile, code)
289
+
290
+
291
+ def unique_key(adict):
292
+ # this obtains a unique key given a dictionary
293
+ # currently it works by appending together n of the letters of the
294
+ # current keys and increasing n until a unique key is found
295
+ # -- not particularly quick
296
+ allkeys = list(adict.keys())
297
+ done = False
298
+ n = 1
299
+ while not done:
300
+ newkey = "".join([x[:n] for x in allkeys])
301
+ if newkey in allkeys:
302
+ n += 1
303
+ else:
304
+ done = True
305
+ return newkey
306
+
307
+
308
+ def main():
309
+ try:
310
+ file = sys.argv[1]
311
+ except IndexError:
312
+ fid = sys.stdin
313
+ outfile = sys.stdout
314
+ else:
315
+ fid = open(file, 'r')
316
+ (base, ext) = os.path.splitext(file)
317
+ newname = base
318
+ outfile = open(newname, 'w')
319
+
320
+ allstr = fid.read()
321
+ try:
322
+ writestr = process_str(allstr)
323
+ except ValueError as e:
324
+ raise ValueError("In %s loop at %s" % (file, e)) from None
325
+
326
+ outfile.write(writestr)
327
+
328
+ if __name__ == "__main__":
329
+ main()
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/core.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from distutils.core import Distribution
3
+
4
+ if 'setuptools' in sys.modules:
5
+ have_setuptools = True
6
+ from setuptools import setup as old_setup
7
+ # easy_install imports math, it may be picked up from cwd
8
+ from setuptools.command import easy_install
9
+ try:
10
+ # very old versions of setuptools don't have this
11
+ from setuptools.command import bdist_egg
12
+ except ImportError:
13
+ have_setuptools = False
14
+ else:
15
+ from distutils.core import setup as old_setup
16
+ have_setuptools = False
17
+
18
+ import warnings
19
+ import distutils.core
20
+ import distutils.dist
21
+
22
+ from numpy.distutils.extension import Extension # noqa: F401
23
+ from numpy.distutils.numpy_distribution import NumpyDistribution
24
+ from numpy.distutils.command import config, config_compiler, \
25
+ build, build_py, build_ext, build_clib, build_src, build_scripts, \
26
+ sdist, install_data, install_headers, install, bdist_rpm, \
27
+ install_clib
28
+ from numpy.distutils.misc_util import is_sequence, is_string
29
+
30
+ numpy_cmdclass = {'build': build.build,
31
+ 'build_src': build_src.build_src,
32
+ 'build_scripts': build_scripts.build_scripts,
33
+ 'config_cc': config_compiler.config_cc,
34
+ 'config_fc': config_compiler.config_fc,
35
+ 'config': config.config,
36
+ 'build_ext': build_ext.build_ext,
37
+ 'build_py': build_py.build_py,
38
+ 'build_clib': build_clib.build_clib,
39
+ 'sdist': sdist.sdist,
40
+ 'install_data': install_data.install_data,
41
+ 'install_headers': install_headers.install_headers,
42
+ 'install_clib': install_clib.install_clib,
43
+ 'install': install.install,
44
+ 'bdist_rpm': bdist_rpm.bdist_rpm,
45
+ }
46
+ if have_setuptools:
47
+ # Use our own versions of develop and egg_info to ensure that build_src is
48
+ # handled appropriately.
49
+ from numpy.distutils.command import develop, egg_info
50
+ numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg
51
+ numpy_cmdclass['develop'] = develop.develop
52
+ numpy_cmdclass['easy_install'] = easy_install.easy_install
53
+ numpy_cmdclass['egg_info'] = egg_info.egg_info
54
+
55
+ def _dict_append(d, **kws):
56
+ for k, v in kws.items():
57
+ if k not in d:
58
+ d[k] = v
59
+ continue
60
+ dv = d[k]
61
+ if isinstance(dv, tuple):
62
+ d[k] = dv + tuple(v)
63
+ elif isinstance(dv, list):
64
+ d[k] = dv + list(v)
65
+ elif isinstance(dv, dict):
66
+ _dict_append(dv, **v)
67
+ elif is_string(dv):
68
+ d[k] = dv + v
69
+ else:
70
+ raise TypeError(repr(type(dv)))
71
+
72
+ def _command_line_ok(_cache=None):
73
+ """ Return True if command line does not contain any
74
+ help or display requests.
75
+ """
76
+ if _cache:
77
+ return _cache[0]
78
+ elif _cache is None:
79
+ _cache = []
80
+ ok = True
81
+ display_opts = ['--'+n for n in Distribution.display_option_names]
82
+ for o in Distribution.display_options:
83
+ if o[1]:
84
+ display_opts.append('-'+o[1])
85
+ for arg in sys.argv:
86
+ if arg.startswith('--help') or arg=='-h' or arg in display_opts:
87
+ ok = False
88
+ break
89
+ _cache.append(ok)
90
+ return ok
91
+
92
+ def get_distribution(always=False):
93
+ dist = distutils.core._setup_distribution
94
+ # XXX Hack to get numpy installable with easy_install.
95
+ # The problem is easy_install runs it's own setup(), which
96
+ # sets up distutils.core._setup_distribution. However,
97
+ # when our setup() runs, that gets overwritten and lost.
98
+ # We can't use isinstance, as the DistributionWithoutHelpCommands
99
+ # class is local to a function in setuptools.command.easy_install
100
+ if dist is not None and \
101
+ 'DistributionWithoutHelpCommands' in repr(dist):
102
+ dist = None
103
+ if always and dist is None:
104
+ dist = NumpyDistribution()
105
+ return dist
106
+
107
+ def setup(**attr):
108
+
109
+ cmdclass = numpy_cmdclass.copy()
110
+
111
+ new_attr = attr.copy()
112
+ if 'cmdclass' in new_attr:
113
+ cmdclass.update(new_attr['cmdclass'])
114
+ new_attr['cmdclass'] = cmdclass
115
+
116
+ if 'configuration' in new_attr:
117
+ # To avoid calling configuration if there are any errors
118
+ # or help request in command in the line.
119
+ configuration = new_attr.pop('configuration')
120
+
121
+ old_dist = distutils.core._setup_distribution
122
+ old_stop = distutils.core._setup_stop_after
123
+ distutils.core._setup_distribution = None
124
+ distutils.core._setup_stop_after = "commandline"
125
+ try:
126
+ dist = setup(**new_attr)
127
+ finally:
128
+ distutils.core._setup_distribution = old_dist
129
+ distutils.core._setup_stop_after = old_stop
130
+ if dist.help or not _command_line_ok():
131
+ # probably displayed help, skip running any commands
132
+ return dist
133
+
134
+ # create setup dictionary and append to new_attr
135
+ config = configuration()
136
+ if hasattr(config, 'todict'):
137
+ config = config.todict()
138
+ _dict_append(new_attr, **config)
139
+
140
+ # Move extension source libraries to libraries
141
+ libraries = []
142
+ for ext in new_attr.get('ext_modules', []):
143
+ new_libraries = []
144
+ for item in ext.libraries:
145
+ if is_sequence(item):
146
+ lib_name, build_info = item
147
+ _check_append_ext_library(libraries, lib_name, build_info)
148
+ new_libraries.append(lib_name)
149
+ elif is_string(item):
150
+ new_libraries.append(item)
151
+ else:
152
+ raise TypeError("invalid description of extension module "
153
+ "library %r" % (item,))
154
+ ext.libraries = new_libraries
155
+ if libraries:
156
+ if 'libraries' not in new_attr:
157
+ new_attr['libraries'] = []
158
+ for item in libraries:
159
+ _check_append_library(new_attr['libraries'], item)
160
+
161
+ # sources in ext_modules or libraries may contain header files
162
+ if ('ext_modules' in new_attr or 'libraries' in new_attr) \
163
+ and 'headers' not in new_attr:
164
+ new_attr['headers'] = []
165
+
166
+ # Use our custom NumpyDistribution class instead of distutils' one
167
+ new_attr['distclass'] = NumpyDistribution
168
+
169
+ return old_setup(**new_attr)
170
+
171
+ def _check_append_library(libraries, item):
172
+ for libitem in libraries:
173
+ if is_sequence(libitem):
174
+ if is_sequence(item):
175
+ if item[0]==libitem[0]:
176
+ if item[1] is libitem[1]:
177
+ return
178
+ warnings.warn("[0] libraries list contains %r with"
179
+ " different build_info" % (item[0],),
180
+ stacklevel=2)
181
+ break
182
+ else:
183
+ if item==libitem[0]:
184
+ warnings.warn("[1] libraries list contains %r with"
185
+ " no build_info" % (item[0],),
186
+ stacklevel=2)
187
+ break
188
+ else:
189
+ if is_sequence(item):
190
+ if item[0]==libitem:
191
+ warnings.warn("[2] libraries list contains %r with"
192
+ " no build_info" % (item[0],),
193
+ stacklevel=2)
194
+ break
195
+ else:
196
+ if item==libitem:
197
+ return
198
+ libraries.append(item)
199
+
200
+ def _check_append_ext_library(libraries, lib_name, build_info):
201
+ for item in libraries:
202
+ if is_sequence(item):
203
+ if item[0]==lib_name:
204
+ if item[1] is build_info:
205
+ return
206
+ warnings.warn("[3] libraries list contains %r with"
207
+ " different build_info" % (lib_name,),
208
+ stacklevel=2)
209
+ break
210
+ elif item==lib_name:
211
+ warnings.warn("[4] libraries list contains %r with"
212
+ " no build_info" % (lib_name,),
213
+ stacklevel=2)
214
+ break
215
+ libraries.append((lib_name, build_info))
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/cpuinfo.py ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ cpuinfo
4
+
5
+ Copyright 2002 Pearu Peterson all rights reserved,
6
+ Pearu Peterson <pearu@cens.ioc.ee>
7
+ Permission to use, modify, and distribute this software is given under the
8
+ terms of the NumPy (BSD style) license. See LICENSE.txt that came with
9
+ this distribution for specifics.
10
+
11
+ NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
12
+ Pearu Peterson
13
+
14
+ """
15
+ __all__ = ['cpu']
16
+
17
+ import os
18
+ import platform
19
+ import re
20
+ import sys
21
+ import types
22
+ import warnings
23
+
24
+ from subprocess import getstatusoutput
25
+
26
+
27
+ def getoutput(cmd, successful_status=(0,), stacklevel=1):
28
+ try:
29
+ status, output = getstatusoutput(cmd)
30
+ except OSError as e:
31
+ warnings.warn(str(e), UserWarning, stacklevel=stacklevel)
32
+ return False, ""
33
+ if os.WIFEXITED(status) and os.WEXITSTATUS(status) in successful_status:
34
+ return True, output
35
+ return False, output
36
+
37
+ def command_info(successful_status=(0,), stacklevel=1, **kw):
38
+ info = {}
39
+ for key in kw:
40
+ ok, output = getoutput(kw[key], successful_status=successful_status,
41
+ stacklevel=stacklevel+1)
42
+ if ok:
43
+ info[key] = output.strip()
44
+ return info
45
+
46
+ def command_by_line(cmd, successful_status=(0,), stacklevel=1):
47
+ ok, output = getoutput(cmd, successful_status=successful_status,
48
+ stacklevel=stacklevel+1)
49
+ if not ok:
50
+ return
51
+ for line in output.splitlines():
52
+ yield line.strip()
53
+
54
+ def key_value_from_command(cmd, sep, successful_status=(0,),
55
+ stacklevel=1):
56
+ d = {}
57
+ for line in command_by_line(cmd, successful_status=successful_status,
58
+ stacklevel=stacklevel+1):
59
+ l = [s.strip() for s in line.split(sep, 1)]
60
+ if len(l) == 2:
61
+ d[l[0]] = l[1]
62
+ return d
63
+
64
+ class CPUInfoBase:
65
+ """Holds CPU information and provides methods for requiring
66
+ the availability of various CPU features.
67
+ """
68
+
69
+ def _try_call(self, func):
70
+ try:
71
+ return func()
72
+ except Exception:
73
+ pass
74
+
75
+ def __getattr__(self, name):
76
+ if not name.startswith('_'):
77
+ if hasattr(self, '_'+name):
78
+ attr = getattr(self, '_'+name)
79
+ if isinstance(attr, types.MethodType):
80
+ return lambda func=self._try_call,attr=attr : func(attr)
81
+ else:
82
+ return lambda : None
83
+ raise AttributeError(name)
84
+
85
+ def _getNCPUs(self):
86
+ return 1
87
+
88
+ def __get_nbits(self):
89
+ abits = platform.architecture()[0]
90
+ nbits = re.compile(r'(\d+)bit').search(abits).group(1)
91
+ return nbits
92
+
93
+ def _is_32bit(self):
94
+ return self.__get_nbits() == '32'
95
+
96
+ def _is_64bit(self):
97
+ return self.__get_nbits() == '64'
98
+
99
+ class LinuxCPUInfo(CPUInfoBase):
100
+
101
+ info = None
102
+
103
+ def __init__(self):
104
+ if self.info is not None:
105
+ return
106
+ info = [ {} ]
107
+ ok, output = getoutput('uname -m')
108
+ if ok:
109
+ info[0]['uname_m'] = output.strip()
110
+ try:
111
+ fo = open('/proc/cpuinfo')
112
+ except OSError as e:
113
+ warnings.warn(str(e), UserWarning, stacklevel=2)
114
+ else:
115
+ for line in fo:
116
+ name_value = [s.strip() for s in line.split(':', 1)]
117
+ if len(name_value) != 2:
118
+ continue
119
+ name, value = name_value
120
+ if not info or name in info[-1]: # next processor
121
+ info.append({})
122
+ info[-1][name] = value
123
+ fo.close()
124
+ self.__class__.info = info
125
+
126
+ def _not_impl(self): pass
127
+
128
+ # Athlon
129
+
130
+ def _is_AMD(self):
131
+ return self.info[0]['vendor_id']=='AuthenticAMD'
132
+
133
+ def _is_AthlonK6_2(self):
134
+ return self._is_AMD() and self.info[0]['model'] == '2'
135
+
136
+ def _is_AthlonK6_3(self):
137
+ return self._is_AMD() and self.info[0]['model'] == '3'
138
+
139
+ def _is_AthlonK6(self):
140
+ return re.match(r'.*?AMD-K6', self.info[0]['model name']) is not None
141
+
142
+ def _is_AthlonK7(self):
143
+ return re.match(r'.*?AMD-K7', self.info[0]['model name']) is not None
144
+
145
+ def _is_AthlonMP(self):
146
+ return re.match(r'.*?Athlon\(tm\) MP\b',
147
+ self.info[0]['model name']) is not None
148
+
149
+ def _is_AMD64(self):
150
+ return self.is_AMD() and self.info[0]['family'] == '15'
151
+
152
+ def _is_Athlon64(self):
153
+ return re.match(r'.*?Athlon\(tm\) 64\b',
154
+ self.info[0]['model name']) is not None
155
+
156
+ def _is_AthlonHX(self):
157
+ return re.match(r'.*?Athlon HX\b',
158
+ self.info[0]['model name']) is not None
159
+
160
+ def _is_Opteron(self):
161
+ return re.match(r'.*?Opteron\b',
162
+ self.info[0]['model name']) is not None
163
+
164
+ def _is_Hammer(self):
165
+ return re.match(r'.*?Hammer\b',
166
+ self.info[0]['model name']) is not None
167
+
168
+ # Alpha
169
+
170
+ def _is_Alpha(self):
171
+ return self.info[0]['cpu']=='Alpha'
172
+
173
+ def _is_EV4(self):
174
+ return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'
175
+
176
+ def _is_EV5(self):
177
+ return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'
178
+
179
+ def _is_EV56(self):
180
+ return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'
181
+
182
+ def _is_PCA56(self):
183
+ return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'
184
+
185
+ # Intel
186
+
187
+ #XXX
188
+ _is_i386 = _not_impl
189
+
190
+ def _is_Intel(self):
191
+ return self.info[0]['vendor_id']=='GenuineIntel'
192
+
193
+ def _is_i486(self):
194
+ return self.info[0]['cpu']=='i486'
195
+
196
+ def _is_i586(self):
197
+ return self.is_Intel() and self.info[0]['cpu family'] == '5'
198
+
199
+ def _is_i686(self):
200
+ return self.is_Intel() and self.info[0]['cpu family'] == '6'
201
+
202
+ def _is_Celeron(self):
203
+ return re.match(r'.*?Celeron',
204
+ self.info[0]['model name']) is not None
205
+
206
+ def _is_Pentium(self):
207
+ return re.match(r'.*?Pentium',
208
+ self.info[0]['model name']) is not None
209
+
210
+ def _is_PentiumII(self):
211
+ return re.match(r'.*?Pentium.*?II\b',
212
+ self.info[0]['model name']) is not None
213
+
214
+ def _is_PentiumPro(self):
215
+ return re.match(r'.*?PentiumPro\b',
216
+ self.info[0]['model name']) is not None
217
+
218
+ def _is_PentiumMMX(self):
219
+ return re.match(r'.*?Pentium.*?MMX\b',
220
+ self.info[0]['model name']) is not None
221
+
222
+ def _is_PentiumIII(self):
223
+ return re.match(r'.*?Pentium.*?III\b',
224
+ self.info[0]['model name']) is not None
225
+
226
+ def _is_PentiumIV(self):
227
+ return re.match(r'.*?Pentium.*?(IV|4)\b',
228
+ self.info[0]['model name']) is not None
229
+
230
+ def _is_PentiumM(self):
231
+ return re.match(r'.*?Pentium.*?M\b',
232
+ self.info[0]['model name']) is not None
233
+
234
+ def _is_Prescott(self):
235
+ return self.is_PentiumIV() and self.has_sse3()
236
+
237
+ def _is_Nocona(self):
238
+ return (self.is_Intel()
239
+ and (self.info[0]['cpu family'] == '6'
240
+ or self.info[0]['cpu family'] == '15')
241
+ and (self.has_sse3() and not self.has_ssse3())
242
+ and re.match(r'.*?\blm\b', self.info[0]['flags']) is not None)
243
+
244
+ def _is_Core2(self):
245
+ return (self.is_64bit() and self.is_Intel() and
246
+ re.match(r'.*?Core\(TM\)2\b',
247
+ self.info[0]['model name']) is not None)
248
+
249
+ def _is_Itanium(self):
250
+ return re.match(r'.*?Itanium\b',
251
+ self.info[0]['family']) is not None
252
+
253
+ def _is_XEON(self):
254
+ return re.match(r'.*?XEON\b',
255
+ self.info[0]['model name'], re.IGNORECASE) is not None
256
+
257
+ _is_Xeon = _is_XEON
258
+
259
+ # Varia
260
+
261
+ def _is_singleCPU(self):
262
+ return len(self.info) == 1
263
+
264
+ def _getNCPUs(self):
265
+ return len(self.info)
266
+
267
+ def _has_fdiv_bug(self):
268
+ return self.info[0]['fdiv_bug']=='yes'
269
+
270
+ def _has_f00f_bug(self):
271
+ return self.info[0]['f00f_bug']=='yes'
272
+
273
+ def _has_mmx(self):
274
+ return re.match(r'.*?\bmmx\b', self.info[0]['flags']) is not None
275
+
276
+ def _has_sse(self):
277
+ return re.match(r'.*?\bsse\b', self.info[0]['flags']) is not None
278
+
279
+ def _has_sse2(self):
280
+ return re.match(r'.*?\bsse2\b', self.info[0]['flags']) is not None
281
+
282
+ def _has_sse3(self):
283
+ return re.match(r'.*?\bpni\b', self.info[0]['flags']) is not None
284
+
285
+ def _has_ssse3(self):
286
+ return re.match(r'.*?\bssse3\b', self.info[0]['flags']) is not None
287
+
288
+ def _has_3dnow(self):
289
+ return re.match(r'.*?\b3dnow\b', self.info[0]['flags']) is not None
290
+
291
+ def _has_3dnowext(self):
292
+ return re.match(r'.*?\b3dnowext\b', self.info[0]['flags']) is not None
293
+
294
+ class IRIXCPUInfo(CPUInfoBase):
295
+ info = None
296
+
297
+ def __init__(self):
298
+ if self.info is not None:
299
+ return
300
+ info = key_value_from_command('sysconf', sep=' ',
301
+ successful_status=(0, 1))
302
+ self.__class__.info = info
303
+
304
+ def _not_impl(self): pass
305
+
306
+ def _is_singleCPU(self):
307
+ return self.info.get('NUM_PROCESSORS') == '1'
308
+
309
+ def _getNCPUs(self):
310
+ return int(self.info.get('NUM_PROCESSORS', 1))
311
+
312
+ def __cputype(self, n):
313
+ return self.info.get('PROCESSORS').split()[0].lower() == 'r%s' % (n)
314
+ def _is_r2000(self): return self.__cputype(2000)
315
+ def _is_r3000(self): return self.__cputype(3000)
316
+ def _is_r3900(self): return self.__cputype(3900)
317
+ def _is_r4000(self): return self.__cputype(4000)
318
+ def _is_r4100(self): return self.__cputype(4100)
319
+ def _is_r4300(self): return self.__cputype(4300)
320
+ def _is_r4400(self): return self.__cputype(4400)
321
+ def _is_r4600(self): return self.__cputype(4600)
322
+ def _is_r4650(self): return self.__cputype(4650)
323
+ def _is_r5000(self): return self.__cputype(5000)
324
+ def _is_r6000(self): return self.__cputype(6000)
325
+ def _is_r8000(self): return self.__cputype(8000)
326
+ def _is_r10000(self): return self.__cputype(10000)
327
+ def _is_r12000(self): return self.__cputype(12000)
328
+ def _is_rorion(self): return self.__cputype('orion')
329
+
330
+ def get_ip(self):
331
+ try: return self.info.get('MACHINE')
332
+ except Exception: pass
333
+ def __machine(self, n):
334
+ return self.info.get('MACHINE').lower() == 'ip%s' % (n)
335
+ def _is_IP19(self): return self.__machine(19)
336
+ def _is_IP20(self): return self.__machine(20)
337
+ def _is_IP21(self): return self.__machine(21)
338
+ def _is_IP22(self): return self.__machine(22)
339
+ def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()
340
+ def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()
341
+ def _is_IP24(self): return self.__machine(24)
342
+ def _is_IP25(self): return self.__machine(25)
343
+ def _is_IP26(self): return self.__machine(26)
344
+ def _is_IP27(self): return self.__machine(27)
345
+ def _is_IP28(self): return self.__machine(28)
346
+ def _is_IP30(self): return self.__machine(30)
347
+ def _is_IP32(self): return self.__machine(32)
348
+ def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()
349
+ def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()
350
+
351
+
352
+ class DarwinCPUInfo(CPUInfoBase):
353
+ info = None
354
+
355
+ def __init__(self):
356
+ if self.info is not None:
357
+ return
358
+ info = command_info(arch='arch',
359
+ machine='machine')
360
+ info['sysctl_hw'] = key_value_from_command('sysctl hw', sep='=')
361
+ self.__class__.info = info
362
+
363
+ def _not_impl(self): pass
364
+
365
+ def _getNCPUs(self):
366
+ return int(self.info['sysctl_hw'].get('hw.ncpu', 1))
367
+
368
+ def _is_Power_Macintosh(self):
369
+ return self.info['sysctl_hw']['hw.machine']=='Power Macintosh'
370
+
371
+ def _is_i386(self):
372
+ return self.info['arch']=='i386'
373
+ def _is_ppc(self):
374
+ return self.info['arch']=='ppc'
375
+
376
+ def __machine(self, n):
377
+ return self.info['machine'] == 'ppc%s'%n
378
+ def _is_ppc601(self): return self.__machine(601)
379
+ def _is_ppc602(self): return self.__machine(602)
380
+ def _is_ppc603(self): return self.__machine(603)
381
+ def _is_ppc603e(self): return self.__machine('603e')
382
+ def _is_ppc604(self): return self.__machine(604)
383
+ def _is_ppc604e(self): return self.__machine('604e')
384
+ def _is_ppc620(self): return self.__machine(620)
385
+ def _is_ppc630(self): return self.__machine(630)
386
+ def _is_ppc740(self): return self.__machine(740)
387
+ def _is_ppc7400(self): return self.__machine(7400)
388
+ def _is_ppc7450(self): return self.__machine(7450)
389
+ def _is_ppc750(self): return self.__machine(750)
390
+ def _is_ppc403(self): return self.__machine(403)
391
+ def _is_ppc505(self): return self.__machine(505)
392
+ def _is_ppc801(self): return self.__machine(801)
393
+ def _is_ppc821(self): return self.__machine(821)
394
+ def _is_ppc823(self): return self.__machine(823)
395
+ def _is_ppc860(self): return self.__machine(860)
396
+
397
+
398
+ class SunOSCPUInfo(CPUInfoBase):
399
+
400
+ info = None
401
+
402
+ def __init__(self):
403
+ if self.info is not None:
404
+ return
405
+ info = command_info(arch='arch',
406
+ mach='mach',
407
+ uname_i='uname_i',
408
+ isainfo_b='isainfo -b',
409
+ isainfo_n='isainfo -n',
410
+ )
411
+ info['uname_X'] = key_value_from_command('uname -X', sep='=')
412
+ for line in command_by_line('psrinfo -v 0'):
413
+ m = re.match(r'\s*The (?P<p>[\w\d]+) processor operates at', line)
414
+ if m:
415
+ info['processor'] = m.group('p')
416
+ break
417
+ self.__class__.info = info
418
+
419
+ def _not_impl(self): pass
420
+
421
+ def _is_i386(self):
422
+ return self.info['isainfo_n']=='i386'
423
+ def _is_sparc(self):
424
+ return self.info['isainfo_n']=='sparc'
425
+ def _is_sparcv9(self):
426
+ return self.info['isainfo_n']=='sparcv9'
427
+
428
+ def _getNCPUs(self):
429
+ return int(self.info['uname_X'].get('NumCPU', 1))
430
+
431
+ def _is_sun4(self):
432
+ return self.info['arch']=='sun4'
433
+
434
+ def _is_SUNW(self):
435
+ return re.match(r'SUNW', self.info['uname_i']) is not None
436
+ def _is_sparcstation5(self):
437
+ return re.match(r'.*SPARCstation-5', self.info['uname_i']) is not None
438
+ def _is_ultra1(self):
439
+ return re.match(r'.*Ultra-1', self.info['uname_i']) is not None
440
+ def _is_ultra250(self):
441
+ return re.match(r'.*Ultra-250', self.info['uname_i']) is not None
442
+ def _is_ultra2(self):
443
+ return re.match(r'.*Ultra-2', self.info['uname_i']) is not None
444
+ def _is_ultra30(self):
445
+ return re.match(r'.*Ultra-30', self.info['uname_i']) is not None
446
+ def _is_ultra4(self):
447
+ return re.match(r'.*Ultra-4', self.info['uname_i']) is not None
448
+ def _is_ultra5_10(self):
449
+ return re.match(r'.*Ultra-5_10', self.info['uname_i']) is not None
450
+ def _is_ultra5(self):
451
+ return re.match(r'.*Ultra-5', self.info['uname_i']) is not None
452
+ def _is_ultra60(self):
453
+ return re.match(r'.*Ultra-60', self.info['uname_i']) is not None
454
+ def _is_ultra80(self):
455
+ return re.match(r'.*Ultra-80', self.info['uname_i']) is not None
456
+ def _is_ultraenterprice(self):
457
+ return re.match(r'.*Ultra-Enterprise', self.info['uname_i']) is not None
458
+ def _is_ultraenterprice10k(self):
459
+ return re.match(r'.*Ultra-Enterprise-10000', self.info['uname_i']) is not None
460
+ def _is_sunfire(self):
461
+ return re.match(r'.*Sun-Fire', self.info['uname_i']) is not None
462
+ def _is_ultra(self):
463
+ return re.match(r'.*Ultra', self.info['uname_i']) is not None
464
+
465
+ def _is_cpusparcv7(self):
466
+ return self.info['processor']=='sparcv7'
467
+ def _is_cpusparcv8(self):
468
+ return self.info['processor']=='sparcv8'
469
+ def _is_cpusparcv9(self):
470
+ return self.info['processor']=='sparcv9'
471
+
472
+ class Win32CPUInfo(CPUInfoBase):
473
+
474
+ info = None
475
+ pkey = r"HARDWARE\DESCRIPTION\System\CentralProcessor"
476
+ # XXX: what does the value of
477
+ # HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0
478
+ # mean?
479
+
480
+ def __init__(self):
481
+ if self.info is not None:
482
+ return
483
+ info = []
484
+ try:
485
+ #XXX: Bad style to use so long `try:...except:...`. Fix it!
486
+ import winreg
487
+
488
+ prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
489
+ r"\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
490
+ chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
491
+ pnum=0
492
+ while True:
493
+ try:
494
+ proc=winreg.EnumKey(chnd, pnum)
495
+ except winreg.error:
496
+ break
497
+ else:
498
+ pnum+=1
499
+ info.append({"Processor":proc})
500
+ phnd=winreg.OpenKey(chnd, proc)
501
+ pidx=0
502
+ while True:
503
+ try:
504
+ name, value, vtpe=winreg.EnumValue(phnd, pidx)
505
+ except winreg.error:
506
+ break
507
+ else:
508
+ pidx=pidx+1
509
+ info[-1][name]=value
510
+ if name=="Identifier":
511
+ srch=prgx.search(value)
512
+ if srch:
513
+ info[-1]["Family"]=int(srch.group("FML"))
514
+ info[-1]["Model"]=int(srch.group("MDL"))
515
+ info[-1]["Stepping"]=int(srch.group("STP"))
516
+ except Exception as e:
517
+ print(e, '(ignoring)')
518
+ self.__class__.info = info
519
+
520
+ def _not_impl(self): pass
521
+
522
+ # Athlon
523
+
524
+ def _is_AMD(self):
525
+ return self.info[0]['VendorIdentifier']=='AuthenticAMD'
526
+
527
+ def _is_Am486(self):
528
+ return self.is_AMD() and self.info[0]['Family']==4
529
+
530
+ def _is_Am5x86(self):
531
+ return self.is_AMD() and self.info[0]['Family']==4
532
+
533
+ def _is_AMDK5(self):
534
+ return self.is_AMD() and self.info[0]['Family']==5 \
535
+ and self.info[0]['Model'] in [0, 1, 2, 3]
536
+
537
+ def _is_AMDK6(self):
538
+ return self.is_AMD() and self.info[0]['Family']==5 \
539
+ and self.info[0]['Model'] in [6, 7]
540
+
541
+ def _is_AMDK6_2(self):
542
+ return self.is_AMD() and self.info[0]['Family']==5 \
543
+ and self.info[0]['Model']==8
544
+
545
+ def _is_AMDK6_3(self):
546
+ return self.is_AMD() and self.info[0]['Family']==5 \
547
+ and self.info[0]['Model']==9
548
+
549
+ def _is_AMDK7(self):
550
+ return self.is_AMD() and self.info[0]['Family'] == 6
551
+
552
+ # To reliably distinguish between the different types of AMD64 chips
553
+ # (Athlon64, Operton, Athlon64 X2, Semperon, Turion 64, etc.) would
554
+ # require looking at the 'brand' from cpuid
555
+
556
+ def _is_AMD64(self):
557
+ return self.is_AMD() and self.info[0]['Family'] == 15
558
+
559
+ # Intel
560
+
561
+ def _is_Intel(self):
562
+ return self.info[0]['VendorIdentifier']=='GenuineIntel'
563
+
564
+ def _is_i386(self):
565
+ return self.info[0]['Family']==3
566
+
567
+ def _is_i486(self):
568
+ return self.info[0]['Family']==4
569
+
570
+ def _is_i586(self):
571
+ return self.is_Intel() and self.info[0]['Family']==5
572
+
573
+ def _is_i686(self):
574
+ return self.is_Intel() and self.info[0]['Family']==6
575
+
576
+ def _is_Pentium(self):
577
+ return self.is_Intel() and self.info[0]['Family']==5
578
+
579
+ def _is_PentiumMMX(self):
580
+ return self.is_Intel() and self.info[0]['Family']==5 \
581
+ and self.info[0]['Model']==4
582
+
583
+ def _is_PentiumPro(self):
584
+ return self.is_Intel() and self.info[0]['Family']==6 \
585
+ and self.info[0]['Model']==1
586
+
587
+ def _is_PentiumII(self):
588
+ return self.is_Intel() and self.info[0]['Family']==6 \
589
+ and self.info[0]['Model'] in [3, 5, 6]
590
+
591
+ def _is_PentiumIII(self):
592
+ return self.is_Intel() and self.info[0]['Family']==6 \
593
+ and self.info[0]['Model'] in [7, 8, 9, 10, 11]
594
+
595
+ def _is_PentiumIV(self):
596
+ return self.is_Intel() and self.info[0]['Family']==15
597
+
598
+ def _is_PentiumM(self):
599
+ return self.is_Intel() and self.info[0]['Family'] == 6 \
600
+ and self.info[0]['Model'] in [9, 13, 14]
601
+
602
+ def _is_Core2(self):
603
+ return self.is_Intel() and self.info[0]['Family'] == 6 \
604
+ and self.info[0]['Model'] in [15, 16, 17]
605
+
606
+ # Varia
607
+
608
+ def _is_singleCPU(self):
609
+ return len(self.info) == 1
610
+
611
+ def _getNCPUs(self):
612
+ return len(self.info)
613
+
614
+ def _has_mmx(self):
615
+ if self.is_Intel():
616
+ return (self.info[0]['Family']==5 and self.info[0]['Model']==4) \
617
+ or (self.info[0]['Family'] in [6, 15])
618
+ elif self.is_AMD():
619
+ return self.info[0]['Family'] in [5, 6, 15]
620
+ else:
621
+ return False
622
+
623
+ def _has_sse(self):
624
+ if self.is_Intel():
625
+ return ((self.info[0]['Family']==6 and
626
+ self.info[0]['Model'] in [7, 8, 9, 10, 11])
627
+ or self.info[0]['Family']==15)
628
+ elif self.is_AMD():
629
+ return ((self.info[0]['Family']==6 and
630
+ self.info[0]['Model'] in [6, 7, 8, 10])
631
+ or self.info[0]['Family']==15)
632
+ else:
633
+ return False
634
+
635
+ def _has_sse2(self):
636
+ if self.is_Intel():
637
+ return self.is_Pentium4() or self.is_PentiumM() \
638
+ or self.is_Core2()
639
+ elif self.is_AMD():
640
+ return self.is_AMD64()
641
+ else:
642
+ return False
643
+
644
+ def _has_3dnow(self):
645
+ return self.is_AMD() and self.info[0]['Family'] in [5, 6, 15]
646
+
647
+ def _has_3dnowext(self):
648
+ return self.is_AMD() and self.info[0]['Family'] in [6, 15]
649
+
650
+ if sys.platform.startswith('linux'): # variations: linux2,linux-i386 (any others?)
651
+ cpuinfo = LinuxCPUInfo
652
+ elif sys.platform.startswith('irix'):
653
+ cpuinfo = IRIXCPUInfo
654
+ elif sys.platform == 'darwin':
655
+ cpuinfo = DarwinCPUInfo
656
+ elif sys.platform.startswith('sunos'):
657
+ cpuinfo = SunOSCPUInfo
658
+ elif sys.platform.startswith('win32'):
659
+ cpuinfo = Win32CPUInfo
660
+ elif sys.platform.startswith('cygwin'):
661
+ cpuinfo = LinuxCPUInfo
662
+ #XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.
663
+ else:
664
+ cpuinfo = CPUInfoBase
665
+
666
+ cpu = cpuinfo()
667
+
668
+ #if __name__ == "__main__":
669
+ #
670
+ # cpu.is_blaa()
671
+ # cpu.is_Intel()
672
+ # cpu.is_Alpha()
673
+ #
674
+ # print('CPU information:'),
675
+ # for name in dir(cpuinfo):
676
+ # if name[0]=='_' and name[1]!='_':
677
+ # r = getattr(cpu,name[1:])()
678
+ # if r:
679
+ # if r!=1:
680
+ # print('%s=%s' %(name[1:],r))
681
+ # else:
682
+ # print(name[1:]),
683
+ # print()
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/exec_command.py ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ exec_command
3
+
4
+ Implements exec_command function that is (almost) equivalent to
5
+ commands.getstatusoutput function but on NT, DOS systems the
6
+ returned status is actually correct (though, the returned status
7
+ values may be different by a factor). In addition, exec_command
8
+ takes keyword arguments for (re-)defining environment variables.
9
+
10
+ Provides functions:
11
+
12
+ exec_command --- execute command in a specified directory and
13
+ in the modified environment.
14
+ find_executable --- locate a command using info from environment
15
+ variable PATH. Equivalent to posix `which`
16
+ command.
17
+
18
+ Author: Pearu Peterson <pearu@cens.ioc.ee>
19
+ Created: 11 January 2003
20
+
21
+ Requires: Python 2.x
22
+
23
+ Successfully tested on:
24
+
25
+ ======== ============ =================================================
26
+ os.name sys.platform comments
27
+ ======== ============ =================================================
28
+ posix linux2 Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3
29
+ PyCrust 0.9.3, Idle 1.0.2
30
+ posix linux2 Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2
31
+ posix sunos5 SunOS 5.9, Python 2.2, 2.3.2
32
+ posix darwin Darwin 7.2.0, Python 2.3
33
+ nt win32 Windows Me
34
+ Python 2.3(EE), Idle 1.0, PyCrust 0.7.2
35
+ Python 2.1.1 Idle 0.8
36
+ nt win32 Windows 98, Python 2.1.1. Idle 0.8
37
+ nt win32 Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests
38
+ fail i.e. redefining environment variables may
39
+ not work. FIXED: don't use cygwin echo!
40
+ Comment: also `cmd /c echo` will not work
41
+ but redefining environment variables do work.
42
+ posix cygwin Cygwin 98-4.10, Python 2.3.3(cygming special)
43
+ nt win32 Windows XP, Python 2.3.3
44
+ ======== ============ =================================================
45
+
46
+ Known bugs:
47
+
48
+ * Tests, that send messages to stderr, fail when executed from MSYS prompt
49
+ because the messages are lost at some point.
50
+
51
+ """
52
+ __all__ = ['exec_command', 'find_executable']
53
+
54
+ import os
55
+ import sys
56
+ import subprocess
57
+ import locale
58
+ import warnings
59
+
60
+ from numpy.distutils.misc_util import is_sequence, make_temp_file
61
+ from numpy.distutils import log
62
+
63
+ def filepath_from_subprocess_output(output):
64
+ """
65
+ Convert `bytes` in the encoding used by a subprocess into a filesystem-appropriate `str`.
66
+
67
+ Inherited from `exec_command`, and possibly incorrect.
68
+ """
69
+ mylocale = locale.getpreferredencoding(False)
70
+ if mylocale is None:
71
+ mylocale = 'ascii'
72
+ output = output.decode(mylocale, errors='replace')
73
+ output = output.replace('\r\n', '\n')
74
+ # Another historical oddity
75
+ if output[-1:] == '\n':
76
+ output = output[:-1]
77
+ return output
78
+
79
+
80
+ def forward_bytes_to_stdout(val):
81
+ """
82
+ Forward bytes from a subprocess call to the console, without attempting to
83
+ decode them.
84
+
85
+ The assumption is that the subprocess call already returned bytes in
86
+ a suitable encoding.
87
+ """
88
+ if hasattr(sys.stdout, 'buffer'):
89
+ # use the underlying binary output if there is one
90
+ sys.stdout.buffer.write(val)
91
+ elif hasattr(sys.stdout, 'encoding'):
92
+ # round-trip the encoding if necessary
93
+ sys.stdout.write(val.decode(sys.stdout.encoding))
94
+ else:
95
+ # make a best-guess at the encoding
96
+ sys.stdout.write(val.decode('utf8', errors='replace'))
97
+
98
+
99
+ def temp_file_name():
100
+ # 2019-01-30, 1.17
101
+ warnings.warn('temp_file_name is deprecated since NumPy v1.17, use '
102
+ 'tempfile.mkstemp instead', DeprecationWarning, stacklevel=1)
103
+ fo, name = make_temp_file()
104
+ fo.close()
105
+ return name
106
+
107
+ def get_pythonexe():
108
+ pythonexe = sys.executable
109
+ if os.name in ['nt', 'dos']:
110
+ fdir, fn = os.path.split(pythonexe)
111
+ fn = fn.upper().replace('PYTHONW', 'PYTHON')
112
+ pythonexe = os.path.join(fdir, fn)
113
+ assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
114
+ return pythonexe
115
+
116
+ def find_executable(exe, path=None, _cache={}):
117
+ """Return full path of a executable or None.
118
+
119
+ Symbolic links are not followed.
120
+ """
121
+ key = exe, path
122
+ try:
123
+ return _cache[key]
124
+ except KeyError:
125
+ pass
126
+ log.debug('find_executable(%r)' % exe)
127
+ orig_exe = exe
128
+
129
+ if path is None:
130
+ path = os.environ.get('PATH', os.defpath)
131
+ if os.name=='posix':
132
+ realpath = os.path.realpath
133
+ else:
134
+ realpath = lambda a:a
135
+
136
+ if exe.startswith('"'):
137
+ exe = exe[1:-1]
138
+
139
+ suffixes = ['']
140
+ if os.name in ['nt', 'dos', 'os2']:
141
+ fn, ext = os.path.splitext(exe)
142
+ extra_suffixes = ['.exe', '.com', '.bat']
143
+ if ext.lower() not in extra_suffixes:
144
+ suffixes = extra_suffixes
145
+
146
+ if os.path.isabs(exe):
147
+ paths = ['']
148
+ else:
149
+ paths = [ os.path.abspath(p) for p in path.split(os.pathsep) ]
150
+
151
+ for path in paths:
152
+ fn = os.path.join(path, exe)
153
+ for s in suffixes:
154
+ f_ext = fn+s
155
+ if not os.path.islink(f_ext):
156
+ f_ext = realpath(f_ext)
157
+ if os.path.isfile(f_ext) and os.access(f_ext, os.X_OK):
158
+ log.info('Found executable %s' % f_ext)
159
+ _cache[key] = f_ext
160
+ return f_ext
161
+
162
+ log.warn('Could not locate executable %s' % orig_exe)
163
+ return None
164
+
165
+ ############################################################
166
+
167
+ def _preserve_environment( names ):
168
+ log.debug('_preserve_environment(%r)' % (names))
169
+ env = {name: os.environ.get(name) for name in names}
170
+ return env
171
+
172
+ def _update_environment( **env ):
173
+ log.debug('_update_environment(...)')
174
+ for name, value in env.items():
175
+ os.environ[name] = value or ''
176
+
177
+ def exec_command(command, execute_in='', use_shell=None, use_tee=None,
178
+ _with_python = 1, **env ):
179
+ """
180
+ Return (status,output) of executed command.
181
+
182
+ .. deprecated:: 1.17
183
+ Use subprocess.Popen instead
184
+
185
+ Parameters
186
+ ----------
187
+ command : str
188
+ A concatenated string of executable and arguments.
189
+ execute_in : str
190
+ Before running command ``cd execute_in`` and after ``cd -``.
191
+ use_shell : {bool, None}, optional
192
+ If True, execute ``sh -c command``. Default None (True)
193
+ use_tee : {bool, None}, optional
194
+ If True use tee. Default None (True)
195
+
196
+
197
+ Returns
198
+ -------
199
+ res : str
200
+ Both stdout and stderr messages.
201
+
202
+ Notes
203
+ -----
204
+ On NT, DOS systems the returned status is correct for external commands.
205
+ Wild cards will not work for non-posix systems or when use_shell=0.
206
+
207
+ """
208
+ # 2019-01-30, 1.17
209
+ warnings.warn('exec_command is deprecated since NumPy v1.17, use '
210
+ 'subprocess.Popen instead', DeprecationWarning, stacklevel=1)
211
+ log.debug('exec_command(%r,%s)' % (command,
212
+ ','.join(['%s=%r'%kv for kv in env.items()])))
213
+
214
+ if use_tee is None:
215
+ use_tee = os.name=='posix'
216
+ if use_shell is None:
217
+ use_shell = os.name=='posix'
218
+ execute_in = os.path.abspath(execute_in)
219
+ oldcwd = os.path.abspath(os.getcwd())
220
+
221
+ if __name__[-12:] == 'exec_command':
222
+ exec_dir = os.path.dirname(os.path.abspath(__file__))
223
+ elif os.path.isfile('exec_command.py'):
224
+ exec_dir = os.path.abspath('.')
225
+ else:
226
+ exec_dir = os.path.abspath(sys.argv[0])
227
+ if os.path.isfile(exec_dir):
228
+ exec_dir = os.path.dirname(exec_dir)
229
+
230
+ if oldcwd!=execute_in:
231
+ os.chdir(execute_in)
232
+ log.debug('New cwd: %s' % execute_in)
233
+ else:
234
+ log.debug('Retaining cwd: %s' % oldcwd)
235
+
236
+ oldenv = _preserve_environment( list(env.keys()) )
237
+ _update_environment( **env )
238
+
239
+ try:
240
+ st = _exec_command(command,
241
+ use_shell=use_shell,
242
+ use_tee=use_tee,
243
+ **env)
244
+ finally:
245
+ if oldcwd!=execute_in:
246
+ os.chdir(oldcwd)
247
+ log.debug('Restored cwd to %s' % oldcwd)
248
+ _update_environment(**oldenv)
249
+
250
+ return st
251
+
252
+
253
+ def _exec_command(command, use_shell=None, use_tee = None, **env):
254
+ """
255
+ Internal workhorse for exec_command().
256
+ """
257
+ if use_shell is None:
258
+ use_shell = os.name=='posix'
259
+ if use_tee is None:
260
+ use_tee = os.name=='posix'
261
+
262
+ if os.name == 'posix' and use_shell:
263
+ # On POSIX, subprocess always uses /bin/sh, override
264
+ sh = os.environ.get('SHELL', '/bin/sh')
265
+ if is_sequence(command):
266
+ command = [sh, '-c', ' '.join(command)]
267
+ else:
268
+ command = [sh, '-c', command]
269
+ use_shell = False
270
+
271
+ elif os.name == 'nt' and is_sequence(command):
272
+ # On Windows, join the string for CreateProcess() ourselves as
273
+ # subprocess does it a bit differently
274
+ command = ' '.join(_quote_arg(arg) for arg in command)
275
+
276
+ # Inherit environment by default
277
+ env = env or None
278
+ try:
279
+ # text is set to False so that communicate()
280
+ # will return bytes. We need to decode the output ourselves
281
+ # so that Python will not raise a UnicodeDecodeError when
282
+ # it encounters an invalid character; rather, we simply replace it
283
+ proc = subprocess.Popen(command, shell=use_shell, env=env, text=False,
284
+ stdout=subprocess.PIPE,
285
+ stderr=subprocess.STDOUT)
286
+ except OSError:
287
+ # Return 127, as os.spawn*() and /bin/sh do
288
+ return 127, ''
289
+
290
+ text, err = proc.communicate()
291
+ mylocale = locale.getpreferredencoding(False)
292
+ if mylocale is None:
293
+ mylocale = 'ascii'
294
+ text = text.decode(mylocale, errors='replace')
295
+ text = text.replace('\r\n', '\n')
296
+ # Another historical oddity
297
+ if text[-1:] == '\n':
298
+ text = text[:-1]
299
+
300
+ if use_tee and text:
301
+ print(text)
302
+ return proc.returncode, text
303
+
304
+
305
+ def _quote_arg(arg):
306
+ """
307
+ Quote the argument for safe use in a shell command line.
308
+ """
309
+ # If there is a quote in the string, assume relevant parts of the
310
+ # string are already quoted (e.g. '-I"C:\\Program Files\\..."')
311
+ if '"' not in arg and ' ' in arg:
312
+ return '"%s"' % arg
313
+ return arg
314
+
315
+ ############################################################
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/extension.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """distutils.extension
2
+
3
+ Provides the Extension class, used to describe C/C++ extension
4
+ modules in setup scripts.
5
+
6
+ Overridden to support f2py.
7
+
8
+ """
9
+ import re
10
+ from distutils.extension import Extension as old_Extension
11
+
12
+
13
+ cxx_ext_re = re.compile(r'.*\.(cpp|cxx|cc)\Z', re.I).match
14
+ fortran_pyf_ext_re = re.compile(r'.*\.(f90|f95|f77|for|ftn|f|pyf)\Z', re.I).match
15
+
16
+
17
+ class Extension(old_Extension):
18
+ """
19
+ Parameters
20
+ ----------
21
+ name : str
22
+ Extension name.
23
+ sources : list of str
24
+ List of source file locations relative to the top directory of
25
+ the package.
26
+ extra_compile_args : list of str
27
+ Extra command line arguments to pass to the compiler.
28
+ extra_f77_compile_args : list of str
29
+ Extra command line arguments to pass to the fortran77 compiler.
30
+ extra_f90_compile_args : list of str
31
+ Extra command line arguments to pass to the fortran90 compiler.
32
+ """
33
+ def __init__(
34
+ self, name, sources,
35
+ include_dirs=None,
36
+ define_macros=None,
37
+ undef_macros=None,
38
+ library_dirs=None,
39
+ libraries=None,
40
+ runtime_library_dirs=None,
41
+ extra_objects=None,
42
+ extra_compile_args=None,
43
+ extra_link_args=None,
44
+ export_symbols=None,
45
+ swig_opts=None,
46
+ depends=None,
47
+ language=None,
48
+ f2py_options=None,
49
+ module_dirs=None,
50
+ extra_c_compile_args=None,
51
+ extra_cxx_compile_args=None,
52
+ extra_f77_compile_args=None,
53
+ extra_f90_compile_args=None,):
54
+
55
+ old_Extension.__init__(
56
+ self, name, [],
57
+ include_dirs=include_dirs,
58
+ define_macros=define_macros,
59
+ undef_macros=undef_macros,
60
+ library_dirs=library_dirs,
61
+ libraries=libraries,
62
+ runtime_library_dirs=runtime_library_dirs,
63
+ extra_objects=extra_objects,
64
+ extra_compile_args=extra_compile_args,
65
+ extra_link_args=extra_link_args,
66
+ export_symbols=export_symbols)
67
+
68
+ # Avoid assert statements checking that sources contains strings:
69
+ self.sources = sources
70
+
71
+ # Python 2.4 distutils new features
72
+ self.swig_opts = swig_opts or []
73
+ # swig_opts is assumed to be a list. Here we handle the case where it
74
+ # is specified as a string instead.
75
+ if isinstance(self.swig_opts, str):
76
+ import warnings
77
+ msg = "swig_opts is specified as a string instead of a list"
78
+ warnings.warn(msg, SyntaxWarning, stacklevel=2)
79
+ self.swig_opts = self.swig_opts.split()
80
+
81
+ # Python 2.3 distutils new features
82
+ self.depends = depends or []
83
+ self.language = language
84
+
85
+ # numpy_distutils features
86
+ self.f2py_options = f2py_options or []
87
+ self.module_dirs = module_dirs or []
88
+ self.extra_c_compile_args = extra_c_compile_args or []
89
+ self.extra_cxx_compile_args = extra_cxx_compile_args or []
90
+ self.extra_f77_compile_args = extra_f77_compile_args or []
91
+ self.extra_f90_compile_args = extra_f90_compile_args or []
92
+
93
+ return
94
+
95
+ def has_cxx_sources(self):
96
+ return any(cxx_ext_re(str(source)) for source in self.sources)
97
+
98
+ def has_f2py_sources(self):
99
+ return any(fortran_pyf_ext_re(source) for source in self.sources)
100
+
101
+ # class Extension
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/__init__.py ADDED
@@ -0,0 +1,1035 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """numpy.distutils.fcompiler
2
+
3
+ Contains FCompiler, an abstract base class that defines the interface
4
+ for the numpy.distutils Fortran compiler abstraction model.
5
+
6
+ Terminology:
7
+
8
+ To be consistent, where the term 'executable' is used, it means the single
9
+ file, like 'gcc', that is executed, and should be a string. In contrast,
10
+ 'command' means the entire command line, like ['gcc', '-c', 'file.c'], and
11
+ should be a list.
12
+
13
+ But note that FCompiler.executables is actually a dictionary of commands.
14
+
15
+ """
16
+ __all__ = ['FCompiler', 'new_fcompiler', 'show_fcompilers',
17
+ 'dummy_fortran_file']
18
+
19
+ import os
20
+ import sys
21
+ import re
22
+ from pathlib import Path
23
+
24
+ from distutils.sysconfig import get_python_lib
25
+ from distutils.fancy_getopt import FancyGetopt
26
+ from distutils.errors import DistutilsModuleError, \
27
+ DistutilsExecError, CompileError, LinkError, DistutilsPlatformError
28
+ from distutils.util import split_quoted, strtobool
29
+
30
+ from numpy.distutils.ccompiler import CCompiler, gen_lib_options
31
+ from numpy.distutils import log
32
+ from numpy.distutils.misc_util import is_string, all_strings, is_sequence, \
33
+ make_temp_file, get_shared_lib_extension
34
+ from numpy.distutils.exec_command import find_executable
35
+ from numpy.distutils import _shell_utils
36
+
37
+ from .environment import EnvironmentConfig
38
+
39
+ __metaclass__ = type
40
+
41
+
42
+ FORTRAN_COMMON_FIXED_EXTENSIONS = ['.for', '.ftn', '.f77', '.f']
43
+
44
+
45
+ class CompilerNotFound(Exception):
46
+ pass
47
+
48
+ def flaglist(s):
49
+ if is_string(s):
50
+ return split_quoted(s)
51
+ else:
52
+ return s
53
+
54
+ def str2bool(s):
55
+ if is_string(s):
56
+ return strtobool(s)
57
+ return bool(s)
58
+
59
+ def is_sequence_of_strings(seq):
60
+ return is_sequence(seq) and all_strings(seq)
61
+
62
+ class FCompiler(CCompiler):
63
+ """Abstract base class to define the interface that must be implemented
64
+ by real Fortran compiler classes.
65
+
66
+ Methods that subclasses may redefine:
67
+
68
+ update_executables(), find_executables(), get_version()
69
+ get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()
70
+ get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),
71
+ get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),
72
+ get_flags_arch_f90(), get_flags_debug_f90(),
73
+ get_flags_fix(), get_flags_linker_so()
74
+
75
+ DON'T call these methods (except get_version) after
76
+ constructing a compiler instance or inside any other method.
77
+ All methods, except update_executables() and find_executables(),
78
+ may call the get_version() method.
79
+
80
+ After constructing a compiler instance, always call customize(dist=None)
81
+ method that finalizes compiler construction and makes the following
82
+ attributes available:
83
+ compiler_f77
84
+ compiler_f90
85
+ compiler_fix
86
+ linker_so
87
+ archiver
88
+ ranlib
89
+ libraries
90
+ library_dirs
91
+ """
92
+
93
+ # These are the environment variables and distutils keys used.
94
+ # Each configuration description is
95
+ # (<hook name>, <environment variable>, <key in distutils.cfg>, <convert>, <append>)
96
+ # The hook names are handled by the self._environment_hook method.
97
+ # - names starting with 'self.' call methods in this class
98
+ # - names starting with 'exe.' return the key in the executables dict
99
+ # - names like 'flags.YYY' return self.get_flag_YYY()
100
+ # convert is either None or a function to convert a string to the
101
+ # appropriate type used.
102
+
103
+ distutils_vars = EnvironmentConfig(
104
+ distutils_section='config_fc',
105
+ noopt = (None, None, 'noopt', str2bool, False),
106
+ noarch = (None, None, 'noarch', str2bool, False),
107
+ debug = (None, None, 'debug', str2bool, False),
108
+ verbose = (None, None, 'verbose', str2bool, False),
109
+ )
110
+
111
+ command_vars = EnvironmentConfig(
112
+ distutils_section='config_fc',
113
+ compiler_f77 = ('exe.compiler_f77', 'F77', 'f77exec', None, False),
114
+ compiler_f90 = ('exe.compiler_f90', 'F90', 'f90exec', None, False),
115
+ compiler_fix = ('exe.compiler_fix', 'F90', 'f90exec', None, False),
116
+ version_cmd = ('exe.version_cmd', None, None, None, False),
117
+ linker_so = ('exe.linker_so', 'LDSHARED', 'ldshared', None, False),
118
+ linker_exe = ('exe.linker_exe', 'LD', 'ld', None, False),
119
+ archiver = (None, 'AR', 'ar', None, False),
120
+ ranlib = (None, 'RANLIB', 'ranlib', None, False),
121
+ )
122
+
123
+ flag_vars = EnvironmentConfig(
124
+ distutils_section='config_fc',
125
+ f77 = ('flags.f77', 'F77FLAGS', 'f77flags', flaglist, True),
126
+ f90 = ('flags.f90', 'F90FLAGS', 'f90flags', flaglist, True),
127
+ free = ('flags.free', 'FREEFLAGS', 'freeflags', flaglist, True),
128
+ fix = ('flags.fix', None, None, flaglist, False),
129
+ opt = ('flags.opt', 'FOPT', 'opt', flaglist, True),
130
+ opt_f77 = ('flags.opt_f77', None, None, flaglist, False),
131
+ opt_f90 = ('flags.opt_f90', None, None, flaglist, False),
132
+ arch = ('flags.arch', 'FARCH', 'arch', flaglist, False),
133
+ arch_f77 = ('flags.arch_f77', None, None, flaglist, False),
134
+ arch_f90 = ('flags.arch_f90', None, None, flaglist, False),
135
+ debug = ('flags.debug', 'FDEBUG', 'fdebug', flaglist, True),
136
+ debug_f77 = ('flags.debug_f77', None, None, flaglist, False),
137
+ debug_f90 = ('flags.debug_f90', None, None, flaglist, False),
138
+ flags = ('self.get_flags', 'FFLAGS', 'fflags', flaglist, True),
139
+ linker_so = ('flags.linker_so', 'LDFLAGS', 'ldflags', flaglist, True),
140
+ linker_exe = ('flags.linker_exe', 'LDFLAGS', 'ldflags', flaglist, True),
141
+ ar = ('flags.ar', 'ARFLAGS', 'arflags', flaglist, True),
142
+ )
143
+
144
+ language_map = {'.f': 'f77',
145
+ '.for': 'f77',
146
+ '.F': 'f77', # XXX: needs preprocessor
147
+ '.ftn': 'f77',
148
+ '.f77': 'f77',
149
+ '.f90': 'f90',
150
+ '.F90': 'f90', # XXX: needs preprocessor
151
+ '.f95': 'f90',
152
+ }
153
+ language_order = ['f90', 'f77']
154
+
155
+
156
+ # These will be set by the subclass
157
+
158
+ compiler_type = None
159
+ compiler_aliases = ()
160
+ version_pattern = None
161
+
162
+ possible_executables = []
163
+ executables = {
164
+ 'version_cmd': ["f77", "-v"],
165
+ 'compiler_f77': ["f77"],
166
+ 'compiler_f90': ["f90"],
167
+ 'compiler_fix': ["f90", "-fixed"],
168
+ 'linker_so': ["f90", "-shared"],
169
+ 'linker_exe': ["f90"],
170
+ 'archiver': ["ar", "-cr"],
171
+ 'ranlib': None,
172
+ }
173
+
174
+ # If compiler does not support compiling Fortran 90 then it can
175
+ # suggest using another compiler. For example, gnu would suggest
176
+ # gnu95 compiler type when there are F90 sources.
177
+ suggested_f90_compiler = None
178
+
179
+ compile_switch = "-c"
180
+ object_switch = "-o " # Ending space matters! It will be stripped
181
+ # but if it is missing then object_switch
182
+ # will be prefixed to object file name by
183
+ # string concatenation.
184
+ library_switch = "-o " # Ditto!
185
+
186
+ # Switch to specify where module files are created and searched
187
+ # for USE statement. Normally it is a string and also here ending
188
+ # space matters. See above.
189
+ module_dir_switch = None
190
+
191
+ # Switch to specify where module files are searched for USE statement.
192
+ module_include_switch = '-I'
193
+
194
+ pic_flags = [] # Flags to create position-independent code
195
+
196
+ src_extensions = ['.for', '.ftn', '.f77', '.f', '.f90', '.f95', '.F', '.F90', '.FOR']
197
+ obj_extension = ".o"
198
+
199
+ shared_lib_extension = get_shared_lib_extension()
200
+ static_lib_extension = ".a" # or .lib
201
+ static_lib_format = "lib%s%s" # or %s%s
202
+ shared_lib_format = "%s%s"
203
+ exe_extension = ""
204
+
205
+ _exe_cache = {}
206
+
207
+ _executable_keys = ['version_cmd', 'compiler_f77', 'compiler_f90',
208
+ 'compiler_fix', 'linker_so', 'linker_exe', 'archiver',
209
+ 'ranlib']
210
+
211
+ # This will be set by new_fcompiler when called in
212
+ # command/{build_ext.py, build_clib.py, config.py} files.
213
+ c_compiler = None
214
+
215
+ # extra_{f77,f90}_compile_args are set by build_ext.build_extension method
216
+ extra_f77_compile_args = []
217
+ extra_f90_compile_args = []
218
+
219
+ def __init__(self, *args, **kw):
220
+ CCompiler.__init__(self, *args, **kw)
221
+ self.distutils_vars = self.distutils_vars.clone(self._environment_hook)
222
+ self.command_vars = self.command_vars.clone(self._environment_hook)
223
+ self.flag_vars = self.flag_vars.clone(self._environment_hook)
224
+ self.executables = self.executables.copy()
225
+ for e in self._executable_keys:
226
+ if e not in self.executables:
227
+ self.executables[e] = None
228
+
229
+ # Some methods depend on .customize() being called first, so
230
+ # this keeps track of whether that's happened yet.
231
+ self._is_customised = False
232
+
233
+ def __copy__(self):
234
+ obj = self.__new__(self.__class__)
235
+ obj.__dict__.update(self.__dict__)
236
+ obj.distutils_vars = obj.distutils_vars.clone(obj._environment_hook)
237
+ obj.command_vars = obj.command_vars.clone(obj._environment_hook)
238
+ obj.flag_vars = obj.flag_vars.clone(obj._environment_hook)
239
+ obj.executables = obj.executables.copy()
240
+ return obj
241
+
242
+ def copy(self):
243
+ return self.__copy__()
244
+
245
+ # Use properties for the attributes used by CCompiler. Setting them
246
+ # as attributes from the self.executables dictionary is error-prone,
247
+ # so we get them from there each time.
248
+ def _command_property(key):
249
+ def fget(self):
250
+ assert self._is_customised
251
+ return self.executables[key]
252
+ return property(fget=fget)
253
+ version_cmd = _command_property('version_cmd')
254
+ compiler_f77 = _command_property('compiler_f77')
255
+ compiler_f90 = _command_property('compiler_f90')
256
+ compiler_fix = _command_property('compiler_fix')
257
+ linker_so = _command_property('linker_so')
258
+ linker_exe = _command_property('linker_exe')
259
+ archiver = _command_property('archiver')
260
+ ranlib = _command_property('ranlib')
261
+
262
+ # Make our terminology consistent.
263
+ def set_executable(self, key, value):
264
+ self.set_command(key, value)
265
+
266
+ def set_commands(self, **kw):
267
+ for k, v in kw.items():
268
+ self.set_command(k, v)
269
+
270
+ def set_command(self, key, value):
271
+ if not key in self._executable_keys:
272
+ raise ValueError(
273
+ "unknown executable '%s' for class %s" %
274
+ (key, self.__class__.__name__))
275
+ if is_string(value):
276
+ value = split_quoted(value)
277
+ assert value is None or is_sequence_of_strings(value[1:]), (key, value)
278
+ self.executables[key] = value
279
+
280
+ ######################################################################
281
+ ## Methods that subclasses may redefine. But don't call these methods!
282
+ ## They are private to FCompiler class and may return unexpected
283
+ ## results if used elsewhere. So, you have been warned..
284
+
285
+ def find_executables(self):
286
+ """Go through the self.executables dictionary, and attempt to
287
+ find and assign appropriate executables.
288
+
289
+ Executable names are looked for in the environment (environment
290
+ variables, the distutils.cfg, and command line), the 0th-element of
291
+ the command list, and the self.possible_executables list.
292
+
293
+ Also, if the 0th element is "<F77>" or "<F90>", the Fortran 77
294
+ or the Fortran 90 compiler executable is used, unless overridden
295
+ by an environment setting.
296
+
297
+ Subclasses should call this if overridden.
298
+ """
299
+ assert self._is_customised
300
+ exe_cache = self._exe_cache
301
+ def cached_find_executable(exe):
302
+ if exe in exe_cache:
303
+ return exe_cache[exe]
304
+ fc_exe = find_executable(exe)
305
+ exe_cache[exe] = exe_cache[fc_exe] = fc_exe
306
+ return fc_exe
307
+ def verify_command_form(name, value):
308
+ if value is not None and not is_sequence_of_strings(value):
309
+ raise ValueError(
310
+ "%s value %r is invalid in class %s" %
311
+ (name, value, self.__class__.__name__))
312
+ def set_exe(exe_key, f77=None, f90=None):
313
+ cmd = self.executables.get(exe_key, None)
314
+ if not cmd:
315
+ return None
316
+ # Note that we get cmd[0] here if the environment doesn't
317
+ # have anything set
318
+ exe_from_environ = getattr(self.command_vars, exe_key)
319
+ if not exe_from_environ:
320
+ possibles = [f90, f77] + self.possible_executables
321
+ else:
322
+ possibles = [exe_from_environ] + self.possible_executables
323
+
324
+ seen = set()
325
+ unique_possibles = []
326
+ for e in possibles:
327
+ if e == '<F77>':
328
+ e = f77
329
+ elif e == '<F90>':
330
+ e = f90
331
+ if not e or e in seen:
332
+ continue
333
+ seen.add(e)
334
+ unique_possibles.append(e)
335
+
336
+ for exe in unique_possibles:
337
+ fc_exe = cached_find_executable(exe)
338
+ if fc_exe:
339
+ cmd[0] = fc_exe
340
+ return fc_exe
341
+ self.set_command(exe_key, None)
342
+ return None
343
+
344
+ ctype = self.compiler_type
345
+ f90 = set_exe('compiler_f90')
346
+ if not f90:
347
+ f77 = set_exe('compiler_f77')
348
+ if f77:
349
+ log.warn('%s: no Fortran 90 compiler found' % ctype)
350
+ else:
351
+ raise CompilerNotFound('%s: f90 nor f77' % ctype)
352
+ else:
353
+ f77 = set_exe('compiler_f77', f90=f90)
354
+ if not f77:
355
+ log.warn('%s: no Fortran 77 compiler found' % ctype)
356
+ set_exe('compiler_fix', f90=f90)
357
+
358
+ set_exe('linker_so', f77=f77, f90=f90)
359
+ set_exe('linker_exe', f77=f77, f90=f90)
360
+ set_exe('version_cmd', f77=f77, f90=f90)
361
+ set_exe('archiver')
362
+ set_exe('ranlib')
363
+
364
+ def update_executables(self):
365
+ """Called at the beginning of customisation. Subclasses should
366
+ override this if they need to set up the executables dictionary.
367
+
368
+ Note that self.find_executables() is run afterwards, so the
369
+ self.executables dictionary values can contain <F77> or <F90> as
370
+ the command, which will be replaced by the found F77 or F90
371
+ compiler.
372
+ """
373
+ pass
374
+
375
+ def get_flags(self):
376
+ """List of flags common to all compiler types."""
377
+ return [] + self.pic_flags
378
+
379
+ def _get_command_flags(self, key):
380
+ cmd = self.executables.get(key, None)
381
+ if cmd is None:
382
+ return []
383
+ return cmd[1:]
384
+
385
+ def get_flags_f77(self):
386
+ """List of Fortran 77 specific flags."""
387
+ return self._get_command_flags('compiler_f77')
388
+ def get_flags_f90(self):
389
+ """List of Fortran 90 specific flags."""
390
+ return self._get_command_flags('compiler_f90')
391
+ def get_flags_free(self):
392
+ """List of Fortran 90 free format specific flags."""
393
+ return []
394
+ def get_flags_fix(self):
395
+ """List of Fortran 90 fixed format specific flags."""
396
+ return self._get_command_flags('compiler_fix')
397
+ def get_flags_linker_so(self):
398
+ """List of linker flags to build a shared library."""
399
+ return self._get_command_flags('linker_so')
400
+ def get_flags_linker_exe(self):
401
+ """List of linker flags to build an executable."""
402
+ return self._get_command_flags('linker_exe')
403
+ def get_flags_ar(self):
404
+ """List of archiver flags. """
405
+ return self._get_command_flags('archiver')
406
+ def get_flags_opt(self):
407
+ """List of architecture independent compiler flags."""
408
+ return []
409
+ def get_flags_arch(self):
410
+ """List of architecture dependent compiler flags."""
411
+ return []
412
+ def get_flags_debug(self):
413
+ """List of compiler flags to compile with debugging information."""
414
+ return []
415
+
416
+ get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt
417
+ get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch
418
+ get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug
419
+
420
+ def get_libraries(self):
421
+ """List of compiler libraries."""
422
+ return self.libraries[:]
423
+ def get_library_dirs(self):
424
+ """List of compiler library directories."""
425
+ return self.library_dirs[:]
426
+
427
+ def get_version(self, force=False, ok_status=[0]):
428
+ assert self._is_customised
429
+ version = CCompiler.get_version(self, force=force, ok_status=ok_status)
430
+ if version is None:
431
+ raise CompilerNotFound()
432
+ return version
433
+
434
+
435
+ ############################################################
436
+
437
+ ## Public methods:
438
+
439
+ def customize(self, dist = None):
440
+ """Customize Fortran compiler.
441
+
442
+ This method gets Fortran compiler specific information from
443
+ (i) class definition, (ii) environment, (iii) distutils config
444
+ files, and (iv) command line (later overrides earlier).
445
+
446
+ This method should be always called after constructing a
447
+ compiler instance. But not in __init__ because Distribution
448
+ instance is needed for (iii) and (iv).
449
+ """
450
+ log.info('customize %s' % (self.__class__.__name__))
451
+
452
+ self._is_customised = True
453
+
454
+ self.distutils_vars.use_distribution(dist)
455
+ self.command_vars.use_distribution(dist)
456
+ self.flag_vars.use_distribution(dist)
457
+
458
+ self.update_executables()
459
+
460
+ # find_executables takes care of setting the compiler commands,
461
+ # version_cmd, linker_so, linker_exe, ar, and ranlib
462
+ self.find_executables()
463
+
464
+ noopt = self.distutils_vars.get('noopt', False)
465
+ noarch = self.distutils_vars.get('noarch', noopt)
466
+ debug = self.distutils_vars.get('debug', False)
467
+
468
+ f77 = self.command_vars.compiler_f77
469
+ f90 = self.command_vars.compiler_f90
470
+
471
+ f77flags = []
472
+ f90flags = []
473
+ freeflags = []
474
+ fixflags = []
475
+
476
+ if f77:
477
+ f77 = _shell_utils.NativeParser.split(f77)
478
+ f77flags = self.flag_vars.f77
479
+ if f90:
480
+ f90 = _shell_utils.NativeParser.split(f90)
481
+ f90flags = self.flag_vars.f90
482
+ freeflags = self.flag_vars.free
483
+ # XXX Assuming that free format is default for f90 compiler.
484
+ fix = self.command_vars.compiler_fix
485
+ # NOTE: this and similar examples are probably just
486
+ # excluding --coverage flag when F90 = gfortran --coverage
487
+ # instead of putting that flag somewhere more appropriate
488
+ # this and similar examples where a Fortran compiler
489
+ # environment variable has been customized by CI or a user
490
+ # should perhaps eventually be more thoroughly tested and more
491
+ # robustly handled
492
+ if fix:
493
+ fix = _shell_utils.NativeParser.split(fix)
494
+ fixflags = self.flag_vars.fix + f90flags
495
+
496
+ oflags, aflags, dflags = [], [], []
497
+ # examine get_flags_<tag>_<compiler> for extra flags
498
+ # only add them if the method is different from get_flags_<tag>
499
+ def get_flags(tag, flags):
500
+ # note that self.flag_vars.<tag> calls self.get_flags_<tag>()
501
+ flags.extend(getattr(self.flag_vars, tag))
502
+ this_get = getattr(self, 'get_flags_' + tag)
503
+ for name, c, flagvar in [('f77', f77, f77flags),
504
+ ('f90', f90, f90flags),
505
+ ('f90', fix, fixflags)]:
506
+ t = '%s_%s' % (tag, name)
507
+ if c and this_get is not getattr(self, 'get_flags_' + t):
508
+ flagvar.extend(getattr(self.flag_vars, t))
509
+ if not noopt:
510
+ get_flags('opt', oflags)
511
+ if not noarch:
512
+ get_flags('arch', aflags)
513
+ if debug:
514
+ get_flags('debug', dflags)
515
+
516
+ fflags = self.flag_vars.flags + dflags + oflags + aflags
517
+
518
+ if f77:
519
+ self.set_commands(compiler_f77=f77+f77flags+fflags)
520
+ if f90:
521
+ self.set_commands(compiler_f90=f90+freeflags+f90flags+fflags)
522
+ if fix:
523
+ self.set_commands(compiler_fix=fix+fixflags+fflags)
524
+
525
+
526
+ #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS
527
+ linker_so = self.linker_so
528
+ if linker_so:
529
+ linker_so_flags = self.flag_vars.linker_so
530
+ if sys.platform.startswith('aix'):
531
+ python_lib = get_python_lib(standard_lib=1)
532
+ ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix')
533
+ python_exp = os.path.join(python_lib, 'config', 'python.exp')
534
+ linker_so = [ld_so_aix] + linker_so + ['-bI:'+python_exp]
535
+ if sys.platform.startswith('os400'):
536
+ from distutils.sysconfig import get_config_var
537
+ python_config = get_config_var('LIBPL')
538
+ ld_so_aix = os.path.join(python_config, 'ld_so_aix')
539
+ python_exp = os.path.join(python_config, 'python.exp')
540
+ linker_so = [ld_so_aix] + linker_so + ['-bI:'+python_exp]
541
+ self.set_commands(linker_so=linker_so+linker_so_flags)
542
+
543
+ linker_exe = self.linker_exe
544
+ if linker_exe:
545
+ linker_exe_flags = self.flag_vars.linker_exe
546
+ self.set_commands(linker_exe=linker_exe+linker_exe_flags)
547
+
548
+ ar = self.command_vars.archiver
549
+ if ar:
550
+ arflags = self.flag_vars.ar
551
+ self.set_commands(archiver=[ar]+arflags)
552
+
553
+ self.set_library_dirs(self.get_library_dirs())
554
+ self.set_libraries(self.get_libraries())
555
+
556
+ def dump_properties(self):
557
+ """Print out the attributes of a compiler instance."""
558
+ props = []
559
+ for key in list(self.executables.keys()) + \
560
+ ['version', 'libraries', 'library_dirs',
561
+ 'object_switch', 'compile_switch']:
562
+ if hasattr(self, key):
563
+ v = getattr(self, key)
564
+ props.append((key, None, '= '+repr(v)))
565
+ props.sort()
566
+
567
+ pretty_printer = FancyGetopt(props)
568
+ for l in pretty_printer.generate_help("%s instance properties:" \
569
+ % (self.__class__.__name__)):
570
+ if l[:4]==' --':
571
+ l = ' ' + l[4:]
572
+ print(l)
573
+
574
+ ###################
575
+
576
+ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
577
+ """Compile 'src' to product 'obj'."""
578
+ src_flags = {}
579
+ if Path(src).suffix.lower() in FORTRAN_COMMON_FIXED_EXTENSIONS \
580
+ and not has_f90_header(src):
581
+ flavor = ':f77'
582
+ compiler = self.compiler_f77
583
+ src_flags = get_f77flags(src)
584
+ extra_compile_args = self.extra_f77_compile_args or []
585
+ elif is_free_format(src):
586
+ flavor = ':f90'
587
+ compiler = self.compiler_f90
588
+ if compiler is None:
589
+ raise DistutilsExecError('f90 not supported by %s needed for %s'\
590
+ % (self.__class__.__name__, src))
591
+ extra_compile_args = self.extra_f90_compile_args or []
592
+ else:
593
+ flavor = ':fix'
594
+ compiler = self.compiler_fix
595
+ if compiler is None:
596
+ raise DistutilsExecError('f90 (fixed) not supported by %s needed for %s'\
597
+ % (self.__class__.__name__, src))
598
+ extra_compile_args = self.extra_f90_compile_args or []
599
+ if self.object_switch[-1]==' ':
600
+ o_args = [self.object_switch.strip(), obj]
601
+ else:
602
+ o_args = [self.object_switch.strip()+obj]
603
+
604
+ assert self.compile_switch.strip()
605
+ s_args = [self.compile_switch, src]
606
+
607
+ if extra_compile_args:
608
+ log.info('extra %s options: %r' \
609
+ % (flavor[1:], ' '.join(extra_compile_args)))
610
+
611
+ extra_flags = src_flags.get(self.compiler_type, [])
612
+ if extra_flags:
613
+ log.info('using compile options from source: %r' \
614
+ % ' '.join(extra_flags))
615
+
616
+ command = compiler + cc_args + extra_flags + s_args + o_args \
617
+ + extra_postargs + extra_compile_args
618
+
619
+ display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,
620
+ src)
621
+ try:
622
+ self.spawn(command, display=display)
623
+ except DistutilsExecError as e:
624
+ msg = str(e)
625
+ raise CompileError(msg) from None
626
+
627
+ def module_options(self, module_dirs, module_build_dir):
628
+ options = []
629
+ if self.module_dir_switch is not None:
630
+ if self.module_dir_switch[-1]==' ':
631
+ options.extend([self.module_dir_switch.strip(), module_build_dir])
632
+ else:
633
+ options.append(self.module_dir_switch.strip()+module_build_dir)
634
+ else:
635
+ print('XXX: module_build_dir=%r option ignored' % (module_build_dir))
636
+ print('XXX: Fix module_dir_switch for ', self.__class__.__name__)
637
+ if self.module_include_switch is not None:
638
+ for d in [module_build_dir]+module_dirs:
639
+ options.append('%s%s' % (self.module_include_switch, d))
640
+ else:
641
+ print('XXX: module_dirs=%r option ignored' % (module_dirs))
642
+ print('XXX: Fix module_include_switch for ', self.__class__.__name__)
643
+ return options
644
+
645
+ def library_option(self, lib):
646
+ return "-l" + lib
647
+ def library_dir_option(self, dir):
648
+ return "-L" + dir
649
+
650
+ def link(self, target_desc, objects,
651
+ output_filename, output_dir=None, libraries=None,
652
+ library_dirs=None, runtime_library_dirs=None,
653
+ export_symbols=None, debug=0, extra_preargs=None,
654
+ extra_postargs=None, build_temp=None, target_lang=None):
655
+ objects, output_dir = self._fix_object_args(objects, output_dir)
656
+ libraries, library_dirs, runtime_library_dirs = \
657
+ self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
658
+
659
+ lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
660
+ libraries)
661
+ if is_string(output_dir):
662
+ output_filename = os.path.join(output_dir, output_filename)
663
+ elif output_dir is not None:
664
+ raise TypeError("'output_dir' must be a string or None")
665
+
666
+ if self._need_link(objects, output_filename):
667
+ if self.library_switch[-1]==' ':
668
+ o_args = [self.library_switch.strip(), output_filename]
669
+ else:
670
+ o_args = [self.library_switch.strip()+output_filename]
671
+
672
+ if is_string(self.objects):
673
+ ld_args = objects + [self.objects]
674
+ else:
675
+ ld_args = objects + self.objects
676
+ ld_args = ld_args + lib_opts + o_args
677
+ if debug:
678
+ ld_args[:0] = ['-g']
679
+ if extra_preargs:
680
+ ld_args[:0] = extra_preargs
681
+ if extra_postargs:
682
+ ld_args.extend(extra_postargs)
683
+ self.mkpath(os.path.dirname(output_filename))
684
+ if target_desc == CCompiler.EXECUTABLE:
685
+ linker = self.linker_exe[:]
686
+ else:
687
+ linker = self.linker_so[:]
688
+ command = linker + ld_args
689
+ try:
690
+ self.spawn(command)
691
+ except DistutilsExecError as e:
692
+ msg = str(e)
693
+ raise LinkError(msg) from None
694
+ else:
695
+ log.debug("skipping %s (up-to-date)", output_filename)
696
+
697
+ def _environment_hook(self, name, hook_name):
698
+ if hook_name is None:
699
+ return None
700
+ if is_string(hook_name):
701
+ if hook_name.startswith('self.'):
702
+ hook_name = hook_name[5:]
703
+ hook = getattr(self, hook_name)
704
+ return hook()
705
+ elif hook_name.startswith('exe.'):
706
+ hook_name = hook_name[4:]
707
+ var = self.executables[hook_name]
708
+ if var:
709
+ return var[0]
710
+ else:
711
+ return None
712
+ elif hook_name.startswith('flags.'):
713
+ hook_name = hook_name[6:]
714
+ hook = getattr(self, 'get_flags_' + hook_name)
715
+ return hook()
716
+ else:
717
+ return hook_name()
718
+
719
+ def can_ccompiler_link(self, ccompiler):
720
+ """
721
+ Check if the given C compiler can link objects produced by
722
+ this compiler.
723
+ """
724
+ return True
725
+
726
+ def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir):
727
+ """
728
+ Convert a set of object files that are not compatible with the default
729
+ linker, to a file that is compatible.
730
+
731
+ Parameters
732
+ ----------
733
+ objects : list
734
+ List of object files to include.
735
+ output_dir : str
736
+ Output directory to place generated object files.
737
+ extra_dll_dir : str
738
+ Output directory to place extra DLL files that need to be
739
+ included on Windows.
740
+
741
+ Returns
742
+ -------
743
+ converted_objects : list of str
744
+ List of converted object files.
745
+ Note that the number of output files is not necessarily
746
+ the same as inputs.
747
+
748
+ """
749
+ raise NotImplementedError()
750
+
751
+ ## class FCompiler
752
+
753
+ _default_compilers = (
754
+ # sys.platform mappings
755
+ ('win32', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95',
756
+ 'intelvem', 'intelem', 'flang')),
757
+ ('cygwin.*', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95')),
758
+ ('linux.*', ('arm', 'gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag',
759
+ 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95',
760
+ 'pathf95', 'nagfor', 'fujitsu')),
761
+ ('darwin.*', ('gnu95', 'nag', 'nagfor', 'absoft', 'ibm', 'intel', 'gnu',
762
+ 'g95', 'pg')),
763
+ ('sunos.*', ('sun', 'gnu', 'gnu95', 'g95')),
764
+ ('irix.*', ('mips', 'gnu', 'gnu95',)),
765
+ ('aix.*', ('ibm', 'gnu', 'gnu95',)),
766
+ # os.name mappings
767
+ ('posix', ('gnu', 'gnu95',)),
768
+ ('nt', ('gnu', 'gnu95',)),
769
+ ('mac', ('gnu95', 'gnu', 'pg')),
770
+ )
771
+
772
+ fcompiler_class = None
773
+ fcompiler_aliases = None
774
+
775
+ def load_all_fcompiler_classes():
776
+ """Cache all the FCompiler classes found in modules in the
777
+ numpy.distutils.fcompiler package.
778
+ """
779
+ from glob import glob
780
+ global fcompiler_class, fcompiler_aliases
781
+ if fcompiler_class is not None:
782
+ return
783
+ pys = os.path.join(os.path.dirname(__file__), '*.py')
784
+ fcompiler_class = {}
785
+ fcompiler_aliases = {}
786
+ for fname in glob(pys):
787
+ module_name, ext = os.path.splitext(os.path.basename(fname))
788
+ module_name = 'numpy.distutils.fcompiler.' + module_name
789
+ __import__ (module_name)
790
+ module = sys.modules[module_name]
791
+ if hasattr(module, 'compilers'):
792
+ for cname in module.compilers:
793
+ klass = getattr(module, cname)
794
+ desc = (klass.compiler_type, klass, klass.description)
795
+ fcompiler_class[klass.compiler_type] = desc
796
+ for alias in klass.compiler_aliases:
797
+ if alias in fcompiler_aliases:
798
+ raise ValueError("alias %r defined for both %s and %s"
799
+ % (alias, klass.__name__,
800
+ fcompiler_aliases[alias][1].__name__))
801
+ fcompiler_aliases[alias] = desc
802
+
803
+ def _find_existing_fcompiler(compiler_types,
804
+ osname=None, platform=None,
805
+ requiref90=False,
806
+ c_compiler=None):
807
+ from numpy.distutils.core import get_distribution
808
+ dist = get_distribution(always=True)
809
+ for compiler_type in compiler_types:
810
+ v = None
811
+ try:
812
+ c = new_fcompiler(plat=platform, compiler=compiler_type,
813
+ c_compiler=c_compiler)
814
+ c.customize(dist)
815
+ v = c.get_version()
816
+ if requiref90 and c.compiler_f90 is None:
817
+ v = None
818
+ new_compiler = c.suggested_f90_compiler
819
+ if new_compiler:
820
+ log.warn('Trying %r compiler as suggested by %r '
821
+ 'compiler for f90 support.' % (compiler_type,
822
+ new_compiler))
823
+ c = new_fcompiler(plat=platform, compiler=new_compiler,
824
+ c_compiler=c_compiler)
825
+ c.customize(dist)
826
+ v = c.get_version()
827
+ if v is not None:
828
+ compiler_type = new_compiler
829
+ if requiref90 and c.compiler_f90 is None:
830
+ raise ValueError('%s does not support compiling f90 codes, '
831
+ 'skipping.' % (c.__class__.__name__))
832
+ except DistutilsModuleError:
833
+ log.debug("_find_existing_fcompiler: compiler_type='%s' raised DistutilsModuleError", compiler_type)
834
+ except CompilerNotFound:
835
+ log.debug("_find_existing_fcompiler: compiler_type='%s' not found", compiler_type)
836
+ if v is not None:
837
+ return compiler_type
838
+ return None
839
+
840
+ def available_fcompilers_for_platform(osname=None, platform=None):
841
+ if osname is None:
842
+ osname = os.name
843
+ if platform is None:
844
+ platform = sys.platform
845
+ matching_compiler_types = []
846
+ for pattern, compiler_type in _default_compilers:
847
+ if re.match(pattern, platform) or re.match(pattern, osname):
848
+ for ct in compiler_type:
849
+ if ct not in matching_compiler_types:
850
+ matching_compiler_types.append(ct)
851
+ if not matching_compiler_types:
852
+ matching_compiler_types.append('gnu')
853
+ return matching_compiler_types
854
+
855
+ def get_default_fcompiler(osname=None, platform=None, requiref90=False,
856
+ c_compiler=None):
857
+ """Determine the default Fortran compiler to use for the given
858
+ platform."""
859
+ matching_compiler_types = available_fcompilers_for_platform(osname,
860
+ platform)
861
+ log.info("get_default_fcompiler: matching types: '%s'",
862
+ matching_compiler_types)
863
+ compiler_type = _find_existing_fcompiler(matching_compiler_types,
864
+ osname=osname,
865
+ platform=platform,
866
+ requiref90=requiref90,
867
+ c_compiler=c_compiler)
868
+ return compiler_type
869
+
870
+ # Flag to avoid rechecking for Fortran compiler every time
871
+ failed_fcompilers = set()
872
+
873
+ def new_fcompiler(plat=None,
874
+ compiler=None,
875
+ verbose=0,
876
+ dry_run=0,
877
+ force=0,
878
+ requiref90=False,
879
+ c_compiler = None):
880
+ """Generate an instance of some FCompiler subclass for the supplied
881
+ platform/compiler combination.
882
+ """
883
+ global failed_fcompilers
884
+ fcompiler_key = (plat, compiler)
885
+ if fcompiler_key in failed_fcompilers:
886
+ return None
887
+
888
+ load_all_fcompiler_classes()
889
+ if plat is None:
890
+ plat = os.name
891
+ if compiler is None:
892
+ compiler = get_default_fcompiler(plat, requiref90=requiref90,
893
+ c_compiler=c_compiler)
894
+ if compiler in fcompiler_class:
895
+ module_name, klass, long_description = fcompiler_class[compiler]
896
+ elif compiler in fcompiler_aliases:
897
+ module_name, klass, long_description = fcompiler_aliases[compiler]
898
+ else:
899
+ msg = "don't know how to compile Fortran code on platform '%s'" % plat
900
+ if compiler is not None:
901
+ msg = msg + " with '%s' compiler." % compiler
902
+ msg = msg + " Supported compilers are: %s)" \
903
+ % (','.join(fcompiler_class.keys()))
904
+ log.warn(msg)
905
+ failed_fcompilers.add(fcompiler_key)
906
+ return None
907
+
908
+ compiler = klass(verbose=verbose, dry_run=dry_run, force=force)
909
+ compiler.c_compiler = c_compiler
910
+ return compiler
911
+
912
+ def show_fcompilers(dist=None):
913
+ """Print list of available compilers (used by the "--help-fcompiler"
914
+ option to "config_fc").
915
+ """
916
+ if dist is None:
917
+ from distutils.dist import Distribution
918
+ from numpy.distutils.command.config_compiler import config_fc
919
+ dist = Distribution()
920
+ dist.script_name = os.path.basename(sys.argv[0])
921
+ dist.script_args = ['config_fc'] + sys.argv[1:]
922
+ try:
923
+ dist.script_args.remove('--help-fcompiler')
924
+ except ValueError:
925
+ pass
926
+ dist.cmdclass['config_fc'] = config_fc
927
+ dist.parse_config_files()
928
+ dist.parse_command_line()
929
+ compilers = []
930
+ compilers_na = []
931
+ compilers_ni = []
932
+ if not fcompiler_class:
933
+ load_all_fcompiler_classes()
934
+ platform_compilers = available_fcompilers_for_platform()
935
+ for compiler in platform_compilers:
936
+ v = None
937
+ log.set_verbosity(-2)
938
+ try:
939
+ c = new_fcompiler(compiler=compiler, verbose=dist.verbose)
940
+ c.customize(dist)
941
+ v = c.get_version()
942
+ except (DistutilsModuleError, CompilerNotFound) as e:
943
+ log.debug("show_fcompilers: %s not found" % (compiler,))
944
+ log.debug(repr(e))
945
+
946
+ if v is None:
947
+ compilers_na.append(("fcompiler="+compiler, None,
948
+ fcompiler_class[compiler][2]))
949
+ else:
950
+ c.dump_properties()
951
+ compilers.append(("fcompiler="+compiler, None,
952
+ fcompiler_class[compiler][2] + ' (%s)' % v))
953
+
954
+ compilers_ni = list(set(fcompiler_class.keys()) - set(platform_compilers))
955
+ compilers_ni = [("fcompiler="+fc, None, fcompiler_class[fc][2])
956
+ for fc in compilers_ni]
957
+
958
+ compilers.sort()
959
+ compilers_na.sort()
960
+ compilers_ni.sort()
961
+ pretty_printer = FancyGetopt(compilers)
962
+ pretty_printer.print_help("Fortran compilers found:")
963
+ pretty_printer = FancyGetopt(compilers_na)
964
+ pretty_printer.print_help("Compilers available for this "
965
+ "platform, but not found:")
966
+ if compilers_ni:
967
+ pretty_printer = FancyGetopt(compilers_ni)
968
+ pretty_printer.print_help("Compilers not available on this platform:")
969
+ print("For compiler details, run 'config_fc --verbose' setup command.")
970
+
971
+
972
+ def dummy_fortran_file():
973
+ fo, name = make_temp_file(suffix='.f')
974
+ fo.write(" subroutine dummy()\n end\n")
975
+ fo.close()
976
+ return name[:-2]
977
+
978
+
979
+ _has_f_header = re.compile(r'-\*-\s*fortran\s*-\*-', re.I).search
980
+ _has_f90_header = re.compile(r'-\*-\s*f90\s*-\*-', re.I).search
981
+ _has_fix_header = re.compile(r'-\*-\s*fix\s*-\*-', re.I).search
982
+ _free_f90_start = re.compile(r'[^c*!]\s*[^\s\d\t]', re.I).match
983
+
984
+ def is_free_format(file):
985
+ """Check if file is in free format Fortran."""
986
+ # f90 allows both fixed and free format, assuming fixed unless
987
+ # signs of free format are detected.
988
+ result = 0
989
+ with open(file, encoding='latin1') as f:
990
+ line = f.readline()
991
+ n = 10000 # the number of non-comment lines to scan for hints
992
+ if _has_f_header(line) or _has_fix_header(line):
993
+ n = 0
994
+ elif _has_f90_header(line):
995
+ n = 0
996
+ result = 1
997
+ while n>0 and line:
998
+ line = line.rstrip()
999
+ if line and line[0]!='!':
1000
+ n -= 1
1001
+ if (line[0]!='\t' and _free_f90_start(line[:5])) or line[-1:]=='&':
1002
+ result = 1
1003
+ break
1004
+ line = f.readline()
1005
+ return result
1006
+
1007
+ def has_f90_header(src):
1008
+ with open(src, encoding='latin1') as f:
1009
+ line = f.readline()
1010
+ return _has_f90_header(line) or _has_fix_header(line)
1011
+
1012
+ _f77flags_re = re.compile(r'(c|)f77flags\s*\(\s*(?P<fcname>\w+)\s*\)\s*=\s*(?P<fflags>.*)', re.I)
1013
+ def get_f77flags(src):
1014
+ """
1015
+ Search the first 20 lines of fortran 77 code for line pattern
1016
+ `CF77FLAGS(<fcompiler type>)=<f77 flags>`
1017
+ Return a dictionary {<fcompiler type>:<f77 flags>}.
1018
+ """
1019
+ flags = {}
1020
+ with open(src, encoding='latin1') as f:
1021
+ i = 0
1022
+ for line in f:
1023
+ i += 1
1024
+ if i>20: break
1025
+ m = _f77flags_re.match(line)
1026
+ if not m: continue
1027
+ fcname = m.group('fcname').strip()
1028
+ fflags = m.group('fflags').strip()
1029
+ flags[fcname] = split_quoted(fflags)
1030
+ return flags
1031
+
1032
+ # TODO: implement get_f90flags and use it in _compile similarly to get_f77flags
1033
+
1034
+ if __name__ == '__main__':
1035
+ show_fcompilers()
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/absoft.py ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Absoft Corporation ceased operations on 12/31/2022.
3
+ # Thus, all links to <http://www.absoft.com> are invalid.
4
+
5
+ # Notes:
6
+ # - when using -g77 then use -DUNDERSCORE_G77 to compile f2py
7
+ # generated extension modules (works for f2py v2.45.241_1936 and up)
8
+ import os
9
+
10
+ from numpy.distutils.cpuinfo import cpu
11
+ from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
12
+ from numpy.distutils.misc_util import cyg2win32
13
+
14
+ compilers = ['AbsoftFCompiler']
15
+
16
+ class AbsoftFCompiler(FCompiler):
17
+
18
+ compiler_type = 'absoft'
19
+ description = 'Absoft Corp Fortran Compiler'
20
+ #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp'
21
+ version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\
22
+ r' (?P<version>[^\s*,]*)(.*?Absoft Corp|)'
23
+
24
+ # on windows: f90 -V -c dummy.f
25
+ # f90: Copyright Absoft Corporation 1994-1998 mV2; Cray Research, Inc. 1994-1996 CF90 (2.x.x.x f36t87) Version 2.3 Wed Apr 19, 2006 13:05:16
26
+
27
+ # samt5735(8)$ f90 -V -c dummy.f
28
+ # f90: Copyright Absoft Corporation 1994-2002; Absoft Pro FORTRAN Version 8.0
29
+ # Note that fink installs g77 as f77, so need to use f90 for detection.
30
+
31
+ executables = {
32
+ 'version_cmd' : None, # set by update_executables
33
+ 'compiler_f77' : ["f77"],
34
+ 'compiler_fix' : ["f90"],
35
+ 'compiler_f90' : ["f90"],
36
+ 'linker_so' : ["<F90>"],
37
+ 'archiver' : ["ar", "-cr"],
38
+ 'ranlib' : ["ranlib"]
39
+ }
40
+
41
+ if os.name=='nt':
42
+ library_switch = '/out:' #No space after /out:!
43
+
44
+ module_dir_switch = None
45
+ module_include_switch = '-p'
46
+
47
+ def update_executables(self):
48
+ f = cyg2win32(dummy_fortran_file())
49
+ self.executables['version_cmd'] = ['<F90>', '-V', '-c',
50
+ f+'.f', '-o', f+'.o']
51
+
52
+ def get_flags_linker_so(self):
53
+ if os.name=='nt':
54
+ opt = ['/dll']
55
+ # The "-K shared" switches are being left in for pre-9.0 versions
56
+ # of Absoft though I don't think versions earlier than 9 can
57
+ # actually be used to build shared libraries. In fact, version
58
+ # 8 of Absoft doesn't recognize "-K shared" and will fail.
59
+ elif self.get_version() >= '9.0':
60
+ opt = ['-shared']
61
+ else:
62
+ opt = ["-K", "shared"]
63
+ return opt
64
+
65
+ def library_dir_option(self, dir):
66
+ if os.name=='nt':
67
+ return ['-link', '/PATH:%s' % (dir)]
68
+ return "-L" + dir
69
+
70
+ def library_option(self, lib):
71
+ if os.name=='nt':
72
+ return '%s.lib' % (lib)
73
+ return "-l" + lib
74
+
75
+ def get_library_dirs(self):
76
+ opt = FCompiler.get_library_dirs(self)
77
+ d = os.environ.get('ABSOFT')
78
+ if d:
79
+ if self.get_version() >= '10.0':
80
+ # use shared libraries, the static libraries were not compiled -fPIC
81
+ prefix = 'sh'
82
+ else:
83
+ prefix = ''
84
+ if cpu.is_64bit():
85
+ suffix = '64'
86
+ else:
87
+ suffix = ''
88
+ opt.append(os.path.join(d, '%slib%s' % (prefix, suffix)))
89
+ return opt
90
+
91
+ def get_libraries(self):
92
+ opt = FCompiler.get_libraries(self)
93
+ if self.get_version() >= '11.0':
94
+ opt.extend(['af90math', 'afio', 'af77math', 'amisc'])
95
+ elif self.get_version() >= '10.0':
96
+ opt.extend(['af90math', 'afio', 'af77math', 'U77'])
97
+ elif self.get_version() >= '8.0':
98
+ opt.extend(['f90math', 'fio', 'f77math', 'U77'])
99
+ else:
100
+ opt.extend(['fio', 'f90math', 'fmath', 'U77'])
101
+ if os.name =='nt':
102
+ opt.append('COMDLG32')
103
+ return opt
104
+
105
+ def get_flags(self):
106
+ opt = FCompiler.get_flags(self)
107
+ if os.name != 'nt':
108
+ opt.extend(['-s'])
109
+ if self.get_version():
110
+ if self.get_version()>='8.2':
111
+ opt.append('-fpic')
112
+ return opt
113
+
114
+ def get_flags_f77(self):
115
+ opt = FCompiler.get_flags_f77(self)
116
+ opt.extend(['-N22', '-N90', '-N110'])
117
+ v = self.get_version()
118
+ if os.name == 'nt':
119
+ if v and v>='8.0':
120
+ opt.extend(['-f', '-N15'])
121
+ else:
122
+ opt.append('-f')
123
+ if v:
124
+ if v<='4.6':
125
+ opt.append('-B108')
126
+ else:
127
+ # Though -N15 is undocumented, it works with
128
+ # Absoft 8.0 on Linux
129
+ opt.append('-N15')
130
+ return opt
131
+
132
+ def get_flags_f90(self):
133
+ opt = FCompiler.get_flags_f90(self)
134
+ opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX",
135
+ "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"])
136
+ if self.get_version():
137
+ if self.get_version()>'4.6':
138
+ opt.extend(["-YDEALLOC=ALL"])
139
+ return opt
140
+
141
+ def get_flags_fix(self):
142
+ opt = FCompiler.get_flags_fix(self)
143
+ opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX",
144
+ "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"])
145
+ opt.extend(["-f", "fixed"])
146
+ return opt
147
+
148
+ def get_flags_opt(self):
149
+ opt = ['-O']
150
+ return opt
151
+
152
+ if __name__ == '__main__':
153
+ from distutils import log
154
+ log.set_verbosity(2)
155
+ from numpy.distutils import customized_fcompiler
156
+ print(customized_fcompiler(compiler='absoft').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/arm.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
4
+ from sys import platform
5
+ from os.path import join, dirname, normpath
6
+
7
+ compilers = ['ArmFlangCompiler']
8
+
9
+ import functools
10
+
11
+ class ArmFlangCompiler(FCompiler):
12
+ compiler_type = 'arm'
13
+ description = 'Arm Compiler'
14
+ version_pattern = r'\s*Arm.*version (?P<version>[\d.-]+).*'
15
+
16
+ ar_exe = 'lib.exe'
17
+ possible_executables = ['armflang']
18
+
19
+ executables = {
20
+ 'version_cmd': ["", "--version"],
21
+ 'compiler_f77': ["armflang", "-fPIC"],
22
+ 'compiler_fix': ["armflang", "-fPIC", "-ffixed-form"],
23
+ 'compiler_f90': ["armflang", "-fPIC"],
24
+ 'linker_so': ["armflang", "-fPIC", "-shared"],
25
+ 'archiver': ["ar", "-cr"],
26
+ 'ranlib': None
27
+ }
28
+
29
+ pic_flags = ["-fPIC", "-DPIC"]
30
+ c_compiler = 'arm'
31
+ module_dir_switch = '-module ' # Don't remove ending space!
32
+
33
+ def get_libraries(self):
34
+ opt = FCompiler.get_libraries(self)
35
+ opt.extend(['flang', 'flangrti', 'ompstub'])
36
+ return opt
37
+
38
+ @functools.lru_cache(maxsize=128)
39
+ def get_library_dirs(self):
40
+ """List of compiler library directories."""
41
+ opt = FCompiler.get_library_dirs(self)
42
+ flang_dir = dirname(self.executables['compiler_f77'][0])
43
+ opt.append(normpath(join(flang_dir, '..', 'lib')))
44
+
45
+ return opt
46
+
47
+ def get_flags(self):
48
+ return []
49
+
50
+ def get_flags_free(self):
51
+ return []
52
+
53
+ def get_flags_debug(self):
54
+ return ['-g']
55
+
56
+ def get_flags_opt(self):
57
+ return ['-O3']
58
+
59
+ def get_flags_arch(self):
60
+ return []
61
+
62
+ def runtime_library_dir_option(self, dir):
63
+ return '-Wl,-rpath=%s' % dir
64
+
65
+
66
+ if __name__ == '__main__':
67
+ from distutils import log
68
+ log.set_verbosity(2)
69
+ from numpy.distutils import customized_fcompiler
70
+ print(customized_fcompiler(compiler='armflang').get_version())
71
+
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/compaq.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #http://www.compaq.com/fortran/docs/
3
+ import os
4
+ import sys
5
+
6
+ from numpy.distutils.fcompiler import FCompiler
7
+ from distutils.errors import DistutilsPlatformError
8
+
9
+ compilers = ['CompaqFCompiler']
10
+ if os.name != 'posix' or sys.platform[:6] == 'cygwin' :
11
+ # Otherwise we'd get a false positive on posix systems with
12
+ # case-insensitive filesystems (like darwin), because we'll pick
13
+ # up /bin/df
14
+ compilers.append('CompaqVisualFCompiler')
15
+
16
+ class CompaqFCompiler(FCompiler):
17
+
18
+ compiler_type = 'compaq'
19
+ description = 'Compaq Fortran Compiler'
20
+ version_pattern = r'Compaq Fortran (?P<version>[^\s]*).*'
21
+
22
+ if sys.platform[:5]=='linux':
23
+ fc_exe = 'fort'
24
+ else:
25
+ fc_exe = 'f90'
26
+
27
+ executables = {
28
+ 'version_cmd' : ['<F90>', "-version"],
29
+ 'compiler_f77' : [fc_exe, "-f77rtl", "-fixed"],
30
+ 'compiler_fix' : [fc_exe, "-fixed"],
31
+ 'compiler_f90' : [fc_exe],
32
+ 'linker_so' : ['<F90>'],
33
+ 'archiver' : ["ar", "-cr"],
34
+ 'ranlib' : ["ranlib"]
35
+ }
36
+
37
+ module_dir_switch = '-module ' # not tested
38
+ module_include_switch = '-I'
39
+
40
+ def get_flags(self):
41
+ return ['-assume no2underscore', '-nomixed_str_len_arg']
42
+ def get_flags_debug(self):
43
+ return ['-g', '-check bounds']
44
+ def get_flags_opt(self):
45
+ return ['-O4', '-align dcommons', '-assume bigarrays',
46
+ '-assume nozsize', '-math_library fast']
47
+ def get_flags_arch(self):
48
+ return ['-arch host', '-tune host']
49
+ def get_flags_linker_so(self):
50
+ if sys.platform[:5]=='linux':
51
+ return ['-shared']
52
+ return ['-shared', '-Wl,-expect_unresolved,*']
53
+
54
+ class CompaqVisualFCompiler(FCompiler):
55
+
56
+ compiler_type = 'compaqv'
57
+ description = 'DIGITAL or Compaq Visual Fortran Compiler'
58
+ version_pattern = (r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'
59
+ r' Version (?P<version>[^\s]*).*')
60
+
61
+ compile_switch = '/compile_only'
62
+ object_switch = '/object:'
63
+ library_switch = '/OUT:' #No space after /OUT:!
64
+
65
+ static_lib_extension = ".lib"
66
+ static_lib_format = "%s%s"
67
+ module_dir_switch = '/module:'
68
+ module_include_switch = '/I'
69
+
70
+ ar_exe = 'lib.exe'
71
+ fc_exe = 'DF'
72
+
73
+ if sys.platform=='win32':
74
+ from numpy.distutils.msvccompiler import MSVCCompiler
75
+
76
+ try:
77
+ m = MSVCCompiler()
78
+ m.initialize()
79
+ ar_exe = m.lib
80
+ except DistutilsPlatformError:
81
+ pass
82
+ except AttributeError as e:
83
+ if '_MSVCCompiler__root' in str(e):
84
+ print('Ignoring "%s" (I think it is msvccompiler.py bug)' % (e))
85
+ else:
86
+ raise
87
+ except OSError as e:
88
+ if not "vcvarsall.bat" in str(e):
89
+ print("Unexpected OSError in", __file__)
90
+ raise
91
+ except ValueError as e:
92
+ if not "'path'" in str(e):
93
+ print("Unexpected ValueError in", __file__)
94
+ raise
95
+
96
+ executables = {
97
+ 'version_cmd' : ['<F90>', "/what"],
98
+ 'compiler_f77' : [fc_exe, "/f77rtl", "/fixed"],
99
+ 'compiler_fix' : [fc_exe, "/fixed"],
100
+ 'compiler_f90' : [fc_exe],
101
+ 'linker_so' : ['<F90>'],
102
+ 'archiver' : [ar_exe, "/OUT:"],
103
+ 'ranlib' : None
104
+ }
105
+
106
+ def get_flags(self):
107
+ return ['/nologo', '/MD', '/WX', '/iface=(cref,nomixed_str_len_arg)',
108
+ '/names:lowercase', '/assume:underscore']
109
+ def get_flags_opt(self):
110
+ return ['/Ox', '/fast', '/optimize:5', '/unroll:0', '/math_library:fast']
111
+ def get_flags_arch(self):
112
+ return ['/threads']
113
+ def get_flags_debug(self):
114
+ return ['/debug']
115
+
116
+ if __name__ == '__main__':
117
+ from distutils import log
118
+ log.set_verbosity(2)
119
+ from numpy.distutils import customized_fcompiler
120
+ print(customized_fcompiler(compiler='compaq').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/environment.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from distutils.dist import Distribution
3
+
4
+ __metaclass__ = type
5
+
6
+ class EnvironmentConfig:
7
+ def __init__(self, distutils_section='ALL', **kw):
8
+ self._distutils_section = distutils_section
9
+ self._conf_keys = kw
10
+ self._conf = None
11
+ self._hook_handler = None
12
+
13
+ def dump_variable(self, name):
14
+ conf_desc = self._conf_keys[name]
15
+ hook, envvar, confvar, convert, append = conf_desc
16
+ if not convert:
17
+ convert = lambda x : x
18
+ print('%s.%s:' % (self._distutils_section, name))
19
+ v = self._hook_handler(name, hook)
20
+ print(' hook : %s' % (convert(v),))
21
+ if envvar:
22
+ v = os.environ.get(envvar, None)
23
+ print(' environ: %s' % (convert(v),))
24
+ if confvar and self._conf:
25
+ v = self._conf.get(confvar, (None, None))[1]
26
+ print(' config : %s' % (convert(v),))
27
+
28
+ def dump_variables(self):
29
+ for name in self._conf_keys:
30
+ self.dump_variable(name)
31
+
32
+ def __getattr__(self, name):
33
+ try:
34
+ conf_desc = self._conf_keys[name]
35
+ except KeyError:
36
+ raise AttributeError(
37
+ f"'EnvironmentConfig' object has no attribute '{name}'"
38
+ ) from None
39
+
40
+ return self._get_var(name, conf_desc)
41
+
42
+ def get(self, name, default=None):
43
+ try:
44
+ conf_desc = self._conf_keys[name]
45
+ except KeyError:
46
+ return default
47
+ var = self._get_var(name, conf_desc)
48
+ if var is None:
49
+ var = default
50
+ return var
51
+
52
+ def _get_var(self, name, conf_desc):
53
+ hook, envvar, confvar, convert, append = conf_desc
54
+ if convert is None:
55
+ convert = lambda x: x
56
+ var = self._hook_handler(name, hook)
57
+ if envvar is not None:
58
+ envvar_contents = os.environ.get(envvar)
59
+ if envvar_contents is not None:
60
+ envvar_contents = convert(envvar_contents)
61
+ if var and append:
62
+ if os.environ.get('NPY_DISTUTILS_APPEND_FLAGS', '1') == '1':
63
+ var.extend(envvar_contents)
64
+ else:
65
+ # NPY_DISTUTILS_APPEND_FLAGS was explicitly set to 0
66
+ # to keep old (overwrite flags rather than append to
67
+ # them) behavior
68
+ var = envvar_contents
69
+ else:
70
+ var = envvar_contents
71
+ if confvar is not None and self._conf:
72
+ if confvar in self._conf:
73
+ source, confvar_contents = self._conf[confvar]
74
+ var = convert(confvar_contents)
75
+ return var
76
+
77
+
78
+ def clone(self, hook_handler):
79
+ ec = self.__class__(distutils_section=self._distutils_section,
80
+ **self._conf_keys)
81
+ ec._hook_handler = hook_handler
82
+ return ec
83
+
84
+ def use_distribution(self, dist):
85
+ if isinstance(dist, Distribution):
86
+ self._conf = dist.get_option_dict(self._distutils_section)
87
+ else:
88
+ self._conf = dist
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/fujitsu.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ fujitsu
3
+
4
+ Supports Fujitsu compiler function.
5
+ This compiler is developed by Fujitsu and is used in A64FX on Fugaku.
6
+ """
7
+ from numpy.distutils.fcompiler import FCompiler
8
+
9
+ compilers = ['FujitsuFCompiler']
10
+
11
+ class FujitsuFCompiler(FCompiler):
12
+ compiler_type = 'fujitsu'
13
+ description = 'Fujitsu Fortran Compiler'
14
+
15
+ possible_executables = ['frt']
16
+ version_pattern = r'frt \(FRT\) (?P<version>[a-z\d.]+)'
17
+ # $ frt --version
18
+ # frt (FRT) x.x.x yyyymmdd
19
+
20
+ executables = {
21
+ 'version_cmd' : ["<F77>", "--version"],
22
+ 'compiler_f77' : ["frt", "-Fixed"],
23
+ 'compiler_fix' : ["frt", "-Fixed"],
24
+ 'compiler_f90' : ["frt"],
25
+ 'linker_so' : ["frt", "-shared"],
26
+ 'archiver' : ["ar", "-cr"],
27
+ 'ranlib' : ["ranlib"]
28
+ }
29
+ pic_flags = ['-KPIC']
30
+ module_dir_switch = '-M'
31
+ module_include_switch = '-I'
32
+
33
+ def get_flags_opt(self):
34
+ return ['-O3']
35
+ def get_flags_debug(self):
36
+ return ['-g']
37
+ def runtime_library_dir_option(self, dir):
38
+ return f'-Wl,-rpath={dir}'
39
+ def get_libraries(self):
40
+ return ['fj90f', 'fj90i', 'fjsrcinfo']
41
+
42
+ if __name__ == '__main__':
43
+ from distutils import log
44
+ from numpy.distutils import customized_fcompiler
45
+ log.set_verbosity(2)
46
+ print(customized_fcompiler('fujitsu').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/g95.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # http://g95.sourceforge.net/
2
+ from numpy.distutils.fcompiler import FCompiler
3
+
4
+ compilers = ['G95FCompiler']
5
+
6
+ class G95FCompiler(FCompiler):
7
+ compiler_type = 'g95'
8
+ description = 'G95 Fortran Compiler'
9
+
10
+ # version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*'
11
+ # $ g95 --version
12
+ # G95 (GCC 4.0.3 (g95!) May 22 2006)
13
+
14
+ version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95 (?P<version>.*)!\) (?P<date>.*)\).*'
15
+ # $ g95 --version
16
+ # G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006)
17
+
18
+ executables = {
19
+ 'version_cmd' : ["<F90>", "--version"],
20
+ 'compiler_f77' : ["g95", "-ffixed-form"],
21
+ 'compiler_fix' : ["g95", "-ffixed-form"],
22
+ 'compiler_f90' : ["g95"],
23
+ 'linker_so' : ["<F90>", "-shared"],
24
+ 'archiver' : ["ar", "-cr"],
25
+ 'ranlib' : ["ranlib"]
26
+ }
27
+ pic_flags = ['-fpic']
28
+ module_dir_switch = '-fmod='
29
+ module_include_switch = '-I'
30
+
31
+ def get_flags(self):
32
+ return ['-fno-second-underscore']
33
+ def get_flags_opt(self):
34
+ return ['-O']
35
+ def get_flags_debug(self):
36
+ return ['-g']
37
+
38
+ if __name__ == '__main__':
39
+ from distutils import log
40
+ from numpy.distutils import customized_fcompiler
41
+ log.set_verbosity(2)
42
+ print(customized_fcompiler('g95').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/gnu.py ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import os
3
+ import sys
4
+ import warnings
5
+ import platform
6
+ import tempfile
7
+ import hashlib
8
+ import base64
9
+ import subprocess
10
+ from subprocess import Popen, PIPE, STDOUT
11
+ from numpy.distutils.exec_command import filepath_from_subprocess_output
12
+ from numpy.distutils.fcompiler import FCompiler
13
+ from distutils.version import LooseVersion
14
+
15
+ compilers = ['GnuFCompiler', 'Gnu95FCompiler']
16
+
17
+ TARGET_R = re.compile(r"Target: ([a-zA-Z0-9_\-]*)")
18
+
19
+ # XXX: handle cross compilation
20
+
21
+
22
+ def is_win64():
23
+ return sys.platform == "win32" and platform.architecture()[0] == "64bit"
24
+
25
+
26
+ class GnuFCompiler(FCompiler):
27
+ compiler_type = 'gnu'
28
+ compiler_aliases = ('g77', )
29
+ description = 'GNU Fortran 77 compiler'
30
+
31
+ def gnu_version_match(self, version_string):
32
+ """Handle the different versions of GNU fortran compilers"""
33
+ # Strip warning(s) that may be emitted by gfortran
34
+ while version_string.startswith('gfortran: warning'):
35
+ version_string =\
36
+ version_string[version_string.find('\n') + 1:].strip()
37
+
38
+ # Gfortran versions from after 2010 will output a simple string
39
+ # (usually "x.y", "x.y.z" or "x.y.z-q") for ``-dumpversion``; older
40
+ # gfortrans may still return long version strings (``-dumpversion`` was
41
+ # an alias for ``--version``)
42
+ if len(version_string) <= 20:
43
+ # Try to find a valid version string
44
+ m = re.search(r'([0-9.]+)', version_string)
45
+ if m:
46
+ # g77 provides a longer version string that starts with GNU
47
+ # Fortran
48
+ if version_string.startswith('GNU Fortran'):
49
+ return ('g77', m.group(1))
50
+
51
+ # gfortran only outputs a version string such as #.#.#, so check
52
+ # if the match is at the start of the string
53
+ elif m.start() == 0:
54
+ return ('gfortran', m.group(1))
55
+ else:
56
+ # Output probably from --version, try harder:
57
+ m = re.search(r'GNU Fortran\s+95.*?([0-9-.]+)', version_string)
58
+ if m:
59
+ return ('gfortran', m.group(1))
60
+ m = re.search(
61
+ r'GNU Fortran.*?\-?([0-9-.]+\.[0-9-.]+)', version_string)
62
+ if m:
63
+ v = m.group(1)
64
+ if v.startswith('0') or v.startswith('2') or v.startswith('3'):
65
+ # the '0' is for early g77's
66
+ return ('g77', v)
67
+ else:
68
+ # at some point in the 4.x series, the ' 95' was dropped
69
+ # from the version string
70
+ return ('gfortran', v)
71
+
72
+ # If still nothing, raise an error to make the problem easy to find.
73
+ err = 'A valid Fortran version was not found in this string:\n'
74
+ raise ValueError(err + version_string)
75
+
76
+ def version_match(self, version_string):
77
+ v = self.gnu_version_match(version_string)
78
+ if not v or v[0] != 'g77':
79
+ return None
80
+ return v[1]
81
+
82
+ possible_executables = ['g77', 'f77']
83
+ executables = {
84
+ 'version_cmd' : [None, "-dumpversion"],
85
+ 'compiler_f77' : [None, "-g", "-Wall", "-fno-second-underscore"],
86
+ 'compiler_f90' : None, # Use --fcompiler=gnu95 for f90 codes
87
+ 'compiler_fix' : None,
88
+ 'linker_so' : [None, "-g", "-Wall"],
89
+ 'archiver' : ["ar", "-cr"],
90
+ 'ranlib' : ["ranlib"],
91
+ 'linker_exe' : [None, "-g", "-Wall"]
92
+ }
93
+ module_dir_switch = None
94
+ module_include_switch = None
95
+
96
+ # Cygwin: f771: warning: -fPIC ignored for target (all code is
97
+ # position independent)
98
+ if os.name != 'nt' and sys.platform != 'cygwin':
99
+ pic_flags = ['-fPIC']
100
+
101
+ # use -mno-cygwin for g77 when Python is not Cygwin-Python
102
+ if sys.platform == 'win32':
103
+ for key in ['version_cmd', 'compiler_f77', 'linker_so', 'linker_exe']:
104
+ executables[key].append('-mno-cygwin')
105
+
106
+ g2c = 'g2c'
107
+ suggested_f90_compiler = 'gnu95'
108
+
109
+ def get_flags_linker_so(self):
110
+ opt = self.linker_so[1:]
111
+ if sys.platform == 'darwin':
112
+ target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None)
113
+ # If MACOSX_DEPLOYMENT_TARGET is set, we simply trust the value
114
+ # and leave it alone. But, distutils will complain if the
115
+ # environment's value is different from the one in the Python
116
+ # Makefile used to build Python. We let distutils handle this
117
+ # error checking.
118
+ if not target:
119
+ # If MACOSX_DEPLOYMENT_TARGET is not set in the environment,
120
+ # we try to get it first from sysconfig and then
121
+ # fall back to setting it to 10.9 This is a reasonable default
122
+ # even when using the official Python dist and those derived
123
+ # from it.
124
+ import sysconfig
125
+ target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
126
+ if not target:
127
+ target = '10.9'
128
+ s = f'Env. variable MACOSX_DEPLOYMENT_TARGET set to {target}'
129
+ warnings.warn(s, stacklevel=2)
130
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = str(target)
131
+ opt.extend(['-undefined', 'dynamic_lookup', '-bundle'])
132
+ else:
133
+ opt.append("-shared")
134
+ if sys.platform.startswith('sunos'):
135
+ # SunOS often has dynamically loaded symbols defined in the
136
+ # static library libg2c.a The linker doesn't like this. To
137
+ # ignore the problem, use the -mimpure-text flag. It isn't
138
+ # the safest thing, but seems to work. 'man gcc' says:
139
+ # ".. Instead of using -mimpure-text, you should compile all
140
+ # source code with -fpic or -fPIC."
141
+ opt.append('-mimpure-text')
142
+ return opt
143
+
144
+ def get_libgcc_dir(self):
145
+ try:
146
+ output = subprocess.check_output(self.compiler_f77 +
147
+ ['-print-libgcc-file-name'])
148
+ except (OSError, subprocess.CalledProcessError):
149
+ pass
150
+ else:
151
+ output = filepath_from_subprocess_output(output)
152
+ return os.path.dirname(output)
153
+ return None
154
+
155
+ def get_libgfortran_dir(self):
156
+ if sys.platform[:5] == 'linux':
157
+ libgfortran_name = 'libgfortran.so'
158
+ elif sys.platform == 'darwin':
159
+ libgfortran_name = 'libgfortran.dylib'
160
+ else:
161
+ libgfortran_name = None
162
+
163
+ libgfortran_dir = None
164
+ if libgfortran_name:
165
+ find_lib_arg = ['-print-file-name={0}'.format(libgfortran_name)]
166
+ try:
167
+ output = subprocess.check_output(
168
+ self.compiler_f77 + find_lib_arg)
169
+ except (OSError, subprocess.CalledProcessError):
170
+ pass
171
+ else:
172
+ output = filepath_from_subprocess_output(output)
173
+ libgfortran_dir = os.path.dirname(output)
174
+ return libgfortran_dir
175
+
176
+ def get_library_dirs(self):
177
+ opt = []
178
+ if sys.platform[:5] != 'linux':
179
+ d = self.get_libgcc_dir()
180
+ if d:
181
+ # if windows and not cygwin, libg2c lies in a different folder
182
+ if sys.platform == 'win32' and not d.startswith('/usr/lib'):
183
+ d = os.path.normpath(d)
184
+ path = os.path.join(d, "lib%s.a" % self.g2c)
185
+ if not os.path.exists(path):
186
+ root = os.path.join(d, *((os.pardir, ) * 4))
187
+ d2 = os.path.abspath(os.path.join(root, 'lib'))
188
+ path = os.path.join(d2, "lib%s.a" % self.g2c)
189
+ if os.path.exists(path):
190
+ opt.append(d2)
191
+ opt.append(d)
192
+ # For Macports / Linux, libgfortran and libgcc are not co-located
193
+ lib_gfortran_dir = self.get_libgfortran_dir()
194
+ if lib_gfortran_dir:
195
+ opt.append(lib_gfortran_dir)
196
+ return opt
197
+
198
+ def get_libraries(self):
199
+ opt = []
200
+ d = self.get_libgcc_dir()
201
+ if d is not None:
202
+ g2c = self.g2c + '-pic'
203
+ f = self.static_lib_format % (g2c, self.static_lib_extension)
204
+ if not os.path.isfile(os.path.join(d, f)):
205
+ g2c = self.g2c
206
+ else:
207
+ g2c = self.g2c
208
+
209
+ if g2c is not None:
210
+ opt.append(g2c)
211
+ c_compiler = self.c_compiler
212
+ if sys.platform == 'win32' and c_compiler and \
213
+ c_compiler.compiler_type == 'msvc':
214
+ opt.append('gcc')
215
+ if sys.platform == 'darwin':
216
+ opt.append('cc_dynamic')
217
+ return opt
218
+
219
+ def get_flags_debug(self):
220
+ return ['-g']
221
+
222
+ def get_flags_opt(self):
223
+ v = self.get_version()
224
+ if v and v <= '3.3.3':
225
+ # With this compiler version building Fortran BLAS/LAPACK
226
+ # with -O3 caused failures in lib.lapack heevr,syevr tests.
227
+ opt = ['-O2']
228
+ else:
229
+ opt = ['-O3']
230
+ opt.append('-funroll-loops')
231
+ return opt
232
+
233
+ def _c_arch_flags(self):
234
+ """ Return detected arch flags from CFLAGS """
235
+ import sysconfig
236
+ try:
237
+ cflags = sysconfig.get_config_vars()['CFLAGS']
238
+ except KeyError:
239
+ return []
240
+ arch_re = re.compile(r"-arch\s+(\w+)")
241
+ arch_flags = []
242
+ for arch in arch_re.findall(cflags):
243
+ arch_flags += ['-arch', arch]
244
+ return arch_flags
245
+
246
+ def get_flags_arch(self):
247
+ return []
248
+
249
+ def runtime_library_dir_option(self, dir):
250
+ if sys.platform == 'win32' or sys.platform == 'cygwin':
251
+ # Linux/Solaris/Unix support RPATH, Windows does not
252
+ raise NotImplementedError
253
+
254
+ # TODO: could use -Xlinker here, if it's supported
255
+ assert "," not in dir
256
+
257
+ if sys.platform == 'darwin':
258
+ return f'-Wl,-rpath,{dir}'
259
+ elif sys.platform.startswith(('aix', 'os400')):
260
+ # AIX RPATH is called LIBPATH
261
+ return f'-Wl,-blibpath:{dir}'
262
+ else:
263
+ return f'-Wl,-rpath={dir}'
264
+
265
+
266
+ class Gnu95FCompiler(GnuFCompiler):
267
+ compiler_type = 'gnu95'
268
+ compiler_aliases = ('gfortran', )
269
+ description = 'GNU Fortran 95 compiler'
270
+
271
+ def version_match(self, version_string):
272
+ v = self.gnu_version_match(version_string)
273
+ if not v or v[0] != 'gfortran':
274
+ return None
275
+ v = v[1]
276
+ if LooseVersion(v) >= "4":
277
+ # gcc-4 series releases do not support -mno-cygwin option
278
+ pass
279
+ else:
280
+ # use -mno-cygwin flag for gfortran when Python is not
281
+ # Cygwin-Python
282
+ if sys.platform == 'win32':
283
+ for key in [
284
+ 'version_cmd', 'compiler_f77', 'compiler_f90',
285
+ 'compiler_fix', 'linker_so', 'linker_exe'
286
+ ]:
287
+ self.executables[key].append('-mno-cygwin')
288
+ return v
289
+
290
+ possible_executables = ['gfortran', 'f95']
291
+ executables = {
292
+ 'version_cmd' : ["<F90>", "-dumpversion"],
293
+ 'compiler_f77' : [None, "-Wall", "-g", "-ffixed-form",
294
+ "-fno-second-underscore"],
295
+ 'compiler_f90' : [None, "-Wall", "-g",
296
+ "-fno-second-underscore"],
297
+ 'compiler_fix' : [None, "-Wall", "-g","-ffixed-form",
298
+ "-fno-second-underscore"],
299
+ 'linker_so' : ["<F90>", "-Wall", "-g"],
300
+ 'archiver' : ["ar", "-cr"],
301
+ 'ranlib' : ["ranlib"],
302
+ 'linker_exe' : [None, "-Wall"]
303
+ }
304
+
305
+ module_dir_switch = '-J'
306
+ module_include_switch = '-I'
307
+
308
+ if sys.platform.startswith(('aix', 'os400')):
309
+ executables['linker_so'].append('-lpthread')
310
+ if platform.architecture()[0][:2] == '64':
311
+ for key in ['compiler_f77', 'compiler_f90','compiler_fix','linker_so', 'linker_exe']:
312
+ executables[key].append('-maix64')
313
+
314
+ g2c = 'gfortran'
315
+
316
+ def _universal_flags(self, cmd):
317
+ """Return a list of -arch flags for every supported architecture."""
318
+ if not sys.platform == 'darwin':
319
+ return []
320
+ arch_flags = []
321
+ # get arches the C compiler gets.
322
+ c_archs = self._c_arch_flags()
323
+ if "i386" in c_archs:
324
+ c_archs[c_archs.index("i386")] = "i686"
325
+ # check the arches the Fortran compiler supports, and compare with
326
+ # arch flags from C compiler
327
+ for arch in ["ppc", "i686", "x86_64", "ppc64", "s390x"]:
328
+ if _can_target(cmd, arch) and arch in c_archs:
329
+ arch_flags.extend(["-arch", arch])
330
+ return arch_flags
331
+
332
+ def get_flags(self):
333
+ flags = GnuFCompiler.get_flags(self)
334
+ arch_flags = self._universal_flags(self.compiler_f90)
335
+ if arch_flags:
336
+ flags[:0] = arch_flags
337
+ return flags
338
+
339
+ def get_flags_linker_so(self):
340
+ flags = GnuFCompiler.get_flags_linker_so(self)
341
+ arch_flags = self._universal_flags(self.linker_so)
342
+ if arch_flags:
343
+ flags[:0] = arch_flags
344
+ return flags
345
+
346
+ def get_library_dirs(self):
347
+ opt = GnuFCompiler.get_library_dirs(self)
348
+ if sys.platform == 'win32':
349
+ c_compiler = self.c_compiler
350
+ if c_compiler and c_compiler.compiler_type == "msvc":
351
+ target = self.get_target()
352
+ if target:
353
+ d = os.path.normpath(self.get_libgcc_dir())
354
+ root = os.path.join(d, *((os.pardir, ) * 4))
355
+ path = os.path.join(root, "lib")
356
+ mingwdir = os.path.normpath(path)
357
+ if os.path.exists(os.path.join(mingwdir, "libmingwex.a")):
358
+ opt.append(mingwdir)
359
+ # For Macports / Linux, libgfortran and libgcc are not co-located
360
+ lib_gfortran_dir = self.get_libgfortran_dir()
361
+ if lib_gfortran_dir:
362
+ opt.append(lib_gfortran_dir)
363
+ return opt
364
+
365
+ def get_libraries(self):
366
+ opt = GnuFCompiler.get_libraries(self)
367
+ if sys.platform == 'darwin':
368
+ opt.remove('cc_dynamic')
369
+ if sys.platform == 'win32':
370
+ c_compiler = self.c_compiler
371
+ if c_compiler and c_compiler.compiler_type == "msvc":
372
+ if "gcc" in opt:
373
+ i = opt.index("gcc")
374
+ opt.insert(i + 1, "mingwex")
375
+ opt.insert(i + 1, "mingw32")
376
+ c_compiler = self.c_compiler
377
+ if c_compiler and c_compiler.compiler_type == "msvc":
378
+ return []
379
+ else:
380
+ pass
381
+ return opt
382
+
383
+ def get_target(self):
384
+ try:
385
+ p = subprocess.Popen(
386
+ self.compiler_f77 + ['-v'],
387
+ stdin=subprocess.PIPE,
388
+ stderr=subprocess.PIPE,
389
+ )
390
+ stdout, stderr = p.communicate()
391
+ output = (stdout or b"") + (stderr or b"")
392
+ except (OSError, subprocess.CalledProcessError):
393
+ pass
394
+ else:
395
+ output = filepath_from_subprocess_output(output)
396
+ m = TARGET_R.search(output)
397
+ if m:
398
+ return m.group(1)
399
+ return ""
400
+
401
+ def _hash_files(self, filenames):
402
+ h = hashlib.sha1()
403
+ for fn in filenames:
404
+ with open(fn, 'rb') as f:
405
+ while True:
406
+ block = f.read(131072)
407
+ if not block:
408
+ break
409
+ h.update(block)
410
+ text = base64.b32encode(h.digest())
411
+ text = text.decode('ascii')
412
+ return text.rstrip('=')
413
+
414
+ def _link_wrapper_lib(self, objects, output_dir, extra_dll_dir,
415
+ chained_dlls, is_archive):
416
+ """Create a wrapper shared library for the given objects
417
+
418
+ Return an MSVC-compatible lib
419
+ """
420
+
421
+ c_compiler = self.c_compiler
422
+ if c_compiler.compiler_type != "msvc":
423
+ raise ValueError("This method only supports MSVC")
424
+
425
+ object_hash = self._hash_files(list(objects) + list(chained_dlls))
426
+
427
+ if is_win64():
428
+ tag = 'win_amd64'
429
+ else:
430
+ tag = 'win32'
431
+
432
+ basename = 'lib' + os.path.splitext(
433
+ os.path.basename(objects[0]))[0][:8]
434
+ root_name = basename + '.' + object_hash + '.gfortran-' + tag
435
+ dll_name = root_name + '.dll'
436
+ def_name = root_name + '.def'
437
+ lib_name = root_name + '.lib'
438
+ dll_path = os.path.join(extra_dll_dir, dll_name)
439
+ def_path = os.path.join(output_dir, def_name)
440
+ lib_path = os.path.join(output_dir, lib_name)
441
+
442
+ if os.path.isfile(lib_path):
443
+ # Nothing to do
444
+ return lib_path, dll_path
445
+
446
+ if is_archive:
447
+ objects = (["-Wl,--whole-archive"] + list(objects) +
448
+ ["-Wl,--no-whole-archive"])
449
+ self.link_shared_object(
450
+ objects,
451
+ dll_name,
452
+ output_dir=extra_dll_dir,
453
+ extra_postargs=list(chained_dlls) + [
454
+ '-Wl,--allow-multiple-definition',
455
+ '-Wl,--output-def,' + def_path,
456
+ '-Wl,--export-all-symbols',
457
+ '-Wl,--enable-auto-import',
458
+ '-static',
459
+ '-mlong-double-64',
460
+ ])
461
+
462
+ # No PowerPC!
463
+ if is_win64():
464
+ specifier = '/MACHINE:X64'
465
+ else:
466
+ specifier = '/MACHINE:X86'
467
+
468
+ # MSVC specific code
469
+ lib_args = ['/def:' + def_path, '/OUT:' + lib_path, specifier]
470
+ if not c_compiler.initialized:
471
+ c_compiler.initialize()
472
+ c_compiler.spawn([c_compiler.lib] + lib_args)
473
+
474
+ return lib_path, dll_path
475
+
476
+ def can_ccompiler_link(self, compiler):
477
+ # MSVC cannot link objects compiled by GNU fortran
478
+ return compiler.compiler_type not in ("msvc", )
479
+
480
+ def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir):
481
+ """
482
+ Convert a set of object files that are not compatible with the default
483
+ linker, to a file that is compatible.
484
+ """
485
+ if self.c_compiler.compiler_type == "msvc":
486
+ # Compile a DLL and return the lib for the DLL as
487
+ # the object. Also keep track of previous DLLs that
488
+ # we have compiled so that we can link against them.
489
+
490
+ # If there are .a archives, assume they are self-contained
491
+ # static libraries, and build separate DLLs for each
492
+ archives = []
493
+ plain_objects = []
494
+ for obj in objects:
495
+ if obj.lower().endswith('.a'):
496
+ archives.append(obj)
497
+ else:
498
+ plain_objects.append(obj)
499
+
500
+ chained_libs = []
501
+ chained_dlls = []
502
+ for archive in archives[::-1]:
503
+ lib, dll = self._link_wrapper_lib(
504
+ [archive],
505
+ output_dir,
506
+ extra_dll_dir,
507
+ chained_dlls=chained_dlls,
508
+ is_archive=True)
509
+ chained_libs.insert(0, lib)
510
+ chained_dlls.insert(0, dll)
511
+
512
+ if not plain_objects:
513
+ return chained_libs
514
+
515
+ lib, dll = self._link_wrapper_lib(
516
+ plain_objects,
517
+ output_dir,
518
+ extra_dll_dir,
519
+ chained_dlls=chained_dlls,
520
+ is_archive=False)
521
+ return [lib] + chained_libs
522
+ else:
523
+ raise ValueError("Unsupported C compiler")
524
+
525
+
526
+ def _can_target(cmd, arch):
527
+ """Return true if the architecture supports the -arch flag"""
528
+ newcmd = cmd[:]
529
+ fid, filename = tempfile.mkstemp(suffix=".f")
530
+ os.close(fid)
531
+ try:
532
+ d = os.path.dirname(filename)
533
+ output = os.path.splitext(filename)[0] + ".o"
534
+ try:
535
+ newcmd.extend(["-arch", arch, "-c", filename])
536
+ p = Popen(newcmd, stderr=STDOUT, stdout=PIPE, cwd=d)
537
+ p.communicate()
538
+ return p.returncode == 0
539
+ finally:
540
+ if os.path.exists(output):
541
+ os.remove(output)
542
+ finally:
543
+ os.remove(filename)
544
+
545
+
546
+ if __name__ == '__main__':
547
+ from distutils import log
548
+ from numpy.distutils import customized_fcompiler
549
+ log.set_verbosity(2)
550
+
551
+ print(customized_fcompiler('gnu').get_version())
552
+ try:
553
+ print(customized_fcompiler('g95').get_version())
554
+ except Exception as e:
555
+ print(e)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/hpux.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.distutils.fcompiler import FCompiler
2
+
3
+ compilers = ['HPUXFCompiler']
4
+
5
+ class HPUXFCompiler(FCompiler):
6
+
7
+ compiler_type = 'hpux'
8
+ description = 'HP Fortran 90 Compiler'
9
+ version_pattern = r'HP F90 (?P<version>[^\s*,]*)'
10
+
11
+ executables = {
12
+ 'version_cmd' : ["f90", "+version"],
13
+ 'compiler_f77' : ["f90"],
14
+ 'compiler_fix' : ["f90"],
15
+ 'compiler_f90' : ["f90"],
16
+ 'linker_so' : ["ld", "-b"],
17
+ 'archiver' : ["ar", "-cr"],
18
+ 'ranlib' : ["ranlib"]
19
+ }
20
+ module_dir_switch = None #XXX: fix me
21
+ module_include_switch = None #XXX: fix me
22
+ pic_flags = ['+Z']
23
+ def get_flags(self):
24
+ return self.pic_flags + ['+ppu', '+DD64']
25
+ def get_flags_opt(self):
26
+ return ['-O3']
27
+ def get_libraries(self):
28
+ return ['m']
29
+ def get_library_dirs(self):
30
+ opt = ['/usr/lib/hpux64']
31
+ return opt
32
+ def get_version(self, force=0, ok_status=[256, 0, 1]):
33
+ # XXX status==256 may indicate 'unrecognized option' or
34
+ # 'no input file'. So, version_cmd needs more work.
35
+ return FCompiler.get_version(self, force, ok_status)
36
+
37
+ if __name__ == '__main__':
38
+ from distutils import log
39
+ log.set_verbosity(10)
40
+ from numpy.distutils import customized_fcompiler
41
+ print(customized_fcompiler(compiler='hpux').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/ibm.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import sys
4
+ import subprocess
5
+
6
+ from numpy.distutils.fcompiler import FCompiler
7
+ from numpy.distutils.exec_command import find_executable
8
+ from numpy.distutils.misc_util import make_temp_file
9
+ from distutils import log
10
+
11
+ compilers = ['IBMFCompiler']
12
+
13
+ class IBMFCompiler(FCompiler):
14
+ compiler_type = 'ibm'
15
+ description = 'IBM XL Fortran Compiler'
16
+ version_pattern = r'(xlf\(1\)\s*|)IBM XL Fortran ((Advanced Edition |)Version |Enterprise Edition V|for AIX, V)(?P<version>[^\s*]*)'
17
+ #IBM XL Fortran Enterprise Edition V10.1 for AIX \nVersion: 10.01.0000.0004
18
+
19
+ executables = {
20
+ 'version_cmd' : ["<F77>", "-qversion"],
21
+ 'compiler_f77' : ["xlf"],
22
+ 'compiler_fix' : ["xlf90", "-qfixed"],
23
+ 'compiler_f90' : ["xlf90"],
24
+ 'linker_so' : ["xlf95"],
25
+ 'archiver' : ["ar", "-cr"],
26
+ 'ranlib' : ["ranlib"]
27
+ }
28
+
29
+ def get_version(self,*args,**kwds):
30
+ version = FCompiler.get_version(self,*args,**kwds)
31
+
32
+ if version is None and sys.platform.startswith('aix'):
33
+ # use lslpp to find out xlf version
34
+ lslpp = find_executable('lslpp')
35
+ xlf = find_executable('xlf')
36
+ if os.path.exists(xlf) and os.path.exists(lslpp):
37
+ try:
38
+ o = subprocess.check_output([lslpp, '-Lc', 'xlfcmp'])
39
+ except (OSError, subprocess.CalledProcessError):
40
+ pass
41
+ else:
42
+ m = re.search(r'xlfcmp:(?P<version>\d+([.]\d+)+)', o)
43
+ if m: version = m.group('version')
44
+
45
+ xlf_dir = '/etc/opt/ibmcmp/xlf'
46
+ if version is None and os.path.isdir(xlf_dir):
47
+ # linux:
48
+ # If the output of xlf does not contain version info
49
+ # (that's the case with xlf 8.1, for instance) then
50
+ # let's try another method:
51
+ l = sorted(os.listdir(xlf_dir))
52
+ l.reverse()
53
+ l = [d for d in l if os.path.isfile(os.path.join(xlf_dir, d, 'xlf.cfg'))]
54
+ if l:
55
+ from distutils.version import LooseVersion
56
+ self.version = version = LooseVersion(l[0])
57
+ return version
58
+
59
+ def get_flags(self):
60
+ return ['-qextname']
61
+
62
+ def get_flags_debug(self):
63
+ return ['-g']
64
+
65
+ def get_flags_linker_so(self):
66
+ opt = []
67
+ if sys.platform=='darwin':
68
+ opt.append('-Wl,-bundle,-flat_namespace,-undefined,suppress')
69
+ else:
70
+ opt.append('-bshared')
71
+ version = self.get_version(ok_status=[0, 40])
72
+ if version is not None:
73
+ if sys.platform.startswith('aix'):
74
+ xlf_cfg = '/etc/xlf.cfg'
75
+ else:
76
+ xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version
77
+ fo, new_cfg = make_temp_file(suffix='_xlf.cfg')
78
+ log.info('Creating '+new_cfg)
79
+ with open(xlf_cfg) as fi:
80
+ crt1_match = re.compile(r'\s*crt\s*=\s*(?P<path>.*)/crt1.o').match
81
+ for line in fi:
82
+ m = crt1_match(line)
83
+ if m:
84
+ fo.write('crt = %s/bundle1.o\n' % (m.group('path')))
85
+ else:
86
+ fo.write(line)
87
+ fo.close()
88
+ opt.append('-F'+new_cfg)
89
+ return opt
90
+
91
+ def get_flags_opt(self):
92
+ return ['-O3']
93
+
94
+ if __name__ == '__main__':
95
+ from numpy.distutils import customized_fcompiler
96
+ log.set_verbosity(2)
97
+ print(customized_fcompiler(compiler='ibm').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/intel.py ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # http://developer.intel.com/software/products/compilers/flin/
2
+ import sys
3
+
4
+ from numpy.distutils.ccompiler import simple_version_match
5
+ from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
6
+
7
+ compilers = ['IntelFCompiler', 'IntelVisualFCompiler',
8
+ 'IntelItaniumFCompiler', 'IntelItaniumVisualFCompiler',
9
+ 'IntelEM64VisualFCompiler', 'IntelEM64TFCompiler']
10
+
11
+
12
+ def intel_version_match(type):
13
+ # Match against the important stuff in the version string
14
+ return simple_version_match(start=r'Intel.*?Fortran.*?(?:%s).*?Version' % (type,))
15
+
16
+
17
+ class BaseIntelFCompiler(FCompiler):
18
+ def update_executables(self):
19
+ f = dummy_fortran_file()
20
+ self.executables['version_cmd'] = ['<F77>', '-FI', '-V', '-c',
21
+ f + '.f', '-o', f + '.o']
22
+
23
+ def runtime_library_dir_option(self, dir):
24
+ # TODO: could use -Xlinker here, if it's supported
25
+ assert "," not in dir
26
+
27
+ return '-Wl,-rpath=%s' % dir
28
+
29
+
30
+ class IntelFCompiler(BaseIntelFCompiler):
31
+
32
+ compiler_type = 'intel'
33
+ compiler_aliases = ('ifort',)
34
+ description = 'Intel Fortran Compiler for 32-bit apps'
35
+ version_match = intel_version_match('32-bit|IA-32')
36
+
37
+ possible_executables = ['ifort', 'ifc']
38
+
39
+ executables = {
40
+ 'version_cmd' : None, # set by update_executables
41
+ 'compiler_f77' : [None, "-72", "-w90", "-w95"],
42
+ 'compiler_f90' : [None],
43
+ 'compiler_fix' : [None, "-FI"],
44
+ 'linker_so' : ["<F90>", "-shared"],
45
+ 'archiver' : ["ar", "-cr"],
46
+ 'ranlib' : ["ranlib"]
47
+ }
48
+
49
+ pic_flags = ['-fPIC']
50
+ module_dir_switch = '-module ' # Don't remove ending space!
51
+ module_include_switch = '-I'
52
+
53
+ def get_flags_free(self):
54
+ return ['-FR']
55
+
56
+ def get_flags(self):
57
+ return ['-fPIC']
58
+
59
+ def get_flags_opt(self): # Scipy test failures with -O2
60
+ v = self.get_version()
61
+ mpopt = 'openmp' if v and v < '15' else 'qopenmp'
62
+ return ['-fp-model', 'strict', '-O1',
63
+ '-assume', 'minus0', '-{}'.format(mpopt)]
64
+
65
+ def get_flags_arch(self):
66
+ return []
67
+
68
+ def get_flags_linker_so(self):
69
+ opt = FCompiler.get_flags_linker_so(self)
70
+ v = self.get_version()
71
+ if v and v >= '8.0':
72
+ opt.append('-nofor_main')
73
+ if sys.platform == 'darwin':
74
+ # Here, it's -dynamiclib
75
+ try:
76
+ idx = opt.index('-shared')
77
+ opt.remove('-shared')
78
+ except ValueError:
79
+ idx = 0
80
+ opt[idx:idx] = ['-dynamiclib', '-Wl,-undefined,dynamic_lookup']
81
+ return opt
82
+
83
+
84
+ class IntelItaniumFCompiler(IntelFCompiler):
85
+ compiler_type = 'intele'
86
+ compiler_aliases = ()
87
+ description = 'Intel Fortran Compiler for Itanium apps'
88
+
89
+ version_match = intel_version_match('Itanium|IA-64')
90
+
91
+ possible_executables = ['ifort', 'efort', 'efc']
92
+
93
+ executables = {
94
+ 'version_cmd' : None,
95
+ 'compiler_f77' : [None, "-FI", "-w90", "-w95"],
96
+ 'compiler_fix' : [None, "-FI"],
97
+ 'compiler_f90' : [None],
98
+ 'linker_so' : ['<F90>', "-shared"],
99
+ 'archiver' : ["ar", "-cr"],
100
+ 'ranlib' : ["ranlib"]
101
+ }
102
+
103
+
104
+ class IntelEM64TFCompiler(IntelFCompiler):
105
+ compiler_type = 'intelem'
106
+ compiler_aliases = ()
107
+ description = 'Intel Fortran Compiler for 64-bit apps'
108
+
109
+ version_match = intel_version_match('EM64T-based|Intel\\(R\\) 64|64|IA-64|64-bit')
110
+
111
+ possible_executables = ['ifort', 'efort', 'efc']
112
+
113
+ executables = {
114
+ 'version_cmd' : None,
115
+ 'compiler_f77' : [None, "-FI"],
116
+ 'compiler_fix' : [None, "-FI"],
117
+ 'compiler_f90' : [None],
118
+ 'linker_so' : ['<F90>', "-shared"],
119
+ 'archiver' : ["ar", "-cr"],
120
+ 'ranlib' : ["ranlib"]
121
+ }
122
+
123
+ # Is there no difference in the version string between the above compilers
124
+ # and the Visual compilers?
125
+
126
+
127
+ class IntelVisualFCompiler(BaseIntelFCompiler):
128
+ compiler_type = 'intelv'
129
+ description = 'Intel Visual Fortran Compiler for 32-bit apps'
130
+ version_match = intel_version_match('32-bit|IA-32')
131
+
132
+ def update_executables(self):
133
+ f = dummy_fortran_file()
134
+ self.executables['version_cmd'] = ['<F77>', '/FI', '/c',
135
+ f + '.f', '/o', f + '.o']
136
+
137
+ ar_exe = 'lib.exe'
138
+ possible_executables = ['ifort', 'ifl']
139
+
140
+ executables = {
141
+ 'version_cmd' : None,
142
+ 'compiler_f77' : [None],
143
+ 'compiler_fix' : [None],
144
+ 'compiler_f90' : [None],
145
+ 'linker_so' : [None],
146
+ 'archiver' : [ar_exe, "/verbose", "/OUT:"],
147
+ 'ranlib' : None
148
+ }
149
+
150
+ compile_switch = '/c '
151
+ object_switch = '/Fo' # No space after /Fo!
152
+ library_switch = '/OUT:' # No space after /OUT:!
153
+ module_dir_switch = '/module:' # No space after /module:
154
+ module_include_switch = '/I'
155
+
156
+ def get_flags(self):
157
+ opt = ['/nologo', '/MD', '/nbs', '/names:lowercase',
158
+ '/assume:underscore', '/fpp']
159
+ return opt
160
+
161
+ def get_flags_free(self):
162
+ return []
163
+
164
+ def get_flags_debug(self):
165
+ return ['/4Yb', '/d2']
166
+
167
+ def get_flags_opt(self):
168
+ return ['/O1', '/assume:minus0'] # Scipy test failures with /O2
169
+
170
+ def get_flags_arch(self):
171
+ return ["/arch:IA32", "/QaxSSE3"]
172
+
173
+ def runtime_library_dir_option(self, dir):
174
+ raise NotImplementedError
175
+
176
+
177
+ class IntelItaniumVisualFCompiler(IntelVisualFCompiler):
178
+ compiler_type = 'intelev'
179
+ description = 'Intel Visual Fortran Compiler for Itanium apps'
180
+
181
+ version_match = intel_version_match('Itanium')
182
+
183
+ possible_executables = ['efl'] # XXX this is a wild guess
184
+ ar_exe = IntelVisualFCompiler.ar_exe
185
+
186
+ executables = {
187
+ 'version_cmd' : None,
188
+ 'compiler_f77' : [None, "-FI", "-w90", "-w95"],
189
+ 'compiler_fix' : [None, "-FI", "-4L72", "-w"],
190
+ 'compiler_f90' : [None],
191
+ 'linker_so' : ['<F90>', "-shared"],
192
+ 'archiver' : [ar_exe, "/verbose", "/OUT:"],
193
+ 'ranlib' : None
194
+ }
195
+
196
+
197
+ class IntelEM64VisualFCompiler(IntelVisualFCompiler):
198
+ compiler_type = 'intelvem'
199
+ description = 'Intel Visual Fortran Compiler for 64-bit apps'
200
+
201
+ version_match = simple_version_match(start=r'Intel\(R\).*?64,')
202
+
203
+ def get_flags_arch(self):
204
+ return []
205
+
206
+
207
+ if __name__ == '__main__':
208
+ from distutils import log
209
+ log.set_verbosity(2)
210
+ from numpy.distutils import customized_fcompiler
211
+ print(customized_fcompiler(compiler='intel').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/lahey.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from numpy.distutils.fcompiler import FCompiler
4
+
5
+ compilers = ['LaheyFCompiler']
6
+
7
+ class LaheyFCompiler(FCompiler):
8
+
9
+ compiler_type = 'lahey'
10
+ description = 'Lahey/Fujitsu Fortran 95 Compiler'
11
+ version_pattern = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P<version>[^\s*]*)'
12
+
13
+ executables = {
14
+ 'version_cmd' : ["<F90>", "--version"],
15
+ 'compiler_f77' : ["lf95", "--fix"],
16
+ 'compiler_fix' : ["lf95", "--fix"],
17
+ 'compiler_f90' : ["lf95"],
18
+ 'linker_so' : ["lf95", "-shared"],
19
+ 'archiver' : ["ar", "-cr"],
20
+ 'ranlib' : ["ranlib"]
21
+ }
22
+
23
+ module_dir_switch = None #XXX Fix me
24
+ module_include_switch = None #XXX Fix me
25
+
26
+ def get_flags_opt(self):
27
+ return ['-O']
28
+ def get_flags_debug(self):
29
+ return ['-g', '--chk', '--chkglobal']
30
+ def get_library_dirs(self):
31
+ opt = []
32
+ d = os.environ.get('LAHEY')
33
+ if d:
34
+ opt.append(os.path.join(d, 'lib'))
35
+ return opt
36
+ def get_libraries(self):
37
+ opt = []
38
+ opt.extend(['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6'])
39
+ return opt
40
+
41
+ if __name__ == '__main__':
42
+ from distutils import log
43
+ log.set_verbosity(2)
44
+ from numpy.distutils import customized_fcompiler
45
+ print(customized_fcompiler(compiler='lahey').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/mips.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.distutils.cpuinfo import cpu
2
+ from numpy.distutils.fcompiler import FCompiler
3
+
4
+ compilers = ['MIPSFCompiler']
5
+
6
+ class MIPSFCompiler(FCompiler):
7
+
8
+ compiler_type = 'mips'
9
+ description = 'MIPSpro Fortran Compiler'
10
+ version_pattern = r'MIPSpro Compilers: Version (?P<version>[^\s*,]*)'
11
+
12
+ executables = {
13
+ 'version_cmd' : ["<F90>", "-version"],
14
+ 'compiler_f77' : ["f77", "-f77"],
15
+ 'compiler_fix' : ["f90", "-fixedform"],
16
+ 'compiler_f90' : ["f90"],
17
+ 'linker_so' : ["f90", "-shared"],
18
+ 'archiver' : ["ar", "-cr"],
19
+ 'ranlib' : None
20
+ }
21
+ module_dir_switch = None #XXX: fix me
22
+ module_include_switch = None #XXX: fix me
23
+ pic_flags = ['-KPIC']
24
+
25
+ def get_flags(self):
26
+ return self.pic_flags + ['-n32']
27
+ def get_flags_opt(self):
28
+ return ['-O3']
29
+ def get_flags_arch(self):
30
+ opt = []
31
+ for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():
32
+ if getattr(cpu, 'is_IP%s'%a)():
33
+ opt.append('-TARG:platform=IP%s' % a)
34
+ break
35
+ return opt
36
+ def get_flags_arch_f77(self):
37
+ r = None
38
+ if cpu.is_r10000(): r = 10000
39
+ elif cpu.is_r12000(): r = 12000
40
+ elif cpu.is_r8000(): r = 8000
41
+ elif cpu.is_r5000(): r = 5000
42
+ elif cpu.is_r4000(): r = 4000
43
+ if r is not None:
44
+ return ['r%s' % (r)]
45
+ return []
46
+ def get_flags_arch_f90(self):
47
+ r = self.get_flags_arch_f77()
48
+ if r:
49
+ r[0] = '-' + r[0]
50
+ return r
51
+
52
+ if __name__ == '__main__':
53
+ from numpy.distutils import customized_fcompiler
54
+ print(customized_fcompiler(compiler='mips').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/nag.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import re
3
+ from numpy.distutils.fcompiler import FCompiler
4
+
5
+ compilers = ['NAGFCompiler', 'NAGFORCompiler']
6
+
7
+ class BaseNAGFCompiler(FCompiler):
8
+ version_pattern = r'NAG.* Release (?P<version>[^(\s]*)'
9
+
10
+ def version_match(self, version_string):
11
+ m = re.search(self.version_pattern, version_string)
12
+ if m:
13
+ return m.group('version')
14
+ else:
15
+ return None
16
+
17
+ def get_flags_linker_so(self):
18
+ return ["-Wl,-shared"]
19
+ def get_flags_opt(self):
20
+ return ['-O4']
21
+ def get_flags_arch(self):
22
+ return []
23
+
24
+ class NAGFCompiler(BaseNAGFCompiler):
25
+
26
+ compiler_type = 'nag'
27
+ description = 'NAGWare Fortran 95 Compiler'
28
+
29
+ executables = {
30
+ 'version_cmd' : ["<F90>", "-V"],
31
+ 'compiler_f77' : ["f95", "-fixed"],
32
+ 'compiler_fix' : ["f95", "-fixed"],
33
+ 'compiler_f90' : ["f95"],
34
+ 'linker_so' : ["<F90>"],
35
+ 'archiver' : ["ar", "-cr"],
36
+ 'ranlib' : ["ranlib"]
37
+ }
38
+
39
+ def get_flags_linker_so(self):
40
+ if sys.platform == 'darwin':
41
+ return ['-unsharedf95', '-Wl,-bundle,-flat_namespace,-undefined,suppress']
42
+ return BaseNAGFCompiler.get_flags_linker_so(self)
43
+ def get_flags_arch(self):
44
+ version = self.get_version()
45
+ if version and version < '5.1':
46
+ return ['-target=native']
47
+ else:
48
+ return BaseNAGFCompiler.get_flags_arch(self)
49
+ def get_flags_debug(self):
50
+ return ['-g', '-gline', '-g90', '-nan', '-C']
51
+
52
+ class NAGFORCompiler(BaseNAGFCompiler):
53
+
54
+ compiler_type = 'nagfor'
55
+ description = 'NAG Fortran Compiler'
56
+
57
+ executables = {
58
+ 'version_cmd' : ["nagfor", "-V"],
59
+ 'compiler_f77' : ["nagfor", "-fixed"],
60
+ 'compiler_fix' : ["nagfor", "-fixed"],
61
+ 'compiler_f90' : ["nagfor"],
62
+ 'linker_so' : ["nagfor"],
63
+ 'archiver' : ["ar", "-cr"],
64
+ 'ranlib' : ["ranlib"]
65
+ }
66
+
67
+ def get_flags_linker_so(self):
68
+ if sys.platform == 'darwin':
69
+ return ['-unsharedrts',
70
+ '-Wl,-bundle,-flat_namespace,-undefined,suppress']
71
+ return BaseNAGFCompiler.get_flags_linker_so(self)
72
+ def get_flags_debug(self):
73
+ version = self.get_version()
74
+ if version and version > '6.1':
75
+ return ['-g', '-u', '-nan', '-C=all', '-thread_safe',
76
+ '-kind=unique', '-Warn=allocation', '-Warn=subnormal']
77
+ else:
78
+ return ['-g', '-nan', '-C=all', '-u', '-thread_safe']
79
+
80
+
81
+ if __name__ == '__main__':
82
+ from distutils import log
83
+ log.set_verbosity(2)
84
+ from numpy.distutils import customized_fcompiler
85
+ compiler = customized_fcompiler(compiler='nagfor')
86
+ print(compiler.get_version())
87
+ print(compiler.get_flags_debug())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/none.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.distutils.fcompiler import FCompiler
2
+ from numpy.distutils import customized_fcompiler
3
+
4
+ compilers = ['NoneFCompiler']
5
+
6
+ class NoneFCompiler(FCompiler):
7
+
8
+ compiler_type = 'none'
9
+ description = 'Fake Fortran compiler'
10
+
11
+ executables = {'compiler_f77': None,
12
+ 'compiler_f90': None,
13
+ 'compiler_fix': None,
14
+ 'linker_so': None,
15
+ 'linker_exe': None,
16
+ 'archiver': None,
17
+ 'ranlib': None,
18
+ 'version_cmd': None,
19
+ }
20
+
21
+ def find_executables(self):
22
+ pass
23
+
24
+
25
+ if __name__ == '__main__':
26
+ from distutils import log
27
+ log.set_verbosity(2)
28
+ print(customized_fcompiler(compiler='none').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/nv.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.distutils.fcompiler import FCompiler
2
+
3
+ compilers = ['NVHPCFCompiler']
4
+
5
+ class NVHPCFCompiler(FCompiler):
6
+ """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler
7
+
8
+ https://developer.nvidia.com/hpc-sdk
9
+
10
+ Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers,
11
+ https://www.pgroup.com/index.htm.
12
+ See also `numpy.distutils.fcompiler.pg`.
13
+ """
14
+
15
+ compiler_type = 'nv'
16
+ description = 'NVIDIA HPC SDK'
17
+ version_pattern = r'\s*(nvfortran|.+ \(aka nvfortran\)) (?P<version>[\d.-]+).*'
18
+
19
+ executables = {
20
+ 'version_cmd': ["<F90>", "-V"],
21
+ 'compiler_f77': ["nvfortran"],
22
+ 'compiler_fix': ["nvfortran", "-Mfixed"],
23
+ 'compiler_f90': ["nvfortran"],
24
+ 'linker_so': ["<F90>"],
25
+ 'archiver': ["ar", "-cr"],
26
+ 'ranlib': ["ranlib"]
27
+ }
28
+ pic_flags = ['-fpic']
29
+
30
+ module_dir_switch = '-module '
31
+ module_include_switch = '-I'
32
+
33
+ def get_flags(self):
34
+ opt = ['-Minform=inform', '-Mnosecond_underscore']
35
+ return self.pic_flags + opt
36
+
37
+ def get_flags_opt(self):
38
+ return ['-fast']
39
+
40
+ def get_flags_debug(self):
41
+ return ['-g']
42
+
43
+ def get_flags_linker_so(self):
44
+ return ["-shared", '-fpic']
45
+
46
+ def runtime_library_dir_option(self, dir):
47
+ return '-R%s' % dir
48
+
49
+ if __name__ == '__main__':
50
+ from distutils import log
51
+ log.set_verbosity(2)
52
+ from numpy.distutils import customized_fcompiler
53
+ print(customized_fcompiler(compiler='nv').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/pathf95.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.distutils.fcompiler import FCompiler
2
+
3
+ compilers = ['PathScaleFCompiler']
4
+
5
+ class PathScaleFCompiler(FCompiler):
6
+
7
+ compiler_type = 'pathf95'
8
+ description = 'PathScale Fortran Compiler'
9
+ version_pattern = r'PathScale\(TM\) Compiler Suite: Version (?P<version>[\d.]+)'
10
+
11
+ executables = {
12
+ 'version_cmd' : ["pathf95", "-version"],
13
+ 'compiler_f77' : ["pathf95", "-fixedform"],
14
+ 'compiler_fix' : ["pathf95", "-fixedform"],
15
+ 'compiler_f90' : ["pathf95"],
16
+ 'linker_so' : ["pathf95", "-shared"],
17
+ 'archiver' : ["ar", "-cr"],
18
+ 'ranlib' : ["ranlib"]
19
+ }
20
+ pic_flags = ['-fPIC']
21
+ module_dir_switch = '-module ' # Don't remove ending space!
22
+ module_include_switch = '-I'
23
+
24
+ def get_flags_opt(self):
25
+ return ['-O3']
26
+ def get_flags_debug(self):
27
+ return ['-g']
28
+
29
+ if __name__ == '__main__':
30
+ from distutils import log
31
+ log.set_verbosity(2)
32
+ from numpy.distutils import customized_fcompiler
33
+ print(customized_fcompiler(compiler='pathf95').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/pg.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # http://www.pgroup.com
2
+ import sys
3
+
4
+ from numpy.distutils.fcompiler import FCompiler
5
+ from sys import platform
6
+ from os.path import join, dirname, normpath
7
+
8
+ compilers = ['PGroupFCompiler', 'PGroupFlangCompiler']
9
+
10
+
11
+ class PGroupFCompiler(FCompiler):
12
+
13
+ compiler_type = 'pg'
14
+ description = 'Portland Group Fortran Compiler'
15
+ version_pattern = r'\s*pg(f77|f90|hpf|fortran) (?P<version>[\d.-]+).*'
16
+
17
+ if platform == 'darwin':
18
+ executables = {
19
+ 'version_cmd': ["<F77>", "-V"],
20
+ 'compiler_f77': ["pgfortran", "-dynamiclib"],
21
+ 'compiler_fix': ["pgfortran", "-Mfixed", "-dynamiclib"],
22
+ 'compiler_f90': ["pgfortran", "-dynamiclib"],
23
+ 'linker_so': ["libtool"],
24
+ 'archiver': ["ar", "-cr"],
25
+ 'ranlib': ["ranlib"]
26
+ }
27
+ pic_flags = ['']
28
+ else:
29
+ executables = {
30
+ 'version_cmd': ["<F77>", "-V"],
31
+ 'compiler_f77': ["pgfortran"],
32
+ 'compiler_fix': ["pgfortran", "-Mfixed"],
33
+ 'compiler_f90': ["pgfortran"],
34
+ 'linker_so': ["<F90>"],
35
+ 'archiver': ["ar", "-cr"],
36
+ 'ranlib': ["ranlib"]
37
+ }
38
+ pic_flags = ['-fpic']
39
+
40
+ module_dir_switch = '-module '
41
+ module_include_switch = '-I'
42
+
43
+ def get_flags(self):
44
+ opt = ['-Minform=inform', '-Mnosecond_underscore']
45
+ return self.pic_flags + opt
46
+
47
+ def get_flags_opt(self):
48
+ return ['-fast']
49
+
50
+ def get_flags_debug(self):
51
+ return ['-g']
52
+
53
+ if platform == 'darwin':
54
+ def get_flags_linker_so(self):
55
+ return ["-dynamic", '-undefined', 'dynamic_lookup']
56
+
57
+ else:
58
+ def get_flags_linker_so(self):
59
+ return ["-shared", '-fpic']
60
+
61
+ def runtime_library_dir_option(self, dir):
62
+ return '-R%s' % dir
63
+
64
+
65
+ import functools
66
+
67
+ class PGroupFlangCompiler(FCompiler):
68
+ compiler_type = 'flang'
69
+ description = 'Portland Group Fortran LLVM Compiler'
70
+ version_pattern = r'\s*(flang|clang) version (?P<version>[\d.-]+).*'
71
+
72
+ ar_exe = 'lib.exe'
73
+ possible_executables = ['flang']
74
+
75
+ executables = {
76
+ 'version_cmd': ["<F77>", "--version"],
77
+ 'compiler_f77': ["flang"],
78
+ 'compiler_fix': ["flang"],
79
+ 'compiler_f90': ["flang"],
80
+ 'linker_so': [None],
81
+ 'archiver': [ar_exe, "/verbose", "/OUT:"],
82
+ 'ranlib': None
83
+ }
84
+
85
+ library_switch = '/OUT:' # No space after /OUT:!
86
+ module_dir_switch = '-module ' # Don't remove ending space!
87
+
88
+ def get_libraries(self):
89
+ opt = FCompiler.get_libraries(self)
90
+ opt.extend(['flang', 'flangrti', 'ompstub'])
91
+ return opt
92
+
93
+ @functools.lru_cache(maxsize=128)
94
+ def get_library_dirs(self):
95
+ """List of compiler library directories."""
96
+ opt = FCompiler.get_library_dirs(self)
97
+ flang_dir = dirname(self.executables['compiler_f77'][0])
98
+ opt.append(normpath(join(flang_dir, '..', 'lib')))
99
+
100
+ return opt
101
+
102
+ def get_flags(self):
103
+ return []
104
+
105
+ def get_flags_free(self):
106
+ return []
107
+
108
+ def get_flags_debug(self):
109
+ return ['-g']
110
+
111
+ def get_flags_opt(self):
112
+ return ['-O3']
113
+
114
+ def get_flags_arch(self):
115
+ return []
116
+
117
+ def runtime_library_dir_option(self, dir):
118
+ raise NotImplementedError
119
+
120
+
121
+ if __name__ == '__main__':
122
+ from distutils import log
123
+ log.set_verbosity(2)
124
+ from numpy.distutils import customized_fcompiler
125
+ if 'flang' in sys.argv:
126
+ print(customized_fcompiler(compiler='flang').get_version())
127
+ else:
128
+ print(customized_fcompiler(compiler='pg').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/sun.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.distutils.ccompiler import simple_version_match
2
+ from numpy.distutils.fcompiler import FCompiler
3
+
4
+ compilers = ['SunFCompiler']
5
+
6
+ class SunFCompiler(FCompiler):
7
+
8
+ compiler_type = 'sun'
9
+ description = 'Sun or Forte Fortran 95 Compiler'
10
+ # ex:
11
+ # f90: Sun WorkShop 6 update 2 Fortran 95 6.2 Patch 111690-10 2003/08/28
12
+ version_match = simple_version_match(
13
+ start=r'f9[05]: (Sun|Forte|WorkShop).*Fortran 95')
14
+
15
+ executables = {
16
+ 'version_cmd' : ["<F90>", "-V"],
17
+ 'compiler_f77' : ["f90"],
18
+ 'compiler_fix' : ["f90", "-fixed"],
19
+ 'compiler_f90' : ["f90"],
20
+ 'linker_so' : ["<F90>", "-Bdynamic", "-G"],
21
+ 'archiver' : ["ar", "-cr"],
22
+ 'ranlib' : ["ranlib"]
23
+ }
24
+ module_dir_switch = '-moddir='
25
+ module_include_switch = '-M'
26
+ pic_flags = ['-xcode=pic32']
27
+
28
+ def get_flags_f77(self):
29
+ ret = ["-ftrap=%none"]
30
+ if (self.get_version() or '') >= '7':
31
+ ret.append("-f77")
32
+ else:
33
+ ret.append("-fixed")
34
+ return ret
35
+ def get_opt(self):
36
+ return ['-fast', '-dalign']
37
+ def get_arch(self):
38
+ return ['-xtarget=generic']
39
+ def get_libraries(self):
40
+ opt = []
41
+ opt.extend(['fsu', 'sunmath', 'mvec'])
42
+ return opt
43
+
44
+ def runtime_library_dir_option(self, dir):
45
+ return '-R%s' % dir
46
+
47
+ if __name__ == '__main__':
48
+ from distutils import log
49
+ log.set_verbosity(2)
50
+ from numpy.distutils import customized_fcompiler
51
+ print(customized_fcompiler(compiler='sun').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fcompiler/vast.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from numpy.distutils.fcompiler.gnu import GnuFCompiler
4
+
5
+ compilers = ['VastFCompiler']
6
+
7
+ class VastFCompiler(GnuFCompiler):
8
+ compiler_type = 'vast'
9
+ compiler_aliases = ()
10
+ description = 'Pacific-Sierra Research Fortran 90 Compiler'
11
+ version_pattern = (r'\s*Pacific-Sierra Research vf90 '
12
+ r'(Personal|Professional)\s+(?P<version>[^\s]*)')
13
+
14
+ # VAST f90 does not support -o with -c. So, object files are created
15
+ # to the current directory and then moved to build directory
16
+ object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '
17
+
18
+ executables = {
19
+ 'version_cmd' : ["vf90", "-v"],
20
+ 'compiler_f77' : ["g77"],
21
+ 'compiler_fix' : ["f90", "-Wv,-ya"],
22
+ 'compiler_f90' : ["f90"],
23
+ 'linker_so' : ["<F90>"],
24
+ 'archiver' : ["ar", "-cr"],
25
+ 'ranlib' : ["ranlib"]
26
+ }
27
+ module_dir_switch = None #XXX Fix me
28
+ module_include_switch = None #XXX Fix me
29
+
30
+ def find_executables(self):
31
+ pass
32
+
33
+ def get_version_cmd(self):
34
+ f90 = self.compiler_f90[0]
35
+ d, b = os.path.split(f90)
36
+ vf90 = os.path.join(d, 'v'+b)
37
+ return vf90
38
+
39
+ def get_flags_arch(self):
40
+ vast_version = self.get_version()
41
+ gnu = GnuFCompiler()
42
+ gnu.customize(None)
43
+ self.version = gnu.get_version()
44
+ opt = GnuFCompiler.get_flags_arch(self)
45
+ self.version = vast_version
46
+ return opt
47
+
48
+ if __name__ == '__main__':
49
+ from distutils import log
50
+ log.set_verbosity(2)
51
+ from numpy.distutils import customized_fcompiler
52
+ print(customized_fcompiler(compiler='vast').get_version())
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/from_template.py ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+
4
+ process_file(filename)
5
+
6
+ takes templated file .xxx.src and produces .xxx file where .xxx
7
+ is .pyf .f90 or .f using the following template rules:
8
+
9
+ '<..>' denotes a template.
10
+
11
+ All function and subroutine blocks in a source file with names that
12
+ contain '<..>' will be replicated according to the rules in '<..>'.
13
+
14
+ The number of comma-separated words in '<..>' will determine the number of
15
+ replicates.
16
+
17
+ '<..>' may have two different forms, named and short. For example,
18
+
19
+ named:
20
+ <p=d,s,z,c> where anywhere inside a block '<p>' will be replaced with
21
+ 'd', 's', 'z', and 'c' for each replicate of the block.
22
+
23
+ <_c> is already defined: <_c=s,d,c,z>
24
+ <_t> is already defined: <_t=real,double precision,complex,double complex>
25
+
26
+ short:
27
+ <s,d,c,z>, a short form of the named, useful when no <p> appears inside
28
+ a block.
29
+
30
+ In general, '<..>' contains a comma separated list of arbitrary
31
+ expressions. If these expression must contain a comma|leftarrow|rightarrow,
32
+ then prepend the comma|leftarrow|rightarrow with a backslash.
33
+
34
+ If an expression matches '\\<index>' then it will be replaced
35
+ by <index>-th expression.
36
+
37
+ Note that all '<..>' forms in a block must have the same number of
38
+ comma-separated entries.
39
+
40
+ Predefined named template rules:
41
+ <prefix=s,d,c,z>
42
+ <ftype=real,double precision,complex,double complex>
43
+ <ftypereal=real,double precision,\\0,\\1>
44
+ <ctype=float,double,complex_float,complex_double>
45
+ <ctypereal=float,double,\\0,\\1>
46
+
47
+ """
48
+ __all__ = ['process_str', 'process_file']
49
+
50
+ import os
51
+ import sys
52
+ import re
53
+
54
+ routine_start_re = re.compile(r'(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\b', re.I)
55
+ routine_end_re = re.compile(r'\n\s*end\s*(subroutine|function)\b.*(\n|\Z)', re.I)
56
+ function_start_re = re.compile(r'\n (\$|\*)\s*function\b', re.I)
57
+
58
+ def parse_structure(astr):
59
+ """ Return a list of tuples for each function or subroutine each
60
+ tuple is the start and end of a subroutine or function to be
61
+ expanded.
62
+ """
63
+
64
+ spanlist = []
65
+ ind = 0
66
+ while True:
67
+ m = routine_start_re.search(astr, ind)
68
+ if m is None:
69
+ break
70
+ start = m.start()
71
+ if function_start_re.match(astr, start, m.end()):
72
+ while True:
73
+ i = astr.rfind('\n', ind, start)
74
+ if i==-1:
75
+ break
76
+ start = i
77
+ if astr[i:i+7]!='\n $':
78
+ break
79
+ start += 1
80
+ m = routine_end_re.search(astr, m.end())
81
+ ind = end = m and m.end()-1 or len(astr)
82
+ spanlist.append((start, end))
83
+ return spanlist
84
+
85
+ template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>")
86
+ named_re = re.compile(r"<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>")
87
+ list_re = re.compile(r"<\s*((.*?))\s*>")
88
+
89
+ def find_repl_patterns(astr):
90
+ reps = named_re.findall(astr)
91
+ names = {}
92
+ for rep in reps:
93
+ name = rep[0].strip() or unique_key(names)
94
+ repl = rep[1].replace(r'\,', '@comma@')
95
+ thelist = conv(repl)
96
+ names[name] = thelist
97
+ return names
98
+
99
+ def find_and_remove_repl_patterns(astr):
100
+ names = find_repl_patterns(astr)
101
+ astr = re.subn(named_re, '', astr)[0]
102
+ return astr, names
103
+
104
+ item_re = re.compile(r"\A\\(?P<index>\d+)\Z")
105
+ def conv(astr):
106
+ b = astr.split(',')
107
+ l = [x.strip() for x in b]
108
+ for i in range(len(l)):
109
+ m = item_re.match(l[i])
110
+ if m:
111
+ j = int(m.group('index'))
112
+ l[i] = l[j]
113
+ return ','.join(l)
114
+
115
+ def unique_key(adict):
116
+ """ Obtain a unique key given a dictionary."""
117
+ allkeys = list(adict.keys())
118
+ done = False
119
+ n = 1
120
+ while not done:
121
+ newkey = '__l%s' % (n)
122
+ if newkey in allkeys:
123
+ n += 1
124
+ else:
125
+ done = True
126
+ return newkey
127
+
128
+
129
+ template_name_re = re.compile(r'\A\s*(\w[\w\d]*)\s*\Z')
130
+ def expand_sub(substr, names):
131
+ substr = substr.replace(r'\>', '@rightarrow@')
132
+ substr = substr.replace(r'\<', '@leftarrow@')
133
+ lnames = find_repl_patterns(substr)
134
+ substr = named_re.sub(r"<\1>", substr) # get rid of definition templates
135
+
136
+ def listrepl(mobj):
137
+ thelist = conv(mobj.group(1).replace(r'\,', '@comma@'))
138
+ if template_name_re.match(thelist):
139
+ return "<%s>" % (thelist)
140
+ name = None
141
+ for key in lnames.keys(): # see if list is already in dictionary
142
+ if lnames[key] == thelist:
143
+ name = key
144
+ if name is None: # this list is not in the dictionary yet
145
+ name = unique_key(lnames)
146
+ lnames[name] = thelist
147
+ return "<%s>" % name
148
+
149
+ substr = list_re.sub(listrepl, substr) # convert all lists to named templates
150
+ # newnames are constructed as needed
151
+
152
+ numsubs = None
153
+ base_rule = None
154
+ rules = {}
155
+ for r in template_re.findall(substr):
156
+ if r not in rules:
157
+ thelist = lnames.get(r, names.get(r, None))
158
+ if thelist is None:
159
+ raise ValueError('No replicates found for <%s>' % (r))
160
+ if r not in names and not thelist.startswith('_'):
161
+ names[r] = thelist
162
+ rule = [i.replace('@comma@', ',') for i in thelist.split(',')]
163
+ num = len(rule)
164
+
165
+ if numsubs is None:
166
+ numsubs = num
167
+ rules[r] = rule
168
+ base_rule = r
169
+ elif num == numsubs:
170
+ rules[r] = rule
171
+ else:
172
+ print("Mismatch in number of replacements (base <%s=%s>)"
173
+ " for <%s=%s>. Ignoring." %
174
+ (base_rule, ','.join(rules[base_rule]), r, thelist))
175
+ if not rules:
176
+ return substr
177
+
178
+ def namerepl(mobj):
179
+ name = mobj.group(1)
180
+ return rules.get(name, (k+1)*[name])[k]
181
+
182
+ newstr = ''
183
+ for k in range(numsubs):
184
+ newstr += template_re.sub(namerepl, substr) + '\n\n'
185
+
186
+ newstr = newstr.replace('@rightarrow@', '>')
187
+ newstr = newstr.replace('@leftarrow@', '<')
188
+ return newstr
189
+
190
+ def process_str(allstr):
191
+ newstr = allstr
192
+ writestr = ''
193
+
194
+ struct = parse_structure(newstr)
195
+
196
+ oldend = 0
197
+ names = {}
198
+ names.update(_special_names)
199
+ for sub in struct:
200
+ cleanedstr, defs = find_and_remove_repl_patterns(newstr[oldend:sub[0]])
201
+ writestr += cleanedstr
202
+ names.update(defs)
203
+ writestr += expand_sub(newstr[sub[0]:sub[1]], names)
204
+ oldend = sub[1]
205
+ writestr += newstr[oldend:]
206
+
207
+ return writestr
208
+
209
+ include_src_re = re.compile(r"(\n|\A)\s*include\s*['\"](?P<name>[\w\d./\\]+\.src)['\"]", re.I)
210
+
211
+ def resolve_includes(source):
212
+ d = os.path.dirname(source)
213
+ with open(source) as fid:
214
+ lines = []
215
+ for line in fid:
216
+ m = include_src_re.match(line)
217
+ if m:
218
+ fn = m.group('name')
219
+ if not os.path.isabs(fn):
220
+ fn = os.path.join(d, fn)
221
+ if os.path.isfile(fn):
222
+ lines.extend(resolve_includes(fn))
223
+ else:
224
+ lines.append(line)
225
+ else:
226
+ lines.append(line)
227
+ return lines
228
+
229
+ def process_file(source):
230
+ lines = resolve_includes(source)
231
+ return process_str(''.join(lines))
232
+
233
+ _special_names = find_repl_patterns('''
234
+ <_c=s,d,c,z>
235
+ <_t=real,double precision,complex,double complex>
236
+ <prefix=s,d,c,z>
237
+ <ftype=real,double precision,complex,double complex>
238
+ <ctype=float,double,complex_float,complex_double>
239
+ <ftypereal=real,double precision,\\0,\\1>
240
+ <ctypereal=float,double,\\0,\\1>
241
+ ''')
242
+
243
+ def main():
244
+ try:
245
+ file = sys.argv[1]
246
+ except IndexError:
247
+ fid = sys.stdin
248
+ outfile = sys.stdout
249
+ else:
250
+ fid = open(file, 'r')
251
+ (base, ext) = os.path.splitext(file)
252
+ newname = base
253
+ outfile = open(newname, 'w')
254
+
255
+ allstr = fid.read()
256
+ writestr = process_str(allstr)
257
+ outfile.write(writestr)
258
+
259
+
260
+ if __name__ == "__main__":
261
+ main()
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/fujitsuccompiler.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from distutils.unixccompiler import UnixCCompiler
2
+
3
+ class FujitsuCCompiler(UnixCCompiler):
4
+
5
+ """
6
+ Fujitsu compiler.
7
+ """
8
+
9
+ compiler_type = 'fujitsu'
10
+ cc_exe = 'fcc'
11
+ cxx_exe = 'FCC'
12
+
13
+ def __init__(self, verbose=0, dry_run=0, force=0):
14
+ UnixCCompiler.__init__(self, verbose, dry_run, force)
15
+ cc_compiler = self.cc_exe
16
+ cxx_compiler = self.cxx_exe
17
+ self.set_executables(
18
+ compiler=cc_compiler +
19
+ ' -O3 -Nclang -fPIC',
20
+ compiler_so=cc_compiler +
21
+ ' -O3 -Nclang -fPIC',
22
+ compiler_cxx=cxx_compiler +
23
+ ' -O3 -Nclang -fPIC',
24
+ linker_exe=cc_compiler +
25
+ ' -lfj90i -lfj90f -lfjsrcinfo -lelf -shared',
26
+ linker_so=cc_compiler +
27
+ ' -lfj90i -lfj90f -lfjsrcinfo -lelf -shared'
28
+ )
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/intelccompiler.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import platform
2
+
3
+ from distutils.unixccompiler import UnixCCompiler
4
+ from numpy.distutils.exec_command import find_executable
5
+ from numpy.distutils.ccompiler import simple_version_match
6
+ if platform.system() == 'Windows':
7
+ from numpy.distutils.msvc9compiler import MSVCCompiler
8
+
9
+
10
+ class IntelCCompiler(UnixCCompiler):
11
+ """A modified Intel compiler compatible with a GCC-built Python."""
12
+ compiler_type = 'intel'
13
+ cc_exe = 'icc'
14
+ cc_args = 'fPIC'
15
+
16
+ def __init__(self, verbose=0, dry_run=0, force=0):
17
+ UnixCCompiler.__init__(self, verbose, dry_run, force)
18
+
19
+ v = self.get_version()
20
+ mpopt = 'openmp' if v and v < '15' else 'qopenmp'
21
+ self.cc_exe = ('icc -fPIC -fp-model strict -O3 '
22
+ '-fomit-frame-pointer -{}').format(mpopt)
23
+ compiler = self.cc_exe
24
+
25
+ if platform.system() == 'Darwin':
26
+ shared_flag = '-Wl,-undefined,dynamic_lookup'
27
+ else:
28
+ shared_flag = '-shared'
29
+ self.set_executables(compiler=compiler,
30
+ compiler_so=compiler,
31
+ compiler_cxx=compiler,
32
+ archiver='xiar' + ' cru',
33
+ linker_exe=compiler + ' -shared-intel',
34
+ linker_so=compiler + ' ' + shared_flag +
35
+ ' -shared-intel')
36
+
37
+
38
+ class IntelItaniumCCompiler(IntelCCompiler):
39
+ compiler_type = 'intele'
40
+ cc_exe = 'icc'
41
+
42
+
43
+ class IntelEM64TCCompiler(UnixCCompiler):
44
+ """
45
+ A modified Intel x86_64 compiler compatible with a 64bit GCC-built Python.
46
+ """
47
+ compiler_type = 'intelem'
48
+ cc_exe = 'icc -m64'
49
+ cc_args = '-fPIC'
50
+
51
+ def __init__(self, verbose=0, dry_run=0, force=0):
52
+ UnixCCompiler.__init__(self, verbose, dry_run, force)
53
+
54
+ v = self.get_version()
55
+ mpopt = 'openmp' if v and v < '15' else 'qopenmp'
56
+ self.cc_exe = ('icc -std=c99 -m64 -fPIC -fp-model strict -O3 '
57
+ '-fomit-frame-pointer -{}').format(mpopt)
58
+ compiler = self.cc_exe
59
+
60
+ if platform.system() == 'Darwin':
61
+ shared_flag = '-Wl,-undefined,dynamic_lookup'
62
+ else:
63
+ shared_flag = '-shared'
64
+ self.set_executables(compiler=compiler,
65
+ compiler_so=compiler,
66
+ compiler_cxx=compiler,
67
+ archiver='xiar' + ' cru',
68
+ linker_exe=compiler + ' -shared-intel',
69
+ linker_so=compiler + ' ' + shared_flag +
70
+ ' -shared-intel')
71
+
72
+
73
+ if platform.system() == 'Windows':
74
+ class IntelCCompilerW(MSVCCompiler):
75
+ """
76
+ A modified Intel compiler compatible with an MSVC-built Python.
77
+ """
78
+ compiler_type = 'intelw'
79
+ compiler_cxx = 'icl'
80
+
81
+ def __init__(self, verbose=0, dry_run=0, force=0):
82
+ MSVCCompiler.__init__(self, verbose, dry_run, force)
83
+ version_match = simple_version_match(start=r'Intel\(R\).*?32,')
84
+ self.__version = version_match
85
+
86
+ def initialize(self, plat_name=None):
87
+ MSVCCompiler.initialize(self, plat_name)
88
+ self.cc = self.find_exe('icl.exe')
89
+ self.lib = self.find_exe('xilib')
90
+ self.linker = self.find_exe('xilink')
91
+ self.compile_options = ['/nologo', '/O3', '/MD', '/W3',
92
+ '/Qstd=c99']
93
+ self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3',
94
+ '/Qstd=c99', '/Z7', '/D_DEBUG']
95
+
96
+ class IntelEM64TCCompilerW(IntelCCompilerW):
97
+ """
98
+ A modified Intel x86_64 compiler compatible with
99
+ a 64bit MSVC-built Python.
100
+ """
101
+ compiler_type = 'intelemw'
102
+
103
+ def __init__(self, verbose=0, dry_run=0, force=0):
104
+ MSVCCompiler.__init__(self, verbose, dry_run, force)
105
+ version_match = simple_version_match(start=r'Intel\(R\).*?64,')
106
+ self.__version = version_match
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/lib2def.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import sys
3
+ import subprocess
4
+
5
+ __doc__ = """This module generates a DEF file from the symbols in
6
+ an MSVC-compiled DLL import library. It correctly discriminates between
7
+ data and functions. The data is collected from the output of the program
8
+ nm(1).
9
+
10
+ Usage:
11
+ python lib2def.py [libname.lib] [output.def]
12
+ or
13
+ python lib2def.py [libname.lib] > output.def
14
+
15
+ libname.lib defaults to python<py_ver>.lib and output.def defaults to stdout
16
+
17
+ Author: Robert Kern <kernr@mail.ncifcrf.gov>
18
+ Last Update: April 30, 1999
19
+ """
20
+
21
+ __version__ = '0.1a'
22
+
23
+ py_ver = "%d%d" % tuple(sys.version_info[:2])
24
+
25
+ DEFAULT_NM = ['nm', '-Cs']
26
+
27
+ DEF_HEADER = """LIBRARY python%s.dll
28
+ ;CODE PRELOAD MOVEABLE DISCARDABLE
29
+ ;DATA PRELOAD SINGLE
30
+
31
+ EXPORTS
32
+ """ % py_ver
33
+ # the header of the DEF file
34
+
35
+ FUNC_RE = re.compile(r"^(.*) in python%s\.dll" % py_ver, re.MULTILINE)
36
+ DATA_RE = re.compile(r"^_imp__(.*) in python%s\.dll" % py_ver, re.MULTILINE)
37
+
38
+ def parse_cmd():
39
+ """Parses the command-line arguments.
40
+
41
+ libfile, deffile = parse_cmd()"""
42
+ if len(sys.argv) == 3:
43
+ if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
44
+ libfile, deffile = sys.argv[1:]
45
+ elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
46
+ deffile, libfile = sys.argv[1:]
47
+ else:
48
+ print("I'm assuming that your first argument is the library")
49
+ print("and the second is the DEF file.")
50
+ elif len(sys.argv) == 2:
51
+ if sys.argv[1][-4:] == '.def':
52
+ deffile = sys.argv[1]
53
+ libfile = 'python%s.lib' % py_ver
54
+ elif sys.argv[1][-4:] == '.lib':
55
+ deffile = None
56
+ libfile = sys.argv[1]
57
+ else:
58
+ libfile = 'python%s.lib' % py_ver
59
+ deffile = None
60
+ return libfile, deffile
61
+
62
+ def getnm(nm_cmd=['nm', '-Cs', 'python%s.lib' % py_ver], shell=True):
63
+ """Returns the output of nm_cmd via a pipe.
64
+
65
+ nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
66
+ p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
67
+ stderr=subprocess.PIPE, text=True)
68
+ nm_output, nm_err = p.communicate()
69
+ if p.returncode != 0:
70
+ raise RuntimeError('failed to run "%s": "%s"' % (
71
+ ' '.join(nm_cmd), nm_err))
72
+ return nm_output
73
+
74
+ def parse_nm(nm_output):
75
+ """Returns a tuple of lists: dlist for the list of data
76
+ symbols and flist for the list of function symbols.
77
+
78
+ dlist, flist = parse_nm(nm_output)"""
79
+ data = DATA_RE.findall(nm_output)
80
+ func = FUNC_RE.findall(nm_output)
81
+
82
+ flist = []
83
+ for sym in data:
84
+ if sym in func and (sym[:2] == 'Py' or sym[:3] == '_Py' or sym[:4] == 'init'):
85
+ flist.append(sym)
86
+
87
+ dlist = []
88
+ for sym in data:
89
+ if sym not in flist and (sym[:2] == 'Py' or sym[:3] == '_Py'):
90
+ dlist.append(sym)
91
+
92
+ dlist.sort()
93
+ flist.sort()
94
+ return dlist, flist
95
+
96
+ def output_def(dlist, flist, header, file = sys.stdout):
97
+ """Outputs the final DEF file to a file defaulting to stdout.
98
+
99
+ output_def(dlist, flist, header, file = sys.stdout)"""
100
+ for data_sym in dlist:
101
+ header = header + '\t%s DATA\n' % data_sym
102
+ header = header + '\n' # blank line
103
+ for func_sym in flist:
104
+ header = header + '\t%s\n' % func_sym
105
+ file.write(header)
106
+
107
+ if __name__ == '__main__':
108
+ libfile, deffile = parse_cmd()
109
+ if deffile is None:
110
+ deffile = sys.stdout
111
+ else:
112
+ deffile = open(deffile, 'w')
113
+ nm_cmd = DEFAULT_NM + [str(libfile)]
114
+ nm_output = getnm(nm_cmd, shell=False)
115
+ dlist, flist = parse_nm(nm_output)
116
+ output_def(dlist, flist, DEF_HEADER, deffile)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/line_endings.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Functions for converting from DOS to UNIX line endings
2
+
3
+ """
4
+ import os
5
+ import re
6
+ import sys
7
+
8
+
9
+ def dos2unix(file):
10
+ "Replace CRLF with LF in argument files. Print names of changed files."
11
+ if os.path.isdir(file):
12
+ print(file, "Directory!")
13
+ return
14
+
15
+ with open(file, "rb") as fp:
16
+ data = fp.read()
17
+ if '\0' in data:
18
+ print(file, "Binary!")
19
+ return
20
+
21
+ newdata = re.sub("\r\n", "\n", data)
22
+ if newdata != data:
23
+ print('dos2unix:', file)
24
+ with open(file, "wb") as f:
25
+ f.write(newdata)
26
+ return file
27
+ else:
28
+ print(file, 'ok')
29
+
30
+ def dos2unix_one_dir(modified_files, dir_name, file_names):
31
+ for file in file_names:
32
+ full_path = os.path.join(dir_name, file)
33
+ file = dos2unix(full_path)
34
+ if file is not None:
35
+ modified_files.append(file)
36
+
37
+ def dos2unix_dir(dir_name):
38
+ modified_files = []
39
+ os.path.walk(dir_name, dos2unix_one_dir, modified_files)
40
+ return modified_files
41
+ #----------------------------------
42
+
43
+ def unix2dos(file):
44
+ "Replace LF with CRLF in argument files. Print names of changed files."
45
+ if os.path.isdir(file):
46
+ print(file, "Directory!")
47
+ return
48
+
49
+ with open(file, "rb") as fp:
50
+ data = fp.read()
51
+ if '\0' in data:
52
+ print(file, "Binary!")
53
+ return
54
+ newdata = re.sub("\r\n", "\n", data)
55
+ newdata = re.sub("\n", "\r\n", newdata)
56
+ if newdata != data:
57
+ print('unix2dos:', file)
58
+ with open(file, "wb") as f:
59
+ f.write(newdata)
60
+ return file
61
+ else:
62
+ print(file, 'ok')
63
+
64
+ def unix2dos_one_dir(modified_files, dir_name, file_names):
65
+ for file in file_names:
66
+ full_path = os.path.join(dir_name, file)
67
+ unix2dos(full_path)
68
+ if file is not None:
69
+ modified_files.append(file)
70
+
71
+ def unix2dos_dir(dir_name):
72
+ modified_files = []
73
+ os.path.walk(dir_name, unix2dos_one_dir, modified_files)
74
+ return modified_files
75
+
76
+ if __name__ == "__main__":
77
+ dos2unix_dir(sys.argv[1])
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/log.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Colored log
2
+ import sys
3
+ from distutils.log import * # noqa: F403
4
+ from distutils.log import Log as old_Log
5
+ from distutils.log import _global_log
6
+
7
+ from numpy.distutils.misc_util import (red_text, default_text, cyan_text,
8
+ green_text, is_sequence, is_string)
9
+
10
+
11
+ def _fix_args(args,flag=1):
12
+ if is_string(args):
13
+ return args.replace('%', '%%')
14
+ if flag and is_sequence(args):
15
+ return tuple([_fix_args(a, flag=0) for a in args])
16
+ return args
17
+
18
+
19
+ class Log(old_Log):
20
+ def _log(self, level, msg, args):
21
+ if level >= self.threshold:
22
+ if args:
23
+ msg = msg % _fix_args(args)
24
+ if 0:
25
+ if msg.startswith('copying ') and msg.find(' -> ') != -1:
26
+ return
27
+ if msg.startswith('byte-compiling '):
28
+ return
29
+ print(_global_color_map[level](msg))
30
+ sys.stdout.flush()
31
+
32
+ def good(self, msg, *args):
33
+ """
34
+ If we log WARN messages, log this message as a 'nice' anti-warn
35
+ message.
36
+
37
+ """
38
+ if WARN >= self.threshold:
39
+ if args:
40
+ print(green_text(msg % _fix_args(args)))
41
+ else:
42
+ print(green_text(msg))
43
+ sys.stdout.flush()
44
+
45
+
46
+ _global_log.__class__ = Log
47
+
48
+ good = _global_log.good
49
+
50
+ def set_threshold(level, force=False):
51
+ prev_level = _global_log.threshold
52
+ if prev_level > DEBUG or force:
53
+ # If we're running at DEBUG, don't change the threshold, as there's
54
+ # likely a good reason why we're running at this level.
55
+ _global_log.threshold = level
56
+ if level <= DEBUG:
57
+ info('set_threshold: setting threshold to DEBUG level,'
58
+ ' it can be changed only with force argument')
59
+ else:
60
+ info('set_threshold: not changing threshold from DEBUG level'
61
+ ' %s to %s' % (prev_level, level))
62
+ return prev_level
63
+
64
+ def get_threshold():
65
+ return _global_log.threshold
66
+
67
+ def set_verbosity(v, force=False):
68
+ prev_level = _global_log.threshold
69
+ if v < 0:
70
+ set_threshold(ERROR, force)
71
+ elif v == 0:
72
+ set_threshold(WARN, force)
73
+ elif v == 1:
74
+ set_threshold(INFO, force)
75
+ elif v >= 2:
76
+ set_threshold(DEBUG, force)
77
+ return {FATAL:-2,ERROR:-1,WARN:0,INFO:1,DEBUG:2}.get(prev_level, 1)
78
+
79
+
80
+ _global_color_map = {
81
+ DEBUG:cyan_text,
82
+ INFO:default_text,
83
+ WARN:red_text,
84
+ ERROR:red_text,
85
+ FATAL:red_text
86
+ }
87
+
88
+ # don't use INFO,.. flags in set_verbosity, these flags are for set_threshold.
89
+ set_verbosity(0, force=True)
90
+
91
+
92
+ _error = error
93
+ _warn = warn
94
+ _info = info
95
+ _debug = debug
96
+
97
+
98
+ def error(msg, *a, **kw):
99
+ _error(f"ERROR: {msg}", *a, **kw)
100
+
101
+
102
+ def warn(msg, *a, **kw):
103
+ _warn(f"WARN: {msg}", *a, **kw)
104
+
105
+
106
+ def info(msg, *a, **kw):
107
+ _info(f"INFO: {msg}", *a, **kw)
108
+
109
+
110
+ def debug(msg, *a, **kw):
111
+ _debug(f"DEBUG: {msg}", *a, **kw)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/mingw/gfortran_vs2003_hack.c ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ int _get_output_format(void)
2
+ {
3
+ return 0;
4
+ }
5
+
6
+ int _imp____lc_codepage = 0;
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/mingw32ccompiler.py ADDED
@@ -0,0 +1,597 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Support code for building Python extensions on Windows.
3
+
4
+ # NT stuff
5
+ # 1. Make sure libpython<version>.a exists for gcc. If not, build it.
6
+ # 2. Force windows to use gcc (we're struggling with MSVC and g77 support)
7
+ # 3. Force windows to use g77
8
+
9
+ """
10
+ import os
11
+ import sys
12
+ import subprocess
13
+ import re
14
+ import textwrap
15
+
16
+ # Overwrite certain distutils.ccompiler functions:
17
+ import numpy.distutils.ccompiler # noqa: F401
18
+ from numpy.distutils import log
19
+ # NT stuff
20
+ # 1. Make sure libpython<version>.a exists for gcc. If not, build it.
21
+ # 2. Force windows to use gcc (we're struggling with MSVC and g77 support)
22
+ # --> this is done in numpy/distutils/ccompiler.py
23
+ # 3. Force windows to use g77
24
+
25
+ import distutils.cygwinccompiler
26
+ from distutils.unixccompiler import UnixCCompiler
27
+
28
+ try:
29
+ from distutils.msvccompiler import get_build_version as get_build_msvc_version
30
+ except ImportError:
31
+ def get_build_msvc_version():
32
+ return None
33
+
34
+ from distutils.errors import UnknownFileError
35
+ from numpy.distutils.misc_util import (msvc_runtime_library,
36
+ msvc_runtime_version,
37
+ msvc_runtime_major,
38
+ get_build_architecture)
39
+
40
+ def get_msvcr_replacement():
41
+ """Replacement for outdated version of get_msvcr from cygwinccompiler"""
42
+ msvcr = msvc_runtime_library()
43
+ return [] if msvcr is None else [msvcr]
44
+
45
+
46
+ # Useful to generate table of symbols from a dll
47
+ _START = re.compile(r'\[Ordinal/Name Pointer\] Table')
48
+ _TABLE = re.compile(r'^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)')
49
+
50
+ # the same as cygwin plus some additional parameters
51
+ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):
52
+ """ A modified MingW32 compiler compatible with an MSVC built Python.
53
+
54
+ """
55
+
56
+ compiler_type = 'mingw32'
57
+
58
+ def __init__ (self,
59
+ verbose=0,
60
+ dry_run=0,
61
+ force=0):
62
+
63
+ distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose,
64
+ dry_run, force)
65
+
66
+ # **changes: eric jones 4/11/01
67
+ # 1. Check for import library on Windows. Build if it doesn't exist.
68
+
69
+ build_import_library()
70
+
71
+ # Check for custom msvc runtime library on Windows. Build if it doesn't exist.
72
+ msvcr_success = build_msvcr_library()
73
+ msvcr_dbg_success = build_msvcr_library(debug=True)
74
+ if msvcr_success or msvcr_dbg_success:
75
+ # add preprocessor statement for using customized msvcr lib
76
+ self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR')
77
+
78
+ # Define the MSVC version as hint for MinGW
79
+ msvcr_version = msvc_runtime_version()
80
+ if msvcr_version:
81
+ self.define_macro('__MSVCRT_VERSION__', '0x%04i' % msvcr_version)
82
+
83
+ # MS_WIN64 should be defined when building for amd64 on windows,
84
+ # but python headers define it only for MS compilers, which has all
85
+ # kind of bad consequences, like using Py_ModuleInit4 instead of
86
+ # Py_ModuleInit4_64, etc... So we add it here
87
+ if get_build_architecture() == 'AMD64':
88
+ self.set_executables(
89
+ compiler='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall',
90
+ compiler_so='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall '
91
+ '-Wstrict-prototypes',
92
+ linker_exe='gcc -g',
93
+ linker_so='gcc -g -shared')
94
+ else:
95
+ self.set_executables(
96
+ compiler='gcc -O2 -Wall',
97
+ compiler_so='gcc -O2 -Wall -Wstrict-prototypes',
98
+ linker_exe='g++ ',
99
+ linker_so='g++ -shared')
100
+ # added for python2.3 support
101
+ # we can't pass it through set_executables because pre 2.2 would fail
102
+ self.compiler_cxx = ['g++']
103
+
104
+ # Maybe we should also append -mthreads, but then the finished dlls
105
+ # need another dll (mingwm10.dll see Mingw32 docs) (-mthreads: Support
106
+ # thread-safe exception handling on `Mingw32')
107
+
108
+ # no additional libraries needed
109
+ #self.dll_libraries=[]
110
+ return
111
+
112
+ # __init__ ()
113
+
114
+ def link(self,
115
+ target_desc,
116
+ objects,
117
+ output_filename,
118
+ output_dir,
119
+ libraries,
120
+ library_dirs,
121
+ runtime_library_dirs,
122
+ export_symbols = None,
123
+ debug=0,
124
+ extra_preargs=None,
125
+ extra_postargs=None,
126
+ build_temp=None,
127
+ target_lang=None):
128
+ # Include the appropriate MSVC runtime library if Python was built
129
+ # with MSVC >= 7.0 (MinGW standard is msvcrt)
130
+ runtime_library = msvc_runtime_library()
131
+ if runtime_library:
132
+ if not libraries:
133
+ libraries = []
134
+ libraries.append(runtime_library)
135
+ args = (self,
136
+ target_desc,
137
+ objects,
138
+ output_filename,
139
+ output_dir,
140
+ libraries,
141
+ library_dirs,
142
+ runtime_library_dirs,
143
+ None, #export_symbols, we do this in our def-file
144
+ debug,
145
+ extra_preargs,
146
+ extra_postargs,
147
+ build_temp,
148
+ target_lang)
149
+ func = UnixCCompiler.link
150
+ func(*args[:func.__code__.co_argcount])
151
+ return
152
+
153
+ def object_filenames (self,
154
+ source_filenames,
155
+ strip_dir=0,
156
+ output_dir=''):
157
+ if output_dir is None: output_dir = ''
158
+ obj_names = []
159
+ for src_name in source_filenames:
160
+ # use normcase to make sure '.rc' is really '.rc' and not '.RC'
161
+ (base, ext) = os.path.splitext (os.path.normcase(src_name))
162
+
163
+ # added these lines to strip off windows drive letters
164
+ # without it, .o files are placed next to .c files
165
+ # instead of the build directory
166
+ drv, base = os.path.splitdrive(base)
167
+ if drv:
168
+ base = base[1:]
169
+
170
+ if ext not in (self.src_extensions + ['.rc', '.res']):
171
+ raise UnknownFileError(
172
+ "unknown file type '%s' (from '%s')" % \
173
+ (ext, src_name))
174
+ if strip_dir:
175
+ base = os.path.basename (base)
176
+ if ext == '.res' or ext == '.rc':
177
+ # these need to be compiled to object files
178
+ obj_names.append (os.path.join (output_dir,
179
+ base + ext + self.obj_extension))
180
+ else:
181
+ obj_names.append (os.path.join (output_dir,
182
+ base + self.obj_extension))
183
+ return obj_names
184
+
185
+ # object_filenames ()
186
+
187
+
188
+ def find_python_dll():
189
+ # We can't do much here:
190
+ # - find it in the virtualenv (sys.prefix)
191
+ # - find it in python main dir (sys.base_prefix, if in a virtualenv)
192
+ # - in system32,
193
+ # - otherwise (Sxs), I don't know how to get it.
194
+ stems = [sys.prefix]
195
+ if sys.base_prefix != sys.prefix:
196
+ stems.append(sys.base_prefix)
197
+
198
+ sub_dirs = ['', 'lib', 'bin']
199
+ # generate possible combinations of directory trees and sub-directories
200
+ lib_dirs = []
201
+ for stem in stems:
202
+ for folder in sub_dirs:
203
+ lib_dirs.append(os.path.join(stem, folder))
204
+
205
+ # add system directory as well
206
+ if 'SYSTEMROOT' in os.environ:
207
+ lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'System32'))
208
+
209
+ # search in the file system for possible candidates
210
+ major_version, minor_version = tuple(sys.version_info[:2])
211
+ implementation = sys.implementation.name
212
+ if implementation == 'cpython':
213
+ dllname = f'python{major_version}{minor_version}.dll'
214
+ elif implementation == 'pypy':
215
+ dllname = f'libpypy{major_version}.{minor_version}-c.dll'
216
+ else:
217
+ dllname = f'Unknown platform {implementation}'
218
+ print("Looking for %s" % dllname)
219
+ for folder in lib_dirs:
220
+ dll = os.path.join(folder, dllname)
221
+ if os.path.exists(dll):
222
+ return dll
223
+
224
+ raise ValueError("%s not found in %s" % (dllname, lib_dirs))
225
+
226
+ def dump_table(dll):
227
+ st = subprocess.check_output(["objdump.exe", "-p", dll])
228
+ return st.split(b'\n')
229
+
230
+ def generate_def(dll, dfile):
231
+ """Given a dll file location, get all its exported symbols and dump them
232
+ into the given def file.
233
+
234
+ The .def file will be overwritten"""
235
+ dump = dump_table(dll)
236
+ for i in range(len(dump)):
237
+ if _START.match(dump[i].decode()):
238
+ break
239
+ else:
240
+ raise ValueError("Symbol table not found")
241
+
242
+ syms = []
243
+ for j in range(i+1, len(dump)):
244
+ m = _TABLE.match(dump[j].decode())
245
+ if m:
246
+ syms.append((int(m.group(1).strip()), m.group(2)))
247
+ else:
248
+ break
249
+
250
+ if len(syms) == 0:
251
+ log.warn('No symbols found in %s' % dll)
252
+
253
+ with open(dfile, 'w') as d:
254
+ d.write('LIBRARY %s\n' % os.path.basename(dll))
255
+ d.write(';CODE PRELOAD MOVEABLE DISCARDABLE\n')
256
+ d.write(';DATA PRELOAD SINGLE\n')
257
+ d.write('\nEXPORTS\n')
258
+ for s in syms:
259
+ #d.write('@%d %s\n' % (s[0], s[1]))
260
+ d.write('%s\n' % s[1])
261
+
262
+ def find_dll(dll_name):
263
+
264
+ arch = {'AMD64' : 'amd64',
265
+ 'Intel' : 'x86'}[get_build_architecture()]
266
+
267
+ def _find_dll_in_winsxs(dll_name):
268
+ # Walk through the WinSxS directory to find the dll.
269
+ winsxs_path = os.path.join(os.environ.get('WINDIR', r'C:\WINDOWS'),
270
+ 'winsxs')
271
+ if not os.path.exists(winsxs_path):
272
+ return None
273
+ for root, dirs, files in os.walk(winsxs_path):
274
+ if dll_name in files and arch in root:
275
+ return os.path.join(root, dll_name)
276
+ return None
277
+
278
+ def _find_dll_in_path(dll_name):
279
+ # First, look in the Python directory, then scan PATH for
280
+ # the given dll name.
281
+ for path in [sys.prefix] + os.environ['PATH'].split(';'):
282
+ filepath = os.path.join(path, dll_name)
283
+ if os.path.exists(filepath):
284
+ return os.path.abspath(filepath)
285
+
286
+ return _find_dll_in_winsxs(dll_name) or _find_dll_in_path(dll_name)
287
+
288
+ def build_msvcr_library(debug=False):
289
+ if os.name != 'nt':
290
+ return False
291
+
292
+ # If the version number is None, then we couldn't find the MSVC runtime at
293
+ # all, because we are running on a Python distribution which is customed
294
+ # compiled; trust that the compiler is the same as the one available to us
295
+ # now, and that it is capable of linking with the correct runtime without
296
+ # any extra options.
297
+ msvcr_ver = msvc_runtime_major()
298
+ if msvcr_ver is None:
299
+ log.debug('Skip building import library: '
300
+ 'Runtime is not compiled with MSVC')
301
+ return False
302
+
303
+ # Skip using a custom library for versions < MSVC 8.0
304
+ if msvcr_ver < 80:
305
+ log.debug('Skip building msvcr library:'
306
+ ' custom functionality not present')
307
+ return False
308
+
309
+ msvcr_name = msvc_runtime_library()
310
+ if debug:
311
+ msvcr_name += 'd'
312
+
313
+ # Skip if custom library already exists
314
+ out_name = "lib%s.a" % msvcr_name
315
+ out_file = os.path.join(sys.prefix, 'libs', out_name)
316
+ if os.path.isfile(out_file):
317
+ log.debug('Skip building msvcr library: "%s" exists' %
318
+ (out_file,))
319
+ return True
320
+
321
+ # Find the msvcr dll
322
+ msvcr_dll_name = msvcr_name + '.dll'
323
+ dll_file = find_dll(msvcr_dll_name)
324
+ if not dll_file:
325
+ log.warn('Cannot build msvcr library: "%s" not found' %
326
+ msvcr_dll_name)
327
+ return False
328
+
329
+ def_name = "lib%s.def" % msvcr_name
330
+ def_file = os.path.join(sys.prefix, 'libs', def_name)
331
+
332
+ log.info('Building msvcr library: "%s" (from %s)' \
333
+ % (out_file, dll_file))
334
+
335
+ # Generate a symbol definition file from the msvcr dll
336
+ generate_def(dll_file, def_file)
337
+
338
+ # Create a custom mingw library for the given symbol definitions
339
+ cmd = ['dlltool', '-d', def_file, '-l', out_file]
340
+ retcode = subprocess.call(cmd)
341
+
342
+ # Clean up symbol definitions
343
+ os.remove(def_file)
344
+
345
+ return (not retcode)
346
+
347
+ def build_import_library():
348
+ if os.name != 'nt':
349
+ return
350
+
351
+ arch = get_build_architecture()
352
+ if arch == 'AMD64':
353
+ return _build_import_library_amd64()
354
+ elif arch == 'Intel':
355
+ return _build_import_library_x86()
356
+ else:
357
+ raise ValueError("Unhandled arch %s" % arch)
358
+
359
+ def _check_for_import_lib():
360
+ """Check if an import library for the Python runtime already exists."""
361
+ major_version, minor_version = tuple(sys.version_info[:2])
362
+
363
+ # patterns for the file name of the library itself
364
+ patterns = ['libpython%d%d.a',
365
+ 'libpython%d%d.dll.a',
366
+ 'libpython%d.%d.dll.a']
367
+
368
+ # directory trees that may contain the library
369
+ stems = [sys.prefix]
370
+ if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
371
+ stems.append(sys.base_prefix)
372
+ elif hasattr(sys, 'real_prefix') and sys.real_prefix != sys.prefix:
373
+ stems.append(sys.real_prefix)
374
+
375
+ # possible subdirectories within those trees where it is placed
376
+ sub_dirs = ['libs', 'lib']
377
+
378
+ # generate a list of candidate locations
379
+ candidates = []
380
+ for pat in patterns:
381
+ filename = pat % (major_version, minor_version)
382
+ for stem_dir in stems:
383
+ for folder in sub_dirs:
384
+ candidates.append(os.path.join(stem_dir, folder, filename))
385
+
386
+ # test the filesystem to see if we can find any of these
387
+ for fullname in candidates:
388
+ if os.path.isfile(fullname):
389
+ # already exists, in location given
390
+ return (True, fullname)
391
+
392
+ # needs to be built, preferred location given first
393
+ return (False, candidates[0])
394
+
395
+ def _build_import_library_amd64():
396
+ out_exists, out_file = _check_for_import_lib()
397
+ if out_exists:
398
+ log.debug('Skip building import library: "%s" exists', out_file)
399
+ return
400
+
401
+ # get the runtime dll for which we are building import library
402
+ dll_file = find_python_dll()
403
+ log.info('Building import library (arch=AMD64): "%s" (from %s)' %
404
+ (out_file, dll_file))
405
+
406
+ # generate symbol list from this library
407
+ def_name = "python%d%d.def" % tuple(sys.version_info[:2])
408
+ def_file = os.path.join(sys.prefix, 'libs', def_name)
409
+ generate_def(dll_file, def_file)
410
+
411
+ # generate import library from this symbol list
412
+ cmd = ['dlltool', '-d', def_file, '-l', out_file]
413
+ subprocess.check_call(cmd)
414
+
415
+ def _build_import_library_x86():
416
+ """ Build the import libraries for Mingw32-gcc on Windows
417
+ """
418
+ out_exists, out_file = _check_for_import_lib()
419
+ if out_exists:
420
+ log.debug('Skip building import library: "%s" exists', out_file)
421
+ return
422
+
423
+ lib_name = "python%d%d.lib" % tuple(sys.version_info[:2])
424
+ lib_file = os.path.join(sys.prefix, 'libs', lib_name)
425
+ if not os.path.isfile(lib_file):
426
+ # didn't find library file in virtualenv, try base distribution, too,
427
+ # and use that instead if found there. for Python 2.7 venvs, the base
428
+ # directory is in attribute real_prefix instead of base_prefix.
429
+ if hasattr(sys, 'base_prefix'):
430
+ base_lib = os.path.join(sys.base_prefix, 'libs', lib_name)
431
+ elif hasattr(sys, 'real_prefix'):
432
+ base_lib = os.path.join(sys.real_prefix, 'libs', lib_name)
433
+ else:
434
+ base_lib = '' # os.path.isfile('') == False
435
+
436
+ if os.path.isfile(base_lib):
437
+ lib_file = base_lib
438
+ else:
439
+ log.warn('Cannot build import library: "%s" not found', lib_file)
440
+ return
441
+ log.info('Building import library (ARCH=x86): "%s"', out_file)
442
+
443
+ from numpy.distutils import lib2def
444
+
445
+ def_name = "python%d%d.def" % tuple(sys.version_info[:2])
446
+ def_file = os.path.join(sys.prefix, 'libs', def_name)
447
+ nm_output = lib2def.getnm(
448
+ lib2def.DEFAULT_NM + [lib_file], shell=False)
449
+ dlist, flist = lib2def.parse_nm(nm_output)
450
+ with open(def_file, 'w') as fid:
451
+ lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, fid)
452
+
453
+ dll_name = find_python_dll ()
454
+
455
+ cmd = ["dlltool",
456
+ "--dllname", dll_name,
457
+ "--def", def_file,
458
+ "--output-lib", out_file]
459
+ status = subprocess.check_output(cmd)
460
+ if status:
461
+ log.warn('Failed to build import library for gcc. Linking will fail.')
462
+ return
463
+
464
+ #=====================================
465
+ # Dealing with Visual Studio MANIFESTS
466
+ #=====================================
467
+
468
+ # Functions to deal with visual studio manifests. Manifest are a mechanism to
469
+ # enforce strong DLL versioning on windows, and has nothing to do with
470
+ # distutils MANIFEST. manifests are XML files with version info, and used by
471
+ # the OS loader; they are necessary when linking against a DLL not in the
472
+ # system path; in particular, official python 2.6 binary is built against the
473
+ # MS runtime 9 (the one from VS 2008), which is not available on most windows
474
+ # systems; python 2.6 installer does install it in the Win SxS (Side by side)
475
+ # directory, but this requires the manifest for this to work. This is a big
476
+ # mess, thanks MS for a wonderful system.
477
+
478
+ # XXX: ideally, we should use exactly the same version as used by python. I
479
+ # submitted a patch to get this version, but it was only included for python
480
+ # 2.6.1 and above. So for versions below, we use a "best guess".
481
+ _MSVCRVER_TO_FULLVER = {}
482
+ if sys.platform == 'win32':
483
+ try:
484
+ import msvcrt
485
+ # I took one version in my SxS directory: no idea if it is the good
486
+ # one, and we can't retrieve it from python
487
+ _MSVCRVER_TO_FULLVER['80'] = "8.0.50727.42"
488
+ _MSVCRVER_TO_FULLVER['90'] = "9.0.21022.8"
489
+ # Value from msvcrt.CRT_ASSEMBLY_VERSION under Python 3.3.0
490
+ # on Windows XP:
491
+ _MSVCRVER_TO_FULLVER['100'] = "10.0.30319.460"
492
+ crt_ver = getattr(msvcrt, 'CRT_ASSEMBLY_VERSION', None)
493
+ if crt_ver is not None: # Available at least back to Python 3.3
494
+ maj, min = re.match(r'(\d+)\.(\d)', crt_ver).groups()
495
+ _MSVCRVER_TO_FULLVER[maj + min] = crt_ver
496
+ del maj, min
497
+ del crt_ver
498
+ except ImportError:
499
+ # If we are here, means python was not built with MSVC. Not sure what
500
+ # to do in that case: manifest building will fail, but it should not be
501
+ # used in that case anyway
502
+ log.warn('Cannot import msvcrt: using manifest will not be possible')
503
+
504
+ def msvc_manifest_xml(maj, min):
505
+ """Given a major and minor version of the MSVCR, returns the
506
+ corresponding XML file."""
507
+ try:
508
+ fullver = _MSVCRVER_TO_FULLVER[str(maj * 10 + min)]
509
+ except KeyError:
510
+ raise ValueError("Version %d,%d of MSVCRT not supported yet" %
511
+ (maj, min)) from None
512
+ # Don't be fooled, it looks like an XML, but it is not. In particular, it
513
+ # should not have any space before starting, and its size should be
514
+ # divisible by 4, most likely for alignment constraints when the xml is
515
+ # embedded in the binary...
516
+ # This template was copied directly from the python 2.6 binary (using
517
+ # strings.exe from mingw on python.exe).
518
+ template = textwrap.dedent("""\
519
+ <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
520
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
521
+ <security>
522
+ <requestedPrivileges>
523
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
524
+ </requestedPrivileges>
525
+ </security>
526
+ </trustInfo>
527
+ <dependency>
528
+ <dependentAssembly>
529
+ <assemblyIdentity type="win32" name="Microsoft.VC%(maj)d%(min)d.CRT" version="%(fullver)s" processorArchitecture="*" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
530
+ </dependentAssembly>
531
+ </dependency>
532
+ </assembly>""")
533
+
534
+ return template % {'fullver': fullver, 'maj': maj, 'min': min}
535
+
536
+ def manifest_rc(name, type='dll'):
537
+ """Return the rc file used to generate the res file which will be embedded
538
+ as manifest for given manifest file name, of given type ('dll' or
539
+ 'exe').
540
+
541
+ Parameters
542
+ ----------
543
+ name : str
544
+ name of the manifest file to embed
545
+ type : str {'dll', 'exe'}
546
+ type of the binary which will embed the manifest
547
+
548
+ """
549
+ if type == 'dll':
550
+ rctype = 2
551
+ elif type == 'exe':
552
+ rctype = 1
553
+ else:
554
+ raise ValueError("Type %s not supported" % type)
555
+
556
+ return """\
557
+ #include "winuser.h"
558
+ %d RT_MANIFEST %s""" % (rctype, name)
559
+
560
+ def check_embedded_msvcr_match_linked(msver):
561
+ """msver is the ms runtime version used for the MANIFEST."""
562
+ # check msvcr major version are the same for linking and
563
+ # embedding
564
+ maj = msvc_runtime_major()
565
+ if maj:
566
+ if not maj == int(msver):
567
+ raise ValueError(
568
+ "Discrepancy between linked msvcr " \
569
+ "(%d) and the one about to be embedded " \
570
+ "(%d)" % (int(msver), maj))
571
+
572
+ def configtest_name(config):
573
+ base = os.path.basename(config._gen_temp_sourcefile("yo", [], "c"))
574
+ return os.path.splitext(base)[0]
575
+
576
+ def manifest_name(config):
577
+ # Get configest name (including suffix)
578
+ root = configtest_name(config)
579
+ exext = config.compiler.exe_extension
580
+ return root + exext + ".manifest"
581
+
582
+ def rc_name(config):
583
+ # Get configtest name (including suffix)
584
+ root = configtest_name(config)
585
+ return root + ".rc"
586
+
587
+ def generate_manifest(config):
588
+ msver = get_build_msvc_version()
589
+ if msver is not None:
590
+ if msver >= 8:
591
+ check_embedded_msvcr_match_linked(msver)
592
+ ma_str, mi_str = str(msver).split('.')
593
+ # Write the manifest file
594
+ manxml = msvc_manifest_xml(int(ma_str), int(mi_str))
595
+ with open(manifest_name(config), "w") as man:
596
+ config.temp_files.append(manifest_name(config))
597
+ man.write(manxml)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/misc_util.py ADDED
@@ -0,0 +1,2484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import sys
4
+ import copy
5
+ import glob
6
+ import atexit
7
+ import tempfile
8
+ import subprocess
9
+ import shutil
10
+ import multiprocessing
11
+ import textwrap
12
+ import importlib.util
13
+ from threading import local as tlocal
14
+ from functools import reduce
15
+
16
+ import distutils
17
+ from distutils.errors import DistutilsError
18
+
19
+ # stores temporary directory of each thread to only create one per thread
20
+ _tdata = tlocal()
21
+
22
+ # store all created temporary directories so they can be deleted on exit
23
+ _tmpdirs = []
24
+ def clean_up_temporary_directory():
25
+ if _tmpdirs is not None:
26
+ for d in _tmpdirs:
27
+ try:
28
+ shutil.rmtree(d)
29
+ except OSError:
30
+ pass
31
+
32
+ atexit.register(clean_up_temporary_directory)
33
+
34
+ __all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',
35
+ 'dict_append', 'appendpath', 'generate_config_py',
36
+ 'get_cmd', 'allpath', 'get_mathlibs',
37
+ 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',
38
+ 'blue_text', 'cyan_text', 'cyg2win32', 'mingw32', 'all_strings',
39
+ 'has_f_sources', 'has_cxx_sources', 'filter_sources',
40
+ 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',
41
+ 'get_script_files', 'get_lib_source_files', 'get_data_files',
42
+ 'dot_join', 'get_frame', 'minrelpath', 'njoin',
43
+ 'is_sequence', 'is_string', 'as_list', 'gpaths', 'get_language',
44
+ 'get_build_architecture', 'get_info', 'get_pkg_info',
45
+ 'get_num_build_jobs', 'sanitize_cxx_flags',
46
+ 'exec_mod_from_location']
47
+
48
+ class InstallableLib:
49
+ """
50
+ Container to hold information on an installable library.
51
+
52
+ Parameters
53
+ ----------
54
+ name : str
55
+ Name of the installed library.
56
+ build_info : dict
57
+ Dictionary holding build information.
58
+ target_dir : str
59
+ Absolute path specifying where to install the library.
60
+
61
+ See Also
62
+ --------
63
+ Configuration.add_installed_library
64
+
65
+ Notes
66
+ -----
67
+ The three parameters are stored as attributes with the same names.
68
+
69
+ """
70
+ def __init__(self, name, build_info, target_dir):
71
+ self.name = name
72
+ self.build_info = build_info
73
+ self.target_dir = target_dir
74
+
75
+
76
+ def get_num_build_jobs():
77
+ """
78
+ Get number of parallel build jobs set by the --parallel command line
79
+ argument of setup.py
80
+ If the command did not receive a setting the environment variable
81
+ NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of
82
+ processors on the system, with a maximum of 8 (to prevent
83
+ overloading the system if there a lot of CPUs).
84
+
85
+ Returns
86
+ -------
87
+ out : int
88
+ number of parallel jobs that can be run
89
+
90
+ """
91
+ from numpy.distutils.core import get_distribution
92
+ try:
93
+ cpu_count = len(os.sched_getaffinity(0))
94
+ except AttributeError:
95
+ cpu_count = multiprocessing.cpu_count()
96
+ cpu_count = min(cpu_count, 8)
97
+ envjobs = int(os.environ.get("NPY_NUM_BUILD_JOBS", cpu_count))
98
+ dist = get_distribution()
99
+ # may be None during configuration
100
+ if dist is None:
101
+ return envjobs
102
+
103
+ # any of these three may have the job set, take the largest
104
+ cmdattr = (getattr(dist.get_command_obj('build'), 'parallel', None),
105
+ getattr(dist.get_command_obj('build_ext'), 'parallel', None),
106
+ getattr(dist.get_command_obj('build_clib'), 'parallel', None))
107
+ if all(x is None for x in cmdattr):
108
+ return envjobs
109
+ else:
110
+ return max(x for x in cmdattr if x is not None)
111
+
112
+ def quote_args(args):
113
+ """Quote list of arguments.
114
+
115
+ .. deprecated:: 1.22.
116
+ """
117
+ import warnings
118
+ warnings.warn('"quote_args" is deprecated.',
119
+ DeprecationWarning, stacklevel=2)
120
+ # don't used _nt_quote_args as it does not check if
121
+ # args items already have quotes or not.
122
+ args = list(args)
123
+ for i in range(len(args)):
124
+ a = args[i]
125
+ if ' ' in a and a[0] not in '"\'':
126
+ args[i] = '"%s"' % (a)
127
+ return args
128
+
129
+ def allpath(name):
130
+ "Convert a /-separated pathname to one using the OS's path separator."
131
+ split = name.split('/')
132
+ return os.path.join(*split)
133
+
134
+ def rel_path(path, parent_path):
135
+ """Return path relative to parent_path."""
136
+ # Use realpath to avoid issues with symlinked dirs (see gh-7707)
137
+ pd = os.path.realpath(os.path.abspath(parent_path))
138
+ apath = os.path.realpath(os.path.abspath(path))
139
+ if len(apath) < len(pd):
140
+ return path
141
+ if apath == pd:
142
+ return ''
143
+ if pd == apath[:len(pd)]:
144
+ assert apath[len(pd)] in [os.sep], repr((path, apath[len(pd)]))
145
+ path = apath[len(pd)+1:]
146
+ return path
147
+
148
+ def get_path_from_frame(frame, parent_path=None):
149
+ """Return path of the module given a frame object from the call stack.
150
+
151
+ Returned path is relative to parent_path when given,
152
+ otherwise it is absolute path.
153
+ """
154
+
155
+ # First, try to find if the file name is in the frame.
156
+ try:
157
+ caller_file = eval('__file__', frame.f_globals, frame.f_locals)
158
+ d = os.path.dirname(os.path.abspath(caller_file))
159
+ except NameError:
160
+ # __file__ is not defined, so let's try __name__. We try this second
161
+ # because setuptools spoofs __name__ to be '__main__' even though
162
+ # sys.modules['__main__'] might be something else, like easy_install(1).
163
+ caller_name = eval('__name__', frame.f_globals, frame.f_locals)
164
+ __import__(caller_name)
165
+ mod = sys.modules[caller_name]
166
+ if hasattr(mod, '__file__'):
167
+ d = os.path.dirname(os.path.abspath(mod.__file__))
168
+ else:
169
+ # we're probably running setup.py as execfile("setup.py")
170
+ # (likely we're building an egg)
171
+ d = os.path.abspath('.')
172
+
173
+ if parent_path is not None:
174
+ d = rel_path(d, parent_path)
175
+
176
+ return d or '.'
177
+
178
+ def njoin(*path):
179
+ """Join two or more pathname components +
180
+ - convert a /-separated pathname to one using the OS's path separator.
181
+ - resolve `..` and `.` from path.
182
+
183
+ Either passing n arguments as in njoin('a','b'), or a sequence
184
+ of n names as in njoin(['a','b']) is handled, or a mixture of such arguments.
185
+ """
186
+ paths = []
187
+ for p in path:
188
+ if is_sequence(p):
189
+ # njoin(['a', 'b'], 'c')
190
+ paths.append(njoin(*p))
191
+ else:
192
+ assert is_string(p)
193
+ paths.append(p)
194
+ path = paths
195
+ if not path:
196
+ # njoin()
197
+ joined = ''
198
+ else:
199
+ # njoin('a', 'b')
200
+ joined = os.path.join(*path)
201
+ if os.path.sep != '/':
202
+ joined = joined.replace('/', os.path.sep)
203
+ return minrelpath(joined)
204
+
205
+ def get_mathlibs(path=None):
206
+ """Return the MATHLIB line from numpyconfig.h
207
+ """
208
+ if path is not None:
209
+ config_file = os.path.join(path, '_numpyconfig.h')
210
+ else:
211
+ # Look for the file in each of the numpy include directories.
212
+ dirs = get_numpy_include_dirs()
213
+ for path in dirs:
214
+ fn = os.path.join(path, '_numpyconfig.h')
215
+ if os.path.exists(fn):
216
+ config_file = fn
217
+ break
218
+ else:
219
+ raise DistutilsError('_numpyconfig.h not found in numpy include '
220
+ 'dirs %r' % (dirs,))
221
+
222
+ with open(config_file) as fid:
223
+ mathlibs = []
224
+ s = '#define MATHLIB'
225
+ for line in fid:
226
+ if line.startswith(s):
227
+ value = line[len(s):].strip()
228
+ if value:
229
+ mathlibs.extend(value.split(','))
230
+ return mathlibs
231
+
232
+ def minrelpath(path):
233
+ """Resolve `..` and '.' from path.
234
+ """
235
+ if not is_string(path):
236
+ return path
237
+ if '.' not in path:
238
+ return path
239
+ l = path.split(os.sep)
240
+ while l:
241
+ try:
242
+ i = l.index('.', 1)
243
+ except ValueError:
244
+ break
245
+ del l[i]
246
+ j = 1
247
+ while l:
248
+ try:
249
+ i = l.index('..', j)
250
+ except ValueError:
251
+ break
252
+ if l[i-1]=='..':
253
+ j += 1
254
+ else:
255
+ del l[i], l[i-1]
256
+ j = 1
257
+ if not l:
258
+ return ''
259
+ return os.sep.join(l)
260
+
261
+ def sorted_glob(fileglob):
262
+ """sorts output of python glob for https://bugs.python.org/issue30461
263
+ to allow extensions to have reproducible build results"""
264
+ return sorted(glob.glob(fileglob))
265
+
266
+ def _fix_paths(paths, local_path, include_non_existing):
267
+ assert is_sequence(paths), repr(type(paths))
268
+ new_paths = []
269
+ assert not is_string(paths), repr(paths)
270
+ for n in paths:
271
+ if is_string(n):
272
+ if '*' in n or '?' in n:
273
+ p = sorted_glob(n)
274
+ p2 = sorted_glob(njoin(local_path, n))
275
+ if p2:
276
+ new_paths.extend(p2)
277
+ elif p:
278
+ new_paths.extend(p)
279
+ else:
280
+ if include_non_existing:
281
+ new_paths.append(n)
282
+ print('could not resolve pattern in %r: %r' %
283
+ (local_path, n))
284
+ else:
285
+ n2 = njoin(local_path, n)
286
+ if os.path.exists(n2):
287
+ new_paths.append(n2)
288
+ else:
289
+ if os.path.exists(n):
290
+ new_paths.append(n)
291
+ elif include_non_existing:
292
+ new_paths.append(n)
293
+ if not os.path.exists(n):
294
+ print('non-existing path in %r: %r' %
295
+ (local_path, n))
296
+
297
+ elif is_sequence(n):
298
+ new_paths.extend(_fix_paths(n, local_path, include_non_existing))
299
+ else:
300
+ new_paths.append(n)
301
+ return [minrelpath(p) for p in new_paths]
302
+
303
+ def gpaths(paths, local_path='', include_non_existing=True):
304
+ """Apply glob to paths and prepend local_path if needed.
305
+ """
306
+ if is_string(paths):
307
+ paths = (paths,)
308
+ return _fix_paths(paths, local_path, include_non_existing)
309
+
310
+ def make_temp_file(suffix='', prefix='', text=True):
311
+ if not hasattr(_tdata, 'tempdir'):
312
+ _tdata.tempdir = tempfile.mkdtemp()
313
+ _tmpdirs.append(_tdata.tempdir)
314
+ fid, name = tempfile.mkstemp(suffix=suffix,
315
+ prefix=prefix,
316
+ dir=_tdata.tempdir,
317
+ text=text)
318
+ fo = os.fdopen(fid, 'w')
319
+ return fo, name
320
+
321
+ # Hooks for colored terminal output.
322
+ # See also https://web.archive.org/web/20100314204946/http://www.livinglogic.de/Python/ansistyle
323
+ def terminal_has_colors():
324
+ if sys.platform=='cygwin' and 'USE_COLOR' not in os.environ:
325
+ # Avoid importing curses that causes illegal operation
326
+ # with a message:
327
+ # PYTHON2 caused an invalid page fault in
328
+ # module CYGNURSES7.DLL as 015f:18bbfc28
329
+ # Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]
330
+ # ssh to Win32 machine from debian
331
+ # curses.version is 2.2
332
+ # CYGWIN_98-4.10, release 1.5.7(0.109/3/2))
333
+ return 0
334
+ if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty():
335
+ try:
336
+ import curses
337
+ curses.setupterm()
338
+ if (curses.tigetnum("colors") >= 0
339
+ and curses.tigetnum("pairs") >= 0
340
+ and ((curses.tigetstr("setf") is not None
341
+ and curses.tigetstr("setb") is not None)
342
+ or (curses.tigetstr("setaf") is not None
343
+ and curses.tigetstr("setab") is not None)
344
+ or curses.tigetstr("scp") is not None)):
345
+ return 1
346
+ except Exception:
347
+ pass
348
+ return 0
349
+
350
+ if terminal_has_colors():
351
+ _colour_codes = dict(black=0, red=1, green=2, yellow=3,
352
+ blue=4, magenta=5, cyan=6, white=7, default=9)
353
+ def colour_text(s, fg=None, bg=None, bold=False):
354
+ seq = []
355
+ if bold:
356
+ seq.append('1')
357
+ if fg:
358
+ fgcode = 30 + _colour_codes.get(fg.lower(), 0)
359
+ seq.append(str(fgcode))
360
+ if bg:
361
+ bgcode = 40 + _colour_codes.get(bg.lower(), 7)
362
+ seq.append(str(bgcode))
363
+ if seq:
364
+ return '\x1b[%sm%s\x1b[0m' % (';'.join(seq), s)
365
+ else:
366
+ return s
367
+ else:
368
+ def colour_text(s, fg=None, bg=None):
369
+ return s
370
+
371
+ def default_text(s):
372
+ return colour_text(s, 'default')
373
+ def red_text(s):
374
+ return colour_text(s, 'red')
375
+ def green_text(s):
376
+ return colour_text(s, 'green')
377
+ def yellow_text(s):
378
+ return colour_text(s, 'yellow')
379
+ def cyan_text(s):
380
+ return colour_text(s, 'cyan')
381
+ def blue_text(s):
382
+ return colour_text(s, 'blue')
383
+
384
+ #########################
385
+
386
+ def cyg2win32(path: str) -> str:
387
+ """Convert a path from Cygwin-native to Windows-native.
388
+
389
+ Uses the cygpath utility (part of the Base install) to do the
390
+ actual conversion. Falls back to returning the original path if
391
+ this fails.
392
+
393
+ Handles the default ``/cygdrive`` mount prefix as well as the
394
+ ``/proc/cygdrive`` portable prefix, custom cygdrive prefixes such
395
+ as ``/`` or ``/mnt``, and absolute paths such as ``/usr/src/`` or
396
+ ``/home/username``
397
+
398
+ Parameters
399
+ ----------
400
+ path : str
401
+ The path to convert
402
+
403
+ Returns
404
+ -------
405
+ converted_path : str
406
+ The converted path
407
+
408
+ Notes
409
+ -----
410
+ Documentation for cygpath utility:
411
+ https://cygwin.com/cygwin-ug-net/cygpath.html
412
+ Documentation for the C function it wraps:
413
+ https://cygwin.com/cygwin-api/func-cygwin-conv-path.html
414
+
415
+ """
416
+ if sys.platform != "cygwin":
417
+ return path
418
+ return subprocess.check_output(
419
+ ["/usr/bin/cygpath", "--windows", path], text=True
420
+ )
421
+
422
+
423
+ def mingw32():
424
+ """Return true when using mingw32 environment.
425
+ """
426
+ if sys.platform=='win32':
427
+ if os.environ.get('OSTYPE', '')=='msys':
428
+ return True
429
+ if os.environ.get('MSYSTEM', '')=='MINGW32':
430
+ return True
431
+ return False
432
+
433
+ def msvc_runtime_version():
434
+ "Return version of MSVC runtime library, as defined by __MSC_VER__ macro"
435
+ msc_pos = sys.version.find('MSC v.')
436
+ if msc_pos != -1:
437
+ msc_ver = int(sys.version[msc_pos+6:msc_pos+10])
438
+ else:
439
+ msc_ver = None
440
+ return msc_ver
441
+
442
+ def msvc_runtime_library():
443
+ "Return name of MSVC runtime library if Python was built with MSVC >= 7"
444
+ ver = msvc_runtime_major ()
445
+ if ver:
446
+ if ver < 140:
447
+ return "msvcr%i" % ver
448
+ else:
449
+ return "vcruntime%i" % ver
450
+ else:
451
+ return None
452
+
453
+ def msvc_runtime_major():
454
+ "Return major version of MSVC runtime coded like get_build_msvc_version"
455
+ major = {1300: 70, # MSVC 7.0
456
+ 1310: 71, # MSVC 7.1
457
+ 1400: 80, # MSVC 8
458
+ 1500: 90, # MSVC 9 (aka 2008)
459
+ 1600: 100, # MSVC 10 (aka 2010)
460
+ 1900: 140, # MSVC 14 (aka 2015)
461
+ }.get(msvc_runtime_version(), None)
462
+ return major
463
+
464
+ #########################
465
+
466
+ #XXX need support for .C that is also C++
467
+ cxx_ext_match = re.compile(r'.*\.(cpp|cxx|cc)\Z', re.I).match
468
+ fortran_ext_match = re.compile(r'.*\.(f90|f95|f77|for|ftn|f)\Z', re.I).match
469
+ f90_ext_match = re.compile(r'.*\.(f90|f95)\Z', re.I).match
470
+ f90_module_name_match = re.compile(r'\s*module\s*(?P<name>[\w_]+)', re.I).match
471
+ def _get_f90_modules(source):
472
+ """Return a list of Fortran f90 module names that
473
+ given source file defines.
474
+ """
475
+ if not f90_ext_match(source):
476
+ return []
477
+ modules = []
478
+ with open(source) as f:
479
+ for line in f:
480
+ m = f90_module_name_match(line)
481
+ if m:
482
+ name = m.group('name')
483
+ modules.append(name)
484
+ # break # XXX can we assume that there is one module per file?
485
+ return modules
486
+
487
+ def is_string(s):
488
+ return isinstance(s, str)
489
+
490
+ def all_strings(lst):
491
+ """Return True if all items in lst are string objects. """
492
+ return all(is_string(item) for item in lst)
493
+
494
+ def is_sequence(seq):
495
+ if is_string(seq):
496
+ return False
497
+ try:
498
+ len(seq)
499
+ except Exception:
500
+ return False
501
+ return True
502
+
503
+ def is_glob_pattern(s):
504
+ return is_string(s) and ('*' in s or '?' in s)
505
+
506
+ def as_list(seq):
507
+ if is_sequence(seq):
508
+ return list(seq)
509
+ else:
510
+ return [seq]
511
+
512
+ def get_language(sources):
513
+ # not used in numpy/scipy packages, use build_ext.detect_language instead
514
+ """Determine language value (c,f77,f90) from sources """
515
+ language = None
516
+ for source in sources:
517
+ if isinstance(source, str):
518
+ if f90_ext_match(source):
519
+ language = 'f90'
520
+ break
521
+ elif fortran_ext_match(source):
522
+ language = 'f77'
523
+ return language
524
+
525
+ def has_f_sources(sources):
526
+ """Return True if sources contains Fortran files """
527
+ return any(fortran_ext_match(source) for source in sources)
528
+
529
+ def has_cxx_sources(sources):
530
+ """Return True if sources contains C++ files """
531
+ return any(cxx_ext_match(source) for source in sources)
532
+
533
+ def filter_sources(sources):
534
+ """Return four lists of filenames containing
535
+ C, C++, Fortran, and Fortran 90 module sources,
536
+ respectively.
537
+ """
538
+ c_sources = []
539
+ cxx_sources = []
540
+ f_sources = []
541
+ fmodule_sources = []
542
+ for source in sources:
543
+ if fortran_ext_match(source):
544
+ modules = _get_f90_modules(source)
545
+ if modules:
546
+ fmodule_sources.append(source)
547
+ else:
548
+ f_sources.append(source)
549
+ elif cxx_ext_match(source):
550
+ cxx_sources.append(source)
551
+ else:
552
+ c_sources.append(source)
553
+ return c_sources, cxx_sources, f_sources, fmodule_sources
554
+
555
+
556
+ def _get_headers(directory_list):
557
+ # get *.h files from list of directories
558
+ headers = []
559
+ for d in directory_list:
560
+ head = sorted_glob(os.path.join(d, "*.h")) #XXX: *.hpp files??
561
+ headers.extend(head)
562
+ return headers
563
+
564
+ def _get_directories(list_of_sources):
565
+ # get unique directories from list of sources.
566
+ direcs = []
567
+ for f in list_of_sources:
568
+ d = os.path.split(f)
569
+ if d[0] != '' and not d[0] in direcs:
570
+ direcs.append(d[0])
571
+ return direcs
572
+
573
+ def _commandline_dep_string(cc_args, extra_postargs, pp_opts):
574
+ """
575
+ Return commandline representation used to determine if a file needs
576
+ to be recompiled
577
+ """
578
+ cmdline = 'commandline: '
579
+ cmdline += ' '.join(cc_args)
580
+ cmdline += ' '.join(extra_postargs)
581
+ cmdline += ' '.join(pp_opts) + '\n'
582
+ return cmdline
583
+
584
+
585
+ def get_dependencies(sources):
586
+ #XXX scan sources for include statements
587
+ return _get_headers(_get_directories(sources))
588
+
589
+ def is_local_src_dir(directory):
590
+ """Return true if directory is local directory.
591
+ """
592
+ if not is_string(directory):
593
+ return False
594
+ abs_dir = os.path.abspath(directory)
595
+ c = os.path.commonprefix([os.getcwd(), abs_dir])
596
+ new_dir = abs_dir[len(c):].split(os.sep)
597
+ if new_dir and not new_dir[0]:
598
+ new_dir = new_dir[1:]
599
+ if new_dir and new_dir[0]=='build':
600
+ return False
601
+ new_dir = os.sep.join(new_dir)
602
+ return os.path.isdir(new_dir)
603
+
604
+ def general_source_files(top_path):
605
+ pruned_directories = {'CVS':1, '.svn':1, 'build':1}
606
+ prune_file_pat = re.compile(r'(?:[~#]|\.py[co]|\.o)$')
607
+ for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):
608
+ pruned = [ d for d in dirnames if d not in pruned_directories ]
609
+ dirnames[:] = pruned
610
+ for f in filenames:
611
+ if not prune_file_pat.search(f):
612
+ yield os.path.join(dirpath, f)
613
+
614
+ def general_source_directories_files(top_path):
615
+ """Return a directory name relative to top_path and
616
+ files contained.
617
+ """
618
+ pruned_directories = ['CVS', '.svn', 'build']
619
+ prune_file_pat = re.compile(r'(?:[~#]|\.py[co]|\.o)$')
620
+ for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):
621
+ pruned = [ d for d in dirnames if d not in pruned_directories ]
622
+ dirnames[:] = pruned
623
+ for d in dirnames:
624
+ dpath = os.path.join(dirpath, d)
625
+ rpath = rel_path(dpath, top_path)
626
+ files = []
627
+ for f in os.listdir(dpath):
628
+ fn = os.path.join(dpath, f)
629
+ if os.path.isfile(fn) and not prune_file_pat.search(fn):
630
+ files.append(fn)
631
+ yield rpath, files
632
+ dpath = top_path
633
+ rpath = rel_path(dpath, top_path)
634
+ filenames = [os.path.join(dpath, f) for f in os.listdir(dpath) \
635
+ if not prune_file_pat.search(f)]
636
+ files = [f for f in filenames if os.path.isfile(f)]
637
+ yield rpath, files
638
+
639
+
640
+ def get_ext_source_files(ext):
641
+ # Get sources and any include files in the same directory.
642
+ filenames = []
643
+ sources = [_m for _m in ext.sources if is_string(_m)]
644
+ filenames.extend(sources)
645
+ filenames.extend(get_dependencies(sources))
646
+ for d in ext.depends:
647
+ if is_local_src_dir(d):
648
+ filenames.extend(list(general_source_files(d)))
649
+ elif os.path.isfile(d):
650
+ filenames.append(d)
651
+ return filenames
652
+
653
+ def get_script_files(scripts):
654
+ scripts = [_m for _m in scripts if is_string(_m)]
655
+ return scripts
656
+
657
+ def get_lib_source_files(lib):
658
+ filenames = []
659
+ sources = lib[1].get('sources', [])
660
+ sources = [_m for _m in sources if is_string(_m)]
661
+ filenames.extend(sources)
662
+ filenames.extend(get_dependencies(sources))
663
+ depends = lib[1].get('depends', [])
664
+ for d in depends:
665
+ if is_local_src_dir(d):
666
+ filenames.extend(list(general_source_files(d)))
667
+ elif os.path.isfile(d):
668
+ filenames.append(d)
669
+ return filenames
670
+
671
+ def get_shared_lib_extension(is_python_ext=False):
672
+ """Return the correct file extension for shared libraries.
673
+
674
+ Parameters
675
+ ----------
676
+ is_python_ext : bool, optional
677
+ Whether the shared library is a Python extension. Default is False.
678
+
679
+ Returns
680
+ -------
681
+ so_ext : str
682
+ The shared library extension.
683
+
684
+ Notes
685
+ -----
686
+ For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X,
687
+ and '.pyd' on Windows. For Python >= 3.2 `so_ext` has a tag prepended on
688
+ POSIX systems according to PEP 3149.
689
+
690
+ """
691
+ confvars = distutils.sysconfig.get_config_vars()
692
+ so_ext = confvars.get('EXT_SUFFIX', '')
693
+
694
+ if not is_python_ext:
695
+ # hardcode known values, config vars (including SHLIB_SUFFIX) are
696
+ # unreliable (see #3182)
697
+ # darwin, windows and debug linux are wrong in 3.3.1 and older
698
+ if (sys.platform.startswith('linux') or
699
+ sys.platform.startswith('gnukfreebsd')):
700
+ so_ext = '.so'
701
+ elif sys.platform.startswith('darwin'):
702
+ so_ext = '.dylib'
703
+ elif sys.platform.startswith('win'):
704
+ so_ext = '.dll'
705
+ else:
706
+ # fall back to config vars for unknown platforms
707
+ # fix long extension for Python >=3.2, see PEP 3149.
708
+ if 'SOABI' in confvars:
709
+ # Does nothing unless SOABI config var exists
710
+ so_ext = so_ext.replace('.' + confvars.get('SOABI'), '', 1)
711
+
712
+ return so_ext
713
+
714
+ def get_data_files(data):
715
+ if is_string(data):
716
+ return [data]
717
+ sources = data[1]
718
+ filenames = []
719
+ for s in sources:
720
+ if hasattr(s, '__call__'):
721
+ continue
722
+ if is_local_src_dir(s):
723
+ filenames.extend(list(general_source_files(s)))
724
+ elif is_string(s):
725
+ if os.path.isfile(s):
726
+ filenames.append(s)
727
+ else:
728
+ print('Not existing data file:', s)
729
+ else:
730
+ raise TypeError(repr(s))
731
+ return filenames
732
+
733
+ def dot_join(*args):
734
+ return '.'.join([a for a in args if a])
735
+
736
+ def get_frame(level=0):
737
+ """Return frame object from call stack with given level.
738
+ """
739
+ try:
740
+ return sys._getframe(level+1)
741
+ except AttributeError:
742
+ frame = sys.exc_info()[2].tb_frame
743
+ for _ in range(level+1):
744
+ frame = frame.f_back
745
+ return frame
746
+
747
+
748
+ ######################
749
+
750
+ class Configuration:
751
+
752
+ _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',
753
+ 'libraries', 'headers', 'scripts', 'py_modules',
754
+ 'installed_libraries', 'define_macros']
755
+ _dict_keys = ['package_dir', 'installed_pkg_config']
756
+ _extra_keys = ['name', 'version']
757
+
758
+ numpy_include_dirs = []
759
+
760
+ def __init__(self,
761
+ package_name=None,
762
+ parent_name=None,
763
+ top_path=None,
764
+ package_path=None,
765
+ caller_level=1,
766
+ setup_name='setup.py',
767
+ **attrs):
768
+ """Construct configuration instance of a package.
769
+
770
+ package_name -- name of the package
771
+ Ex.: 'distutils'
772
+ parent_name -- name of the parent package
773
+ Ex.: 'numpy'
774
+ top_path -- directory of the toplevel package
775
+ Ex.: the directory where the numpy package source sits
776
+ package_path -- directory of package. Will be computed by magic from the
777
+ directory of the caller module if not specified
778
+ Ex.: the directory where numpy.distutils is
779
+ caller_level -- frame level to caller namespace, internal parameter.
780
+ """
781
+ self.name = dot_join(parent_name, package_name)
782
+ self.version = None
783
+
784
+ caller_frame = get_frame(caller_level)
785
+ self.local_path = get_path_from_frame(caller_frame, top_path)
786
+ # local_path -- directory of a file (usually setup.py) that
787
+ # defines a configuration() function.
788
+ # local_path -- directory of a file (usually setup.py) that
789
+ # defines a configuration() function.
790
+ if top_path is None:
791
+ top_path = self.local_path
792
+ self.local_path = ''
793
+ if package_path is None:
794
+ package_path = self.local_path
795
+ elif os.path.isdir(njoin(self.local_path, package_path)):
796
+ package_path = njoin(self.local_path, package_path)
797
+ if not os.path.isdir(package_path or '.'):
798
+ raise ValueError("%r is not a directory" % (package_path,))
799
+ self.top_path = top_path
800
+ self.package_path = package_path
801
+ # this is the relative path in the installed package
802
+ self.path_in_package = os.path.join(*self.name.split('.'))
803
+
804
+ self.list_keys = self._list_keys[:]
805
+ self.dict_keys = self._dict_keys[:]
806
+
807
+ for n in self.list_keys:
808
+ v = copy.copy(attrs.get(n, []))
809
+ setattr(self, n, as_list(v))
810
+
811
+ for n in self.dict_keys:
812
+ v = copy.copy(attrs.get(n, {}))
813
+ setattr(self, n, v)
814
+
815
+ known_keys = self.list_keys + self.dict_keys
816
+ self.extra_keys = self._extra_keys[:]
817
+ for n in attrs.keys():
818
+ if n in known_keys:
819
+ continue
820
+ a = attrs[n]
821
+ setattr(self, n, a)
822
+ if isinstance(a, list):
823
+ self.list_keys.append(n)
824
+ elif isinstance(a, dict):
825
+ self.dict_keys.append(n)
826
+ else:
827
+ self.extra_keys.append(n)
828
+
829
+ if os.path.exists(njoin(package_path, '__init__.py')):
830
+ self.packages.append(self.name)
831
+ self.package_dir[self.name] = package_path
832
+
833
+ self.options = dict(
834
+ ignore_setup_xxx_py = False,
835
+ assume_default_configuration = False,
836
+ delegate_options_to_subpackages = False,
837
+ quiet = False,
838
+ )
839
+
840
+ caller_instance = None
841
+ for i in range(1, 3):
842
+ try:
843
+ f = get_frame(i)
844
+ except ValueError:
845
+ break
846
+ try:
847
+ caller_instance = eval('self', f.f_globals, f.f_locals)
848
+ break
849
+ except NameError:
850
+ pass
851
+ if isinstance(caller_instance, self.__class__):
852
+ if caller_instance.options['delegate_options_to_subpackages']:
853
+ self.set_options(**caller_instance.options)
854
+
855
+ self.setup_name = setup_name
856
+
857
+ def todict(self):
858
+ """
859
+ Return a dictionary compatible with the keyword arguments of distutils
860
+ setup function.
861
+
862
+ Examples
863
+ --------
864
+ >>> setup(**config.todict()) #doctest: +SKIP
865
+ """
866
+
867
+ self._optimize_data_files()
868
+ d = {}
869
+ known_keys = self.list_keys + self.dict_keys + self.extra_keys
870
+ for n in known_keys:
871
+ a = getattr(self, n)
872
+ if a:
873
+ d[n] = a
874
+ return d
875
+
876
+ def info(self, message):
877
+ if not self.options['quiet']:
878
+ print(message)
879
+
880
+ def warn(self, message):
881
+ sys.stderr.write('Warning: %s\n' % (message,))
882
+
883
+ def set_options(self, **options):
884
+ """
885
+ Configure Configuration instance.
886
+
887
+ The following options are available:
888
+ - ignore_setup_xxx_py
889
+ - assume_default_configuration
890
+ - delegate_options_to_subpackages
891
+ - quiet
892
+
893
+ """
894
+ for key, value in options.items():
895
+ if key in self.options:
896
+ self.options[key] = value
897
+ else:
898
+ raise ValueError('Unknown option: '+key)
899
+
900
+ def get_distribution(self):
901
+ """Return the distutils distribution object for self."""
902
+ from numpy.distutils.core import get_distribution
903
+ return get_distribution()
904
+
905
+ def _wildcard_get_subpackage(self, subpackage_name,
906
+ parent_name,
907
+ caller_level = 1):
908
+ l = subpackage_name.split('.')
909
+ subpackage_path = njoin([self.local_path]+l)
910
+ dirs = [_m for _m in sorted_glob(subpackage_path) if os.path.isdir(_m)]
911
+ config_list = []
912
+ for d in dirs:
913
+ if not os.path.isfile(njoin(d, '__init__.py')):
914
+ continue
915
+ if 'build' in d.split(os.sep):
916
+ continue
917
+ n = '.'.join(d.split(os.sep)[-len(l):])
918
+ c = self.get_subpackage(n,
919
+ parent_name = parent_name,
920
+ caller_level = caller_level+1)
921
+ config_list.extend(c)
922
+ return config_list
923
+
924
+ def _get_configuration_from_setup_py(self, setup_py,
925
+ subpackage_name,
926
+ subpackage_path,
927
+ parent_name,
928
+ caller_level = 1):
929
+ # In case setup_py imports local modules:
930
+ sys.path.insert(0, os.path.dirname(setup_py))
931
+ try:
932
+ setup_name = os.path.splitext(os.path.basename(setup_py))[0]
933
+ n = dot_join(self.name, subpackage_name, setup_name)
934
+ setup_module = exec_mod_from_location(
935
+ '_'.join(n.split('.')), setup_py)
936
+ if not hasattr(setup_module, 'configuration'):
937
+ if not self.options['assume_default_configuration']:
938
+ self.warn('Assuming default configuration '\
939
+ '(%s does not define configuration())'\
940
+ % (setup_module))
941
+ config = Configuration(subpackage_name, parent_name,
942
+ self.top_path, subpackage_path,
943
+ caller_level = caller_level + 1)
944
+ else:
945
+ pn = dot_join(*([parent_name] + subpackage_name.split('.')[:-1]))
946
+ args = (pn,)
947
+ if setup_module.configuration.__code__.co_argcount > 1:
948
+ args = args + (self.top_path,)
949
+ config = setup_module.configuration(*args)
950
+ if config.name!=dot_join(parent_name, subpackage_name):
951
+ self.warn('Subpackage %r configuration returned as %r' % \
952
+ (dot_join(parent_name, subpackage_name), config.name))
953
+ finally:
954
+ del sys.path[0]
955
+ return config
956
+
957
+ def get_subpackage(self,subpackage_name,
958
+ subpackage_path=None,
959
+ parent_name=None,
960
+ caller_level = 1):
961
+ """Return list of subpackage configurations.
962
+
963
+ Parameters
964
+ ----------
965
+ subpackage_name : str or None
966
+ Name of the subpackage to get the configuration. '*' in
967
+ subpackage_name is handled as a wildcard.
968
+ subpackage_path : str
969
+ If None, then the path is assumed to be the local path plus the
970
+ subpackage_name. If a setup.py file is not found in the
971
+ subpackage_path, then a default configuration is used.
972
+ parent_name : str
973
+ Parent name.
974
+ """
975
+ if subpackage_name is None:
976
+ if subpackage_path is None:
977
+ raise ValueError(
978
+ "either subpackage_name or subpackage_path must be specified")
979
+ subpackage_name = os.path.basename(subpackage_path)
980
+
981
+ # handle wildcards
982
+ l = subpackage_name.split('.')
983
+ if subpackage_path is None and '*' in subpackage_name:
984
+ return self._wildcard_get_subpackage(subpackage_name,
985
+ parent_name,
986
+ caller_level = caller_level+1)
987
+ assert '*' not in subpackage_name, repr((subpackage_name, subpackage_path, parent_name))
988
+ if subpackage_path is None:
989
+ subpackage_path = njoin([self.local_path] + l)
990
+ else:
991
+ subpackage_path = njoin([subpackage_path] + l[:-1])
992
+ subpackage_path = self.paths([subpackage_path])[0]
993
+ setup_py = njoin(subpackage_path, self.setup_name)
994
+ if not self.options['ignore_setup_xxx_py']:
995
+ if not os.path.isfile(setup_py):
996
+ setup_py = njoin(subpackage_path,
997
+ 'setup_%s.py' % (subpackage_name))
998
+ if not os.path.isfile(setup_py):
999
+ if not self.options['assume_default_configuration']:
1000
+ self.warn('Assuming default configuration '\
1001
+ '(%s/{setup_%s,setup}.py was not found)' \
1002
+ % (os.path.dirname(setup_py), subpackage_name))
1003
+ config = Configuration(subpackage_name, parent_name,
1004
+ self.top_path, subpackage_path,
1005
+ caller_level = caller_level+1)
1006
+ else:
1007
+ config = self._get_configuration_from_setup_py(
1008
+ setup_py,
1009
+ subpackage_name,
1010
+ subpackage_path,
1011
+ parent_name,
1012
+ caller_level = caller_level + 1)
1013
+ if config:
1014
+ return [config]
1015
+ else:
1016
+ return []
1017
+
1018
+ def add_subpackage(self,subpackage_name,
1019
+ subpackage_path=None,
1020
+ standalone = False):
1021
+ """Add a sub-package to the current Configuration instance.
1022
+
1023
+ This is useful in a setup.py script for adding sub-packages to a
1024
+ package.
1025
+
1026
+ Parameters
1027
+ ----------
1028
+ subpackage_name : str
1029
+ name of the subpackage
1030
+ subpackage_path : str
1031
+ if given, the subpackage path such as the subpackage is in
1032
+ subpackage_path / subpackage_name. If None,the subpackage is
1033
+ assumed to be located in the local path / subpackage_name.
1034
+ standalone : bool
1035
+ """
1036
+
1037
+ if standalone:
1038
+ parent_name = None
1039
+ else:
1040
+ parent_name = self.name
1041
+ config_list = self.get_subpackage(subpackage_name, subpackage_path,
1042
+ parent_name = parent_name,
1043
+ caller_level = 2)
1044
+ if not config_list:
1045
+ self.warn('No configuration returned, assuming unavailable.')
1046
+ for config in config_list:
1047
+ d = config
1048
+ if isinstance(config, Configuration):
1049
+ d = config.todict()
1050
+ assert isinstance(d, dict), repr(type(d))
1051
+
1052
+ self.info('Appending %s configuration to %s' \
1053
+ % (d.get('name'), self.name))
1054
+ self.dict_append(**d)
1055
+
1056
+ dist = self.get_distribution()
1057
+ if dist is not None:
1058
+ self.warn('distutils distribution has been initialized,'\
1059
+ ' it may be too late to add a subpackage '+ subpackage_name)
1060
+
1061
+ def add_data_dir(self, data_path):
1062
+ """Recursively add files under data_path to data_files list.
1063
+
1064
+ Recursively add files under data_path to the list of data_files to be
1065
+ installed (and distributed). The data_path can be either a relative
1066
+ path-name, or an absolute path-name, or a 2-tuple where the first
1067
+ argument shows where in the install directory the data directory
1068
+ should be installed to.
1069
+
1070
+ Parameters
1071
+ ----------
1072
+ data_path : seq or str
1073
+ Argument can be either
1074
+
1075
+ * 2-sequence (<datadir suffix>, <path to data directory>)
1076
+ * path to data directory where python datadir suffix defaults
1077
+ to package dir.
1078
+
1079
+ Notes
1080
+ -----
1081
+ Rules for installation paths::
1082
+
1083
+ foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar
1084
+ (gun, foo/bar) -> parent/gun
1085
+ foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b
1086
+ (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun
1087
+ (gun/*, foo/*) -> parent/gun/a, parent/gun/b
1088
+ /foo/bar -> (bar, /foo/bar) -> parent/bar
1089
+ (gun, /foo/bar) -> parent/gun
1090
+ (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar
1091
+
1092
+ Examples
1093
+ --------
1094
+ For example suppose the source directory contains fun/foo.dat and
1095
+ fun/bar/car.dat:
1096
+
1097
+ >>> self.add_data_dir('fun') #doctest: +SKIP
1098
+ >>> self.add_data_dir(('sun', 'fun')) #doctest: +SKIP
1099
+ >>> self.add_data_dir(('gun', '/full/path/to/fun'))#doctest: +SKIP
1100
+
1101
+ Will install data-files to the locations::
1102
+
1103
+ <package install directory>/
1104
+ fun/
1105
+ foo.dat
1106
+ bar/
1107
+ car.dat
1108
+ sun/
1109
+ foo.dat
1110
+ bar/
1111
+ car.dat
1112
+ gun/
1113
+ foo.dat
1114
+ car.dat
1115
+
1116
+ """
1117
+ if is_sequence(data_path):
1118
+ d, data_path = data_path
1119
+ else:
1120
+ d = None
1121
+ if is_sequence(data_path):
1122
+ [self.add_data_dir((d, p)) for p in data_path]
1123
+ return
1124
+ if not is_string(data_path):
1125
+ raise TypeError("not a string: %r" % (data_path,))
1126
+ if d is None:
1127
+ if os.path.isabs(data_path):
1128
+ return self.add_data_dir((os.path.basename(data_path), data_path))
1129
+ return self.add_data_dir((data_path, data_path))
1130
+ paths = self.paths(data_path, include_non_existing=False)
1131
+ if is_glob_pattern(data_path):
1132
+ if is_glob_pattern(d):
1133
+ pattern_list = allpath(d).split(os.sep)
1134
+ pattern_list.reverse()
1135
+ # /a/*//b/ -> /a/*/b
1136
+ rl = list(range(len(pattern_list)-1)); rl.reverse()
1137
+ for i in rl:
1138
+ if not pattern_list[i]:
1139
+ del pattern_list[i]
1140
+ #
1141
+ for path in paths:
1142
+ if not os.path.isdir(path):
1143
+ print('Not a directory, skipping', path)
1144
+ continue
1145
+ rpath = rel_path(path, self.local_path)
1146
+ path_list = rpath.split(os.sep)
1147
+ path_list.reverse()
1148
+ target_list = []
1149
+ i = 0
1150
+ for s in pattern_list:
1151
+ if is_glob_pattern(s):
1152
+ if i>=len(path_list):
1153
+ raise ValueError('cannot fill pattern %r with %r' \
1154
+ % (d, path))
1155
+ target_list.append(path_list[i])
1156
+ else:
1157
+ assert s==path_list[i], repr((s, path_list[i], data_path, d, path, rpath))
1158
+ target_list.append(s)
1159
+ i += 1
1160
+ if path_list[i:]:
1161
+ self.warn('mismatch of pattern_list=%s and path_list=%s'\
1162
+ % (pattern_list, path_list))
1163
+ target_list.reverse()
1164
+ self.add_data_dir((os.sep.join(target_list), path))
1165
+ else:
1166
+ for path in paths:
1167
+ self.add_data_dir((d, path))
1168
+ return
1169
+ assert not is_glob_pattern(d), repr(d)
1170
+
1171
+ dist = self.get_distribution()
1172
+ if dist is not None and dist.data_files is not None:
1173
+ data_files = dist.data_files
1174
+ else:
1175
+ data_files = self.data_files
1176
+
1177
+ for path in paths:
1178
+ for d1, f in list(general_source_directories_files(path)):
1179
+ target_path = os.path.join(self.path_in_package, d, d1)
1180
+ data_files.append((target_path, f))
1181
+
1182
+ def _optimize_data_files(self):
1183
+ data_dict = {}
1184
+ for p, files in self.data_files:
1185
+ if p not in data_dict:
1186
+ data_dict[p] = set()
1187
+ for f in files:
1188
+ data_dict[p].add(f)
1189
+ self.data_files[:] = [(p, list(files)) for p, files in data_dict.items()]
1190
+
1191
+ def add_data_files(self,*files):
1192
+ """Add data files to configuration data_files.
1193
+
1194
+ Parameters
1195
+ ----------
1196
+ files : sequence
1197
+ Argument(s) can be either
1198
+
1199
+ * 2-sequence (<datadir prefix>,<path to data file(s)>)
1200
+ * paths to data files where python datadir prefix defaults
1201
+ to package dir.
1202
+
1203
+ Notes
1204
+ -----
1205
+ The form of each element of the files sequence is very flexible
1206
+ allowing many combinations of where to get the files from the package
1207
+ and where they should ultimately be installed on the system. The most
1208
+ basic usage is for an element of the files argument sequence to be a
1209
+ simple filename. This will cause that file from the local path to be
1210
+ installed to the installation path of the self.name package (package
1211
+ path). The file argument can also be a relative path in which case the
1212
+ entire relative path will be installed into the package directory.
1213
+ Finally, the file can be an absolute path name in which case the file
1214
+ will be found at the absolute path name but installed to the package
1215
+ path.
1216
+
1217
+ This basic behavior can be augmented by passing a 2-tuple in as the
1218
+ file argument. The first element of the tuple should specify the
1219
+ relative path (under the package install directory) where the
1220
+ remaining sequence of files should be installed to (it has nothing to
1221
+ do with the file-names in the source distribution). The second element
1222
+ of the tuple is the sequence of files that should be installed. The
1223
+ files in this sequence can be filenames, relative paths, or absolute
1224
+ paths. For absolute paths the file will be installed in the top-level
1225
+ package installation directory (regardless of the first argument).
1226
+ Filenames and relative path names will be installed in the package
1227
+ install directory under the path name given as the first element of
1228
+ the tuple.
1229
+
1230
+ Rules for installation paths:
1231
+
1232
+ #. file.txt -> (., file.txt)-> parent/file.txt
1233
+ #. foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt
1234
+ #. /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt
1235
+ #. ``*``.txt -> parent/a.txt, parent/b.txt
1236
+ #. foo/``*``.txt`` -> parent/foo/a.txt, parent/foo/b.txt
1237
+ #. ``*/*.txt`` -> (``*``, ``*``/``*``.txt) -> parent/c/a.txt, parent/d/b.txt
1238
+ #. (sun, file.txt) -> parent/sun/file.txt
1239
+ #. (sun, bar/file.txt) -> parent/sun/file.txt
1240
+ #. (sun, /foo/bar/file.txt) -> parent/sun/file.txt
1241
+ #. (sun, ``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
1242
+ #. (sun, bar/``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
1243
+ #. (sun/``*``, ``*``/``*``.txt) -> parent/sun/c/a.txt, parent/d/b.txt
1244
+
1245
+ An additional feature is that the path to a data-file can actually be
1246
+ a function that takes no arguments and returns the actual path(s) to
1247
+ the data-files. This is useful when the data files are generated while
1248
+ building the package.
1249
+
1250
+ Examples
1251
+ --------
1252
+ Add files to the list of data_files to be included with the package.
1253
+
1254
+ >>> self.add_data_files('foo.dat',
1255
+ ... ('fun', ['gun.dat', 'nun/pun.dat', '/tmp/sun.dat']),
1256
+ ... 'bar/cat.dat',
1257
+ ... '/full/path/to/can.dat') #doctest: +SKIP
1258
+
1259
+ will install these data files to::
1260
+
1261
+ <package install directory>/
1262
+ foo.dat
1263
+ fun/
1264
+ gun.dat
1265
+ nun/
1266
+ pun.dat
1267
+ sun.dat
1268
+ bar/
1269
+ car.dat
1270
+ can.dat
1271
+
1272
+ where <package install directory> is the package (or sub-package)
1273
+ directory such as '/usr/lib/python2.4/site-packages/mypackage' ('C:
1274
+ \\Python2.4 \\Lib \\site-packages \\mypackage') or
1275
+ '/usr/lib/python2.4/site- packages/mypackage/mysubpackage' ('C:
1276
+ \\Python2.4 \\Lib \\site-packages \\mypackage \\mysubpackage').
1277
+ """
1278
+
1279
+ if len(files)>1:
1280
+ for f in files:
1281
+ self.add_data_files(f)
1282
+ return
1283
+ assert len(files)==1
1284
+ if is_sequence(files[0]):
1285
+ d, files = files[0]
1286
+ else:
1287
+ d = None
1288
+ if is_string(files):
1289
+ filepat = files
1290
+ elif is_sequence(files):
1291
+ if len(files)==1:
1292
+ filepat = files[0]
1293
+ else:
1294
+ for f in files:
1295
+ self.add_data_files((d, f))
1296
+ return
1297
+ else:
1298
+ raise TypeError(repr(type(files)))
1299
+
1300
+ if d is None:
1301
+ if hasattr(filepat, '__call__'):
1302
+ d = ''
1303
+ elif os.path.isabs(filepat):
1304
+ d = ''
1305
+ else:
1306
+ d = os.path.dirname(filepat)
1307
+ self.add_data_files((d, files))
1308
+ return
1309
+
1310
+ paths = self.paths(filepat, include_non_existing=False)
1311
+ if is_glob_pattern(filepat):
1312
+ if is_glob_pattern(d):
1313
+ pattern_list = d.split(os.sep)
1314
+ pattern_list.reverse()
1315
+ for path in paths:
1316
+ path_list = path.split(os.sep)
1317
+ path_list.reverse()
1318
+ path_list.pop() # filename
1319
+ target_list = []
1320
+ i = 0
1321
+ for s in pattern_list:
1322
+ if is_glob_pattern(s):
1323
+ target_list.append(path_list[i])
1324
+ i += 1
1325
+ else:
1326
+ target_list.append(s)
1327
+ target_list.reverse()
1328
+ self.add_data_files((os.sep.join(target_list), path))
1329
+ else:
1330
+ self.add_data_files((d, paths))
1331
+ return
1332
+ assert not is_glob_pattern(d), repr((d, filepat))
1333
+
1334
+ dist = self.get_distribution()
1335
+ if dist is not None and dist.data_files is not None:
1336
+ data_files = dist.data_files
1337
+ else:
1338
+ data_files = self.data_files
1339
+
1340
+ data_files.append((os.path.join(self.path_in_package, d), paths))
1341
+
1342
+ ### XXX Implement add_py_modules
1343
+
1344
+ def add_define_macros(self, macros):
1345
+ """Add define macros to configuration
1346
+
1347
+ Add the given sequence of macro name and value duples to the beginning
1348
+ of the define_macros list This list will be visible to all extension
1349
+ modules of the current package.
1350
+ """
1351
+ dist = self.get_distribution()
1352
+ if dist is not None:
1353
+ if not hasattr(dist, 'define_macros'):
1354
+ dist.define_macros = []
1355
+ dist.define_macros.extend(macros)
1356
+ else:
1357
+ self.define_macros.extend(macros)
1358
+
1359
+
1360
+ def add_include_dirs(self,*paths):
1361
+ """Add paths to configuration include directories.
1362
+
1363
+ Add the given sequence of paths to the beginning of the include_dirs
1364
+ list. This list will be visible to all extension modules of the
1365
+ current package.
1366
+ """
1367
+ include_dirs = self.paths(paths)
1368
+ dist = self.get_distribution()
1369
+ if dist is not None:
1370
+ if dist.include_dirs is None:
1371
+ dist.include_dirs = []
1372
+ dist.include_dirs.extend(include_dirs)
1373
+ else:
1374
+ self.include_dirs.extend(include_dirs)
1375
+
1376
+ def add_headers(self,*files):
1377
+ """Add installable headers to configuration.
1378
+
1379
+ Add the given sequence of files to the beginning of the headers list.
1380
+ By default, headers will be installed under <python-
1381
+ include>/<self.name.replace('.','/')>/ directory. If an item of files
1382
+ is a tuple, then its first argument specifies the actual installation
1383
+ location relative to the <python-include> path.
1384
+
1385
+ Parameters
1386
+ ----------
1387
+ files : str or seq
1388
+ Argument(s) can be either:
1389
+
1390
+ * 2-sequence (<includedir suffix>,<path to header file(s)>)
1391
+ * path(s) to header file(s) where python includedir suffix will
1392
+ default to package name.
1393
+ """
1394
+ headers = []
1395
+ for path in files:
1396
+ if is_string(path):
1397
+ [headers.append((self.name, p)) for p in self.paths(path)]
1398
+ else:
1399
+ if not isinstance(path, (tuple, list)) or len(path) != 2:
1400
+ raise TypeError(repr(path))
1401
+ [headers.append((path[0], p)) for p in self.paths(path[1])]
1402
+ dist = self.get_distribution()
1403
+ if dist is not None:
1404
+ if dist.headers is None:
1405
+ dist.headers = []
1406
+ dist.headers.extend(headers)
1407
+ else:
1408
+ self.headers.extend(headers)
1409
+
1410
+ def paths(self,*paths,**kws):
1411
+ """Apply glob to paths and prepend local_path if needed.
1412
+
1413
+ Applies glob.glob(...) to each path in the sequence (if needed) and
1414
+ prepends the local_path if needed. Because this is called on all
1415
+ source lists, this allows wildcard characters to be specified in lists
1416
+ of sources for extension modules and libraries and scripts and allows
1417
+ path-names be relative to the source directory.
1418
+
1419
+ """
1420
+ include_non_existing = kws.get('include_non_existing', True)
1421
+ return gpaths(paths,
1422
+ local_path = self.local_path,
1423
+ include_non_existing=include_non_existing)
1424
+
1425
+ def _fix_paths_dict(self, kw):
1426
+ for k in kw.keys():
1427
+ v = kw[k]
1428
+ if k in ['sources', 'depends', 'include_dirs', 'library_dirs',
1429
+ 'module_dirs', 'extra_objects']:
1430
+ new_v = self.paths(v)
1431
+ kw[k] = new_v
1432
+
1433
+ def add_extension(self,name,sources,**kw):
1434
+ """Add extension to configuration.
1435
+
1436
+ Create and add an Extension instance to the ext_modules list. This
1437
+ method also takes the following optional keyword arguments that are
1438
+ passed on to the Extension constructor.
1439
+
1440
+ Parameters
1441
+ ----------
1442
+ name : str
1443
+ name of the extension
1444
+ sources : seq
1445
+ list of the sources. The list of sources may contain functions
1446
+ (called source generators) which must take an extension instance
1447
+ and a build directory as inputs and return a source file or list of
1448
+ source files or None. If None is returned then no sources are
1449
+ generated. If the Extension instance has no sources after
1450
+ processing all source generators, then no extension module is
1451
+ built.
1452
+ include_dirs :
1453
+ define_macros :
1454
+ undef_macros :
1455
+ library_dirs :
1456
+ libraries :
1457
+ runtime_library_dirs :
1458
+ extra_objects :
1459
+ extra_compile_args :
1460
+ extra_link_args :
1461
+ extra_f77_compile_args :
1462
+ extra_f90_compile_args :
1463
+ export_symbols :
1464
+ swig_opts :
1465
+ depends :
1466
+ The depends list contains paths to files or directories that the
1467
+ sources of the extension module depend on. If any path in the
1468
+ depends list is newer than the extension module, then the module
1469
+ will be rebuilt.
1470
+ language :
1471
+ f2py_options :
1472
+ module_dirs :
1473
+ extra_info : dict or list
1474
+ dict or list of dict of keywords to be appended to keywords.
1475
+
1476
+ Notes
1477
+ -----
1478
+ The self.paths(...) method is applied to all lists that may contain
1479
+ paths.
1480
+ """
1481
+ ext_args = copy.copy(kw)
1482
+ ext_args['name'] = dot_join(self.name, name)
1483
+ ext_args['sources'] = sources
1484
+
1485
+ if 'extra_info' in ext_args:
1486
+ extra_info = ext_args['extra_info']
1487
+ del ext_args['extra_info']
1488
+ if isinstance(extra_info, dict):
1489
+ extra_info = [extra_info]
1490
+ for info in extra_info:
1491
+ assert isinstance(info, dict), repr(info)
1492
+ dict_append(ext_args,**info)
1493
+
1494
+ self._fix_paths_dict(ext_args)
1495
+
1496
+ # Resolve out-of-tree dependencies
1497
+ libraries = ext_args.get('libraries', [])
1498
+ libnames = []
1499
+ ext_args['libraries'] = []
1500
+ for libname in libraries:
1501
+ if isinstance(libname, tuple):
1502
+ self._fix_paths_dict(libname[1])
1503
+
1504
+ # Handle library names of the form libname@relative/path/to/library
1505
+ if '@' in libname:
1506
+ lname, lpath = libname.split('@', 1)
1507
+ lpath = os.path.abspath(njoin(self.local_path, lpath))
1508
+ if os.path.isdir(lpath):
1509
+ c = self.get_subpackage(None, lpath,
1510
+ caller_level = 2)
1511
+ if isinstance(c, Configuration):
1512
+ c = c.todict()
1513
+ for l in [l[0] for l in c.get('libraries', [])]:
1514
+ llname = l.split('__OF__', 1)[0]
1515
+ if llname == lname:
1516
+ c.pop('name', None)
1517
+ dict_append(ext_args,**c)
1518
+ break
1519
+ continue
1520
+ libnames.append(libname)
1521
+
1522
+ ext_args['libraries'] = libnames + ext_args['libraries']
1523
+ ext_args['define_macros'] = \
1524
+ self.define_macros + ext_args.get('define_macros', [])
1525
+
1526
+ from numpy.distutils.core import Extension
1527
+ ext = Extension(**ext_args)
1528
+ self.ext_modules.append(ext)
1529
+
1530
+ dist = self.get_distribution()
1531
+ if dist is not None:
1532
+ self.warn('distutils distribution has been initialized,'\
1533
+ ' it may be too late to add an extension '+name)
1534
+ return ext
1535
+
1536
+ def add_library(self,name,sources,**build_info):
1537
+ """
1538
+ Add library to configuration.
1539
+
1540
+ Parameters
1541
+ ----------
1542
+ name : str
1543
+ Name of the extension.
1544
+ sources : sequence
1545
+ List of the sources. The list of sources may contain functions
1546
+ (called source generators) which must take an extension instance
1547
+ and a build directory as inputs and return a source file or list of
1548
+ source files or None. If None is returned then no sources are
1549
+ generated. If the Extension instance has no sources after
1550
+ processing all source generators, then no extension module is
1551
+ built.
1552
+ build_info : dict, optional
1553
+ The following keys are allowed:
1554
+
1555
+ * depends
1556
+ * macros
1557
+ * include_dirs
1558
+ * extra_compiler_args
1559
+ * extra_f77_compile_args
1560
+ * extra_f90_compile_args
1561
+ * f2py_options
1562
+ * language
1563
+
1564
+ """
1565
+ self._add_library(name, sources, None, build_info)
1566
+
1567
+ dist = self.get_distribution()
1568
+ if dist is not None:
1569
+ self.warn('distutils distribution has been initialized,'\
1570
+ ' it may be too late to add a library '+ name)
1571
+
1572
+ def _add_library(self, name, sources, install_dir, build_info):
1573
+ """Common implementation for add_library and add_installed_library. Do
1574
+ not use directly"""
1575
+ build_info = copy.copy(build_info)
1576
+ build_info['sources'] = sources
1577
+
1578
+ # Sometimes, depends is not set up to an empty list by default, and if
1579
+ # depends is not given to add_library, distutils barfs (#1134)
1580
+ if not 'depends' in build_info:
1581
+ build_info['depends'] = []
1582
+
1583
+ self._fix_paths_dict(build_info)
1584
+
1585
+ # Add to libraries list so that it is build with build_clib
1586
+ self.libraries.append((name, build_info))
1587
+
1588
+ def add_installed_library(self, name, sources, install_dir, build_info=None):
1589
+ """
1590
+ Similar to add_library, but the specified library is installed.
1591
+
1592
+ Most C libraries used with ``distutils`` are only used to build python
1593
+ extensions, but libraries built through this method will be installed
1594
+ so that they can be reused by third-party packages.
1595
+
1596
+ Parameters
1597
+ ----------
1598
+ name : str
1599
+ Name of the installed library.
1600
+ sources : sequence
1601
+ List of the library's source files. See `add_library` for details.
1602
+ install_dir : str
1603
+ Path to install the library, relative to the current sub-package.
1604
+ build_info : dict, optional
1605
+ The following keys are allowed:
1606
+
1607
+ * depends
1608
+ * macros
1609
+ * include_dirs
1610
+ * extra_compiler_args
1611
+ * extra_f77_compile_args
1612
+ * extra_f90_compile_args
1613
+ * f2py_options
1614
+ * language
1615
+
1616
+ Returns
1617
+ -------
1618
+ None
1619
+
1620
+ See Also
1621
+ --------
1622
+ add_library, add_npy_pkg_config, get_info
1623
+
1624
+ Notes
1625
+ -----
1626
+ The best way to encode the options required to link against the specified
1627
+ C libraries is to use a "libname.ini" file, and use `get_info` to
1628
+ retrieve the required options (see `add_npy_pkg_config` for more
1629
+ information).
1630
+
1631
+ """
1632
+ if not build_info:
1633
+ build_info = {}
1634
+
1635
+ install_dir = os.path.join(self.package_path, install_dir)
1636
+ self._add_library(name, sources, install_dir, build_info)
1637
+ self.installed_libraries.append(InstallableLib(name, build_info, install_dir))
1638
+
1639
+ def add_npy_pkg_config(self, template, install_dir, subst_dict=None):
1640
+ """
1641
+ Generate and install a npy-pkg config file from a template.
1642
+
1643
+ The config file generated from `template` is installed in the
1644
+ given install directory, using `subst_dict` for variable substitution.
1645
+
1646
+ Parameters
1647
+ ----------
1648
+ template : str
1649
+ The path of the template, relatively to the current package path.
1650
+ install_dir : str
1651
+ Where to install the npy-pkg config file, relatively to the current
1652
+ package path.
1653
+ subst_dict : dict, optional
1654
+ If given, any string of the form ``@key@`` will be replaced by
1655
+ ``subst_dict[key]`` in the template file when installed. The install
1656
+ prefix is always available through the variable ``@prefix@``, since the
1657
+ install prefix is not easy to get reliably from setup.py.
1658
+
1659
+ See also
1660
+ --------
1661
+ add_installed_library, get_info
1662
+
1663
+ Notes
1664
+ -----
1665
+ This works for both standard installs and in-place builds, i.e. the
1666
+ ``@prefix@`` refer to the source directory for in-place builds.
1667
+
1668
+ Examples
1669
+ --------
1670
+ ::
1671
+
1672
+ config.add_npy_pkg_config('foo.ini.in', 'lib', {'foo': bar})
1673
+
1674
+ Assuming the foo.ini.in file has the following content::
1675
+
1676
+ [meta]
1677
+ Name=@foo@
1678
+ Version=1.0
1679
+ Description=dummy description
1680
+
1681
+ [default]
1682
+ Cflags=-I@prefix@/include
1683
+ Libs=
1684
+
1685
+ The generated file will have the following content::
1686
+
1687
+ [meta]
1688
+ Name=bar
1689
+ Version=1.0
1690
+ Description=dummy description
1691
+
1692
+ [default]
1693
+ Cflags=-Iprefix_dir/include
1694
+ Libs=
1695
+
1696
+ and will be installed as foo.ini in the 'lib' subpath.
1697
+
1698
+ When cross-compiling with numpy distutils, it might be necessary to
1699
+ use modified npy-pkg-config files. Using the default/generated files
1700
+ will link with the host libraries (i.e. libnpymath.a). For
1701
+ cross-compilation you of-course need to link with target libraries,
1702
+ while using the host Python installation.
1703
+
1704
+ You can copy out the numpy/_core/lib/npy-pkg-config directory, add a
1705
+ pkgdir value to the .ini files and set NPY_PKG_CONFIG_PATH environment
1706
+ variable to point to the directory with the modified npy-pkg-config
1707
+ files.
1708
+
1709
+ Example npymath.ini modified for cross-compilation::
1710
+
1711
+ [meta]
1712
+ Name=npymath
1713
+ Description=Portable, core math library implementing C99 standard
1714
+ Version=0.1
1715
+
1716
+ [variables]
1717
+ pkgname=numpy._core
1718
+ pkgdir=/build/arm-linux-gnueabi/sysroot/usr/lib/python3.7/site-packages/numpy/_core
1719
+ prefix=${pkgdir}
1720
+ libdir=${prefix}/lib
1721
+ includedir=${prefix}/include
1722
+
1723
+ [default]
1724
+ Libs=-L${libdir} -lnpymath
1725
+ Cflags=-I${includedir}
1726
+ Requires=mlib
1727
+
1728
+ [msvc]
1729
+ Libs=/LIBPATH:${libdir} npymath.lib
1730
+ Cflags=/INCLUDE:${includedir}
1731
+ Requires=mlib
1732
+
1733
+ """
1734
+ if subst_dict is None:
1735
+ subst_dict = {}
1736
+ template = os.path.join(self.package_path, template)
1737
+
1738
+ if self.name in self.installed_pkg_config:
1739
+ self.installed_pkg_config[self.name].append((template, install_dir,
1740
+ subst_dict))
1741
+ else:
1742
+ self.installed_pkg_config[self.name] = [(template, install_dir,
1743
+ subst_dict)]
1744
+
1745
+
1746
+ def add_scripts(self,*files):
1747
+ """Add scripts to configuration.
1748
+
1749
+ Add the sequence of files to the beginning of the scripts list.
1750
+ Scripts will be installed under the <prefix>/bin/ directory.
1751
+
1752
+ """
1753
+ scripts = self.paths(files)
1754
+ dist = self.get_distribution()
1755
+ if dist is not None:
1756
+ if dist.scripts is None:
1757
+ dist.scripts = []
1758
+ dist.scripts.extend(scripts)
1759
+ else:
1760
+ self.scripts.extend(scripts)
1761
+
1762
+ def dict_append(self,**dict):
1763
+ for key in self.list_keys:
1764
+ a = getattr(self, key)
1765
+ a.extend(dict.get(key, []))
1766
+ for key in self.dict_keys:
1767
+ a = getattr(self, key)
1768
+ a.update(dict.get(key, {}))
1769
+ known_keys = self.list_keys + self.dict_keys + self.extra_keys
1770
+ for key in dict.keys():
1771
+ if key not in known_keys:
1772
+ a = getattr(self, key, None)
1773
+ if a and a==dict[key]: continue
1774
+ self.warn('Inheriting attribute %r=%r from %r' \
1775
+ % (key, dict[key], dict.get('name', '?')))
1776
+ setattr(self, key, dict[key])
1777
+ self.extra_keys.append(key)
1778
+ elif key in self.extra_keys:
1779
+ self.info('Ignoring attempt to set %r (from %r to %r)' \
1780
+ % (key, getattr(self, key), dict[key]))
1781
+ elif key in known_keys:
1782
+ # key is already processed above
1783
+ pass
1784
+ else:
1785
+ raise ValueError("Don't know about key=%r" % (key))
1786
+
1787
+ def __str__(self):
1788
+ from pprint import pformat
1789
+ known_keys = self.list_keys + self.dict_keys + self.extra_keys
1790
+ s = '<'+5*'-' + '\n'
1791
+ s += 'Configuration of '+self.name+':\n'
1792
+ known_keys.sort()
1793
+ for k in known_keys:
1794
+ a = getattr(self, k, None)
1795
+ if a:
1796
+ s += '%s = %s\n' % (k, pformat(a))
1797
+ s += 5*'-' + '>'
1798
+ return s
1799
+
1800
+ def get_config_cmd(self):
1801
+ """
1802
+ Returns the numpy.distutils config command instance.
1803
+ """
1804
+ cmd = get_cmd('config')
1805
+ cmd.ensure_finalized()
1806
+ cmd.dump_source = 0
1807
+ cmd.noisy = 0
1808
+ old_path = os.environ.get('PATH')
1809
+ if old_path:
1810
+ path = os.pathsep.join(['.', old_path])
1811
+ os.environ['PATH'] = path
1812
+ return cmd
1813
+
1814
+ def get_build_temp_dir(self):
1815
+ """
1816
+ Return a path to a temporary directory where temporary files should be
1817
+ placed.
1818
+ """
1819
+ cmd = get_cmd('build')
1820
+ cmd.ensure_finalized()
1821
+ return cmd.build_temp
1822
+
1823
+ def have_f77c(self):
1824
+ """Check for availability of Fortran 77 compiler.
1825
+
1826
+ Use it inside source generating function to ensure that
1827
+ setup distribution instance has been initialized.
1828
+
1829
+ Notes
1830
+ -----
1831
+ True if a Fortran 77 compiler is available (because a simple Fortran 77
1832
+ code was able to be compiled successfully).
1833
+ """
1834
+ simple_fortran_subroutine = '''
1835
+ subroutine simple
1836
+ end
1837
+ '''
1838
+ config_cmd = self.get_config_cmd()
1839
+ flag = config_cmd.try_compile(simple_fortran_subroutine, lang='f77')
1840
+ return flag
1841
+
1842
+ def have_f90c(self):
1843
+ """Check for availability of Fortran 90 compiler.
1844
+
1845
+ Use it inside source generating function to ensure that
1846
+ setup distribution instance has been initialized.
1847
+
1848
+ Notes
1849
+ -----
1850
+ True if a Fortran 90 compiler is available (because a simple Fortran
1851
+ 90 code was able to be compiled successfully)
1852
+ """
1853
+ simple_fortran_subroutine = '''
1854
+ subroutine simple
1855
+ end
1856
+ '''
1857
+ config_cmd = self.get_config_cmd()
1858
+ flag = config_cmd.try_compile(simple_fortran_subroutine, lang='f90')
1859
+ return flag
1860
+
1861
+ def append_to(self, extlib):
1862
+ """Append libraries, include_dirs to extension or library item.
1863
+ """
1864
+ if is_sequence(extlib):
1865
+ lib_name, build_info = extlib
1866
+ dict_append(build_info,
1867
+ libraries=self.libraries,
1868
+ include_dirs=self.include_dirs)
1869
+ else:
1870
+ from numpy.distutils.core import Extension
1871
+ assert isinstance(extlib, Extension), repr(extlib)
1872
+ extlib.libraries.extend(self.libraries)
1873
+ extlib.include_dirs.extend(self.include_dirs)
1874
+
1875
+ def _get_svn_revision(self, path):
1876
+ """Return path's SVN revision number.
1877
+ """
1878
+ try:
1879
+ output = subprocess.check_output(['svnversion'], cwd=path)
1880
+ except (subprocess.CalledProcessError, OSError):
1881
+ pass
1882
+ else:
1883
+ m = re.match(rb'(?P<revision>\d+)', output)
1884
+ if m:
1885
+ return int(m.group('revision'))
1886
+
1887
+ if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK', None):
1888
+ entries = njoin(path, '_svn', 'entries')
1889
+ else:
1890
+ entries = njoin(path, '.svn', 'entries')
1891
+ if os.path.isfile(entries):
1892
+ with open(entries) as f:
1893
+ fstr = f.read()
1894
+ if fstr[:5] == '<?xml': # pre 1.4
1895
+ m = re.search(r'revision="(?P<revision>\d+)"', fstr)
1896
+ if m:
1897
+ return int(m.group('revision'))
1898
+ else: # non-xml entries file --- check to be sure that
1899
+ m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr)
1900
+ if m:
1901
+ return int(m.group('revision'))
1902
+ return None
1903
+
1904
+ def _get_hg_revision(self, path):
1905
+ """Return path's Mercurial revision number.
1906
+ """
1907
+ try:
1908
+ output = subprocess.check_output(
1909
+ ['hg', 'identify', '--num'], cwd=path)
1910
+ except (subprocess.CalledProcessError, OSError):
1911
+ pass
1912
+ else:
1913
+ m = re.match(rb'(?P<revision>\d+)', output)
1914
+ if m:
1915
+ return int(m.group('revision'))
1916
+
1917
+ branch_fn = njoin(path, '.hg', 'branch')
1918
+ branch_cache_fn = njoin(path, '.hg', 'branch.cache')
1919
+
1920
+ if os.path.isfile(branch_fn):
1921
+ branch0 = None
1922
+ with open(branch_fn) as f:
1923
+ revision0 = f.read().strip()
1924
+
1925
+ branch_map = {}
1926
+ with open(branch_cache_fn) as f:
1927
+ for line in f:
1928
+ branch1, revision1 = line.split()[:2]
1929
+ if revision1==revision0:
1930
+ branch0 = branch1
1931
+ try:
1932
+ revision1 = int(revision1)
1933
+ except ValueError:
1934
+ continue
1935
+ branch_map[branch1] = revision1
1936
+
1937
+ return branch_map.get(branch0)
1938
+
1939
+ return None
1940
+
1941
+
1942
+ def get_version(self, version_file=None, version_variable=None):
1943
+ """Try to get version string of a package.
1944
+
1945
+ Return a version string of the current package or None if the version
1946
+ information could not be detected.
1947
+
1948
+ Notes
1949
+ -----
1950
+ This method scans files named
1951
+ __version__.py, <packagename>_version.py, version.py, and
1952
+ __svn_version__.py for string variables version, __version__, and
1953
+ <packagename>_version, until a version number is found.
1954
+ """
1955
+ version = getattr(self, 'version', None)
1956
+ if version is not None:
1957
+ return version
1958
+
1959
+ # Get version from version file.
1960
+ if version_file is None:
1961
+ files = ['__version__.py',
1962
+ self.name.split('.')[-1]+'_version.py',
1963
+ 'version.py',
1964
+ '__svn_version__.py',
1965
+ '__hg_version__.py']
1966
+ else:
1967
+ files = [version_file]
1968
+ if version_variable is None:
1969
+ version_vars = ['version',
1970
+ '__version__',
1971
+ self.name.split('.')[-1]+'_version']
1972
+ else:
1973
+ version_vars = [version_variable]
1974
+ for f in files:
1975
+ fn = njoin(self.local_path, f)
1976
+ if os.path.isfile(fn):
1977
+ info = ('.py', 'U', 1)
1978
+ name = os.path.splitext(os.path.basename(fn))[0]
1979
+ n = dot_join(self.name, name)
1980
+ try:
1981
+ version_module = exec_mod_from_location(
1982
+ '_'.join(n.split('.')), fn)
1983
+ except ImportError as e:
1984
+ self.warn(str(e))
1985
+ version_module = None
1986
+ if version_module is None:
1987
+ continue
1988
+
1989
+ for a in version_vars:
1990
+ version = getattr(version_module, a, None)
1991
+ if version is not None:
1992
+ break
1993
+
1994
+ # Try if versioneer module
1995
+ try:
1996
+ version = version_module.get_versions()['version']
1997
+ except AttributeError:
1998
+ pass
1999
+
2000
+ if version is not None:
2001
+ break
2002
+
2003
+ if version is not None:
2004
+ self.version = version
2005
+ return version
2006
+
2007
+ # Get version as SVN or Mercurial revision number
2008
+ revision = self._get_svn_revision(self.local_path)
2009
+ if revision is None:
2010
+ revision = self._get_hg_revision(self.local_path)
2011
+
2012
+ if revision is not None:
2013
+ version = str(revision)
2014
+ self.version = version
2015
+
2016
+ return version
2017
+
2018
+ def make_svn_version_py(self, delete=True):
2019
+ """Appends a data function to the data_files list that will generate
2020
+ __svn_version__.py file to the current package directory.
2021
+
2022
+ Generate package __svn_version__.py file from SVN revision number,
2023
+ it will be removed after python exits but will be available
2024
+ when sdist, etc commands are executed.
2025
+
2026
+ Notes
2027
+ -----
2028
+ If __svn_version__.py existed before, nothing is done.
2029
+
2030
+ This is
2031
+ intended for working with source directories that are in an SVN
2032
+ repository.
2033
+ """
2034
+ target = njoin(self.local_path, '__svn_version__.py')
2035
+ revision = self._get_svn_revision(self.local_path)
2036
+ if os.path.isfile(target) or revision is None:
2037
+ return
2038
+ else:
2039
+ def generate_svn_version_py():
2040
+ if not os.path.isfile(target):
2041
+ version = str(revision)
2042
+ self.info('Creating %s (version=%r)' % (target, version))
2043
+ with open(target, 'w') as f:
2044
+ f.write('version = %r\n' % (version))
2045
+
2046
+ def rm_file(f=target,p=self.info):
2047
+ if delete:
2048
+ try: os.remove(f); p('removed '+f)
2049
+ except OSError: pass
2050
+ try: os.remove(f+'c'); p('removed '+f+'c')
2051
+ except OSError: pass
2052
+
2053
+ atexit.register(rm_file)
2054
+
2055
+ return target
2056
+
2057
+ self.add_data_files(('', generate_svn_version_py()))
2058
+
2059
+ def make_hg_version_py(self, delete=True):
2060
+ """Appends a data function to the data_files list that will generate
2061
+ __hg_version__.py file to the current package directory.
2062
+
2063
+ Generate package __hg_version__.py file from Mercurial revision,
2064
+ it will be removed after python exits but will be available
2065
+ when sdist, etc commands are executed.
2066
+
2067
+ Notes
2068
+ -----
2069
+ If __hg_version__.py existed before, nothing is done.
2070
+
2071
+ This is intended for working with source directories that are
2072
+ in an Mercurial repository.
2073
+ """
2074
+ target = njoin(self.local_path, '__hg_version__.py')
2075
+ revision = self._get_hg_revision(self.local_path)
2076
+ if os.path.isfile(target) or revision is None:
2077
+ return
2078
+ else:
2079
+ def generate_hg_version_py():
2080
+ if not os.path.isfile(target):
2081
+ version = str(revision)
2082
+ self.info('Creating %s (version=%r)' % (target, version))
2083
+ with open(target, 'w') as f:
2084
+ f.write('version = %r\n' % (version))
2085
+
2086
+ def rm_file(f=target,p=self.info):
2087
+ if delete:
2088
+ try: os.remove(f); p('removed '+f)
2089
+ except OSError: pass
2090
+ try: os.remove(f+'c'); p('removed '+f+'c')
2091
+ except OSError: pass
2092
+
2093
+ atexit.register(rm_file)
2094
+
2095
+ return target
2096
+
2097
+ self.add_data_files(('', generate_hg_version_py()))
2098
+
2099
+ def make_config_py(self,name='__config__'):
2100
+ """Generate package __config__.py file containing system_info
2101
+ information used during building the package.
2102
+
2103
+ This file is installed to the
2104
+ package installation directory.
2105
+
2106
+ """
2107
+ self.py_modules.append((self.name, name, generate_config_py))
2108
+
2109
+ def get_info(self,*names):
2110
+ """Get resources information.
2111
+
2112
+ Return information (from system_info.get_info) for all of the names in
2113
+ the argument list in a single dictionary.
2114
+ """
2115
+ from .system_info import get_info, dict_append
2116
+ info_dict = {}
2117
+ for a in names:
2118
+ dict_append(info_dict,**get_info(a))
2119
+ return info_dict
2120
+
2121
+
2122
+ def get_cmd(cmdname, _cache={}):
2123
+ if cmdname not in _cache:
2124
+ import distutils.core
2125
+ dist = distutils.core._setup_distribution
2126
+ if dist is None:
2127
+ from distutils.errors import DistutilsInternalError
2128
+ raise DistutilsInternalError(
2129
+ 'setup distribution instance not initialized')
2130
+ cmd = dist.get_command_obj(cmdname)
2131
+ _cache[cmdname] = cmd
2132
+ return _cache[cmdname]
2133
+
2134
+ def get_numpy_include_dirs():
2135
+ # numpy_include_dirs are set by numpy/_core/setup.py, otherwise []
2136
+ include_dirs = Configuration.numpy_include_dirs[:]
2137
+ if not include_dirs:
2138
+ import numpy
2139
+ include_dirs = [ numpy.get_include() ]
2140
+ # else running numpy/_core/setup.py
2141
+ return include_dirs
2142
+
2143
+ def get_npy_pkg_dir():
2144
+ """Return the path where to find the npy-pkg-config directory.
2145
+
2146
+ If the NPY_PKG_CONFIG_PATH environment variable is set, the value of that
2147
+ is returned. Otherwise, a path inside the location of the numpy module is
2148
+ returned.
2149
+
2150
+ The NPY_PKG_CONFIG_PATH can be useful when cross-compiling, maintaining
2151
+ customized npy-pkg-config .ini files for the cross-compilation
2152
+ environment, and using them when cross-compiling.
2153
+
2154
+ """
2155
+ d = os.environ.get('NPY_PKG_CONFIG_PATH')
2156
+ if d is not None:
2157
+ return d
2158
+ spec = importlib.util.find_spec('numpy')
2159
+ d = os.path.join(os.path.dirname(spec.origin),
2160
+ '_core', 'lib', 'npy-pkg-config')
2161
+ return d
2162
+
2163
+ def get_pkg_info(pkgname, dirs=None):
2164
+ """
2165
+ Return library info for the given package.
2166
+
2167
+ Parameters
2168
+ ----------
2169
+ pkgname : str
2170
+ Name of the package (should match the name of the .ini file, without
2171
+ the extension, e.g. foo for the file foo.ini).
2172
+ dirs : sequence, optional
2173
+ If given, should be a sequence of additional directories where to look
2174
+ for npy-pkg-config files. Those directories are searched prior to the
2175
+ NumPy directory.
2176
+
2177
+ Returns
2178
+ -------
2179
+ pkginfo : class instance
2180
+ The `LibraryInfo` instance containing the build information.
2181
+
2182
+ Raises
2183
+ ------
2184
+ PkgNotFound
2185
+ If the package is not found.
2186
+
2187
+ See Also
2188
+ --------
2189
+ Configuration.add_npy_pkg_config, Configuration.add_installed_library,
2190
+ get_info
2191
+
2192
+ """
2193
+ from numpy.distutils.npy_pkg_config import read_config
2194
+
2195
+ if dirs:
2196
+ dirs.append(get_npy_pkg_dir())
2197
+ else:
2198
+ dirs = [get_npy_pkg_dir()]
2199
+ return read_config(pkgname, dirs)
2200
+
2201
+ def get_info(pkgname, dirs=None):
2202
+ """
2203
+ Return an info dict for a given C library.
2204
+
2205
+ The info dict contains the necessary options to use the C library.
2206
+
2207
+ Parameters
2208
+ ----------
2209
+ pkgname : str
2210
+ Name of the package (should match the name of the .ini file, without
2211
+ the extension, e.g. foo for the file foo.ini).
2212
+ dirs : sequence, optional
2213
+ If given, should be a sequence of additional directories where to look
2214
+ for npy-pkg-config files. Those directories are searched prior to the
2215
+ NumPy directory.
2216
+
2217
+ Returns
2218
+ -------
2219
+ info : dict
2220
+ The dictionary with build information.
2221
+
2222
+ Raises
2223
+ ------
2224
+ PkgNotFound
2225
+ If the package is not found.
2226
+
2227
+ See Also
2228
+ --------
2229
+ Configuration.add_npy_pkg_config, Configuration.add_installed_library,
2230
+ get_pkg_info
2231
+
2232
+ Examples
2233
+ --------
2234
+ To get the necessary information for the npymath library from NumPy:
2235
+
2236
+ >>> npymath_info = np.distutils.misc_util.get_info('npymath')
2237
+ >>> npymath_info #doctest: +SKIP
2238
+ {'define_macros': [], 'libraries': ['npymath'], 'library_dirs':
2239
+ ['.../numpy/_core/lib'], 'include_dirs': ['.../numpy/_core/include']}
2240
+
2241
+ This info dict can then be used as input to a `Configuration` instance::
2242
+
2243
+ config.add_extension('foo', sources=['foo.c'], extra_info=npymath_info)
2244
+
2245
+ """
2246
+ from numpy.distutils.npy_pkg_config import parse_flags
2247
+ pkg_info = get_pkg_info(pkgname, dirs)
2248
+
2249
+ # Translate LibraryInfo instance into a build_info dict
2250
+ info = parse_flags(pkg_info.cflags())
2251
+ for k, v in parse_flags(pkg_info.libs()).items():
2252
+ info[k].extend(v)
2253
+
2254
+ # add_extension extra_info argument is ANAL
2255
+ info['define_macros'] = info['macros']
2256
+ del info['macros']
2257
+ del info['ignored']
2258
+
2259
+ return info
2260
+
2261
+ def is_bootstrapping():
2262
+ import builtins
2263
+
2264
+ try:
2265
+ builtins.__NUMPY_SETUP__
2266
+ return True
2267
+ except AttributeError:
2268
+ return False
2269
+
2270
+
2271
+ #########################
2272
+
2273
+ def default_config_dict(name = None, parent_name = None, local_path=None):
2274
+ """Return a configuration dictionary for usage in
2275
+ configuration() function defined in file setup_<name>.py.
2276
+ """
2277
+ import warnings
2278
+ warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\
2279
+ 'deprecated default_config_dict(%r,%r,%r)'
2280
+ % (name, parent_name, local_path,
2281
+ name, parent_name, local_path,
2282
+ ), stacklevel=2)
2283
+ c = Configuration(name, parent_name, local_path)
2284
+ return c.todict()
2285
+
2286
+
2287
+ def dict_append(d, **kws):
2288
+ for k, v in kws.items():
2289
+ if k in d:
2290
+ ov = d[k]
2291
+ if isinstance(ov, str):
2292
+ d[k] = v
2293
+ else:
2294
+ d[k].extend(v)
2295
+ else:
2296
+ d[k] = v
2297
+
2298
+ def appendpath(prefix, path):
2299
+ if os.path.sep != '/':
2300
+ prefix = prefix.replace('/', os.path.sep)
2301
+ path = path.replace('/', os.path.sep)
2302
+ drive = ''
2303
+ if os.path.isabs(path):
2304
+ drive = os.path.splitdrive(prefix)[0]
2305
+ absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]
2306
+ pathdrive, path = os.path.splitdrive(path)
2307
+ d = os.path.commonprefix([absprefix, path])
2308
+ if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \
2309
+ or os.path.join(path[:len(d)], path[len(d):]) != path:
2310
+ # Handle invalid paths
2311
+ d = os.path.dirname(d)
2312
+ subpath = path[len(d):]
2313
+ if os.path.isabs(subpath):
2314
+ subpath = subpath[1:]
2315
+ else:
2316
+ subpath = path
2317
+ return os.path.normpath(njoin(drive + prefix, subpath))
2318
+
2319
+ def generate_config_py(target):
2320
+ """Generate config.py file containing system_info information
2321
+ used during building the package.
2322
+
2323
+ Usage:
2324
+ config['py_modules'].append((packagename, '__config__',generate_config_py))
2325
+ """
2326
+ from numpy.distutils.system_info import system_info
2327
+ from distutils.dir_util import mkpath
2328
+ mkpath(os.path.dirname(target))
2329
+ with open(target, 'w') as f:
2330
+ f.write('# This file is generated by numpy\'s %s\n' % (os.path.basename(sys.argv[0])))
2331
+ f.write('# It contains system_info results at the time of building this package.\n')
2332
+ f.write('__all__ = ["get_info","show"]\n\n')
2333
+
2334
+ # For gfortran+msvc combination, extra shared libraries may exist
2335
+ f.write(textwrap.dedent("""
2336
+ import os
2337
+ import sys
2338
+
2339
+ extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
2340
+
2341
+ if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
2342
+ os.add_dll_directory(extra_dll_dir)
2343
+
2344
+ """))
2345
+
2346
+ for k, i in system_info.saved_results.items():
2347
+ f.write('%s=%r\n' % (k, i))
2348
+ f.write(textwrap.dedent(r'''
2349
+ def get_info(name):
2350
+ g = globals()
2351
+ return g.get(name, g.get(name + "_info", {}))
2352
+
2353
+ def show():
2354
+ """
2355
+ Show libraries in the system on which NumPy was built.
2356
+
2357
+ Print information about various resources (libraries, library
2358
+ directories, include directories, etc.) in the system on which
2359
+ NumPy was built.
2360
+
2361
+ See Also
2362
+ --------
2363
+ get_include : Returns the directory containing NumPy C
2364
+ header files.
2365
+
2366
+ Notes
2367
+ -----
2368
+ 1. Classes specifying the information to be printed are defined
2369
+ in the `numpy.distutils.system_info` module.
2370
+
2371
+ Information may include:
2372
+
2373
+ * ``language``: language used to write the libraries (mostly
2374
+ C or f77)
2375
+ * ``libraries``: names of libraries found in the system
2376
+ * ``library_dirs``: directories containing the libraries
2377
+ * ``include_dirs``: directories containing library header files
2378
+ * ``src_dirs``: directories containing library source files
2379
+ * ``define_macros``: preprocessor macros used by
2380
+ ``distutils.setup``
2381
+ * ``baseline``: minimum CPU features required
2382
+ * ``found``: dispatched features supported in the system
2383
+ * ``not found``: dispatched features that are not supported
2384
+ in the system
2385
+
2386
+ 2. NumPy BLAS/LAPACK Installation Notes
2387
+
2388
+ Installing a numpy wheel (``pip install numpy`` or force it
2389
+ via ``pip install numpy --only-binary :numpy: numpy``) includes
2390
+ an OpenBLAS implementation of the BLAS and LAPACK linear algebra
2391
+ APIs. In this case, ``library_dirs`` reports the original build
2392
+ time configuration as compiled with gcc/gfortran; at run time
2393
+ the OpenBLAS library is in
2394
+ ``site-packages/numpy.libs/`` (linux), or
2395
+ ``site-packages/numpy/.dylibs/`` (macOS), or
2396
+ ``site-packages/numpy/.libs/`` (windows).
2397
+
2398
+ Installing numpy from source
2399
+ (``pip install numpy --no-binary numpy``) searches for BLAS and
2400
+ LAPACK dynamic link libraries at build time as influenced by
2401
+ environment variables NPY_BLAS_LIBS, NPY_CBLAS_LIBS, and
2402
+ NPY_LAPACK_LIBS; or NPY_BLAS_ORDER and NPY_LAPACK_ORDER;
2403
+ or the optional file ``~/.numpy-site.cfg``.
2404
+ NumPy remembers those locations and expects to load the same
2405
+ libraries at run-time.
2406
+ In NumPy 1.21+ on macOS, 'accelerate' (Apple's Accelerate BLAS
2407
+ library) is in the default build-time search order after
2408
+ 'openblas'.
2409
+
2410
+ Examples
2411
+ --------
2412
+ >>> import numpy as np
2413
+ >>> np.show_config()
2414
+ blas_opt_info:
2415
+ language = c
2416
+ define_macros = [('HAVE_CBLAS', None)]
2417
+ libraries = ['openblas', 'openblas']
2418
+ library_dirs = ['/usr/local/lib']
2419
+ """
2420
+ from numpy._core._multiarray_umath import (
2421
+ __cpu_features__, __cpu_baseline__, __cpu_dispatch__
2422
+ )
2423
+ for name,info_dict in globals().items():
2424
+ if name[0] == "_" or type(info_dict) is not type({}): continue
2425
+ print(name + ":")
2426
+ if not info_dict:
2427
+ print(" NOT AVAILABLE")
2428
+ for k,v in info_dict.items():
2429
+ v = str(v)
2430
+ if k == "sources" and len(v) > 200:
2431
+ v = v[:60] + " ...\n... " + v[-60:]
2432
+ print(" %s = %s" % (k,v))
2433
+
2434
+ features_found, features_not_found = [], []
2435
+ for feature in __cpu_dispatch__:
2436
+ if __cpu_features__[feature]:
2437
+ features_found.append(feature)
2438
+ else:
2439
+ features_not_found.append(feature)
2440
+
2441
+ print("Supported SIMD extensions in this NumPy install:")
2442
+ print(" baseline = %s" % (','.join(__cpu_baseline__)))
2443
+ print(" found = %s" % (','.join(features_found)))
2444
+ print(" not found = %s" % (','.join(features_not_found)))
2445
+
2446
+ '''))
2447
+
2448
+ return target
2449
+
2450
+ def msvc_version(compiler):
2451
+ """Return version major and minor of compiler instance if it is
2452
+ MSVC, raise an exception otherwise."""
2453
+ if not compiler.compiler_type == "msvc":
2454
+ raise ValueError("Compiler instance is not msvc (%s)"\
2455
+ % compiler.compiler_type)
2456
+ return compiler._MSVCCompiler__version
2457
+
2458
+ def get_build_architecture():
2459
+ # Importing distutils.msvccompiler triggers a warning on non-Windows
2460
+ # systems, so delay the import to here.
2461
+ from distutils.msvccompiler import get_build_architecture
2462
+ return get_build_architecture()
2463
+
2464
+
2465
+ _cxx_ignore_flags = {'-Werror=implicit-function-declaration', '-std=c99'}
2466
+
2467
+
2468
+ def sanitize_cxx_flags(cxxflags):
2469
+ '''
2470
+ Some flags are valid for C but not C++. Prune them.
2471
+ '''
2472
+ return [flag for flag in cxxflags if flag not in _cxx_ignore_flags]
2473
+
2474
+
2475
+ def exec_mod_from_location(modname, modfile):
2476
+ '''
2477
+ Use importlib machinery to import a module `modname` from the file
2478
+ `modfile`. Depending on the `spec.loader`, the module may not be
2479
+ registered in sys.modules.
2480
+ '''
2481
+ spec = importlib.util.spec_from_file_location(modname, modfile)
2482
+ foo = importlib.util.module_from_spec(spec)
2483
+ spec.loader.exec_module(foo)
2484
+ return foo
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/msvc9compiler.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from distutils.msvc9compiler import MSVCCompiler as _MSVCCompiler
3
+
4
+ from .system_info import platform_bits
5
+
6
+
7
+ def _merge(old, new):
8
+ """Concatenate two environment paths avoiding repeats.
9
+
10
+ Here `old` is the environment string before the base class initialize
11
+ function is called and `new` is the string after the call. The new string
12
+ will be a fixed string if it is not obtained from the current environment,
13
+ or the same as the old string if obtained from the same environment. The aim
14
+ here is not to append the new string if it is already contained in the old
15
+ string so as to limit the growth of the environment string.
16
+
17
+ Parameters
18
+ ----------
19
+ old : string
20
+ Previous environment string.
21
+ new : string
22
+ New environment string.
23
+
24
+ Returns
25
+ -------
26
+ ret : string
27
+ Updated environment string.
28
+
29
+ """
30
+ if not old:
31
+ return new
32
+ if new in old:
33
+ return old
34
+
35
+ # Neither new nor old is empty. Give old priority.
36
+ return ';'.join([old, new])
37
+
38
+
39
+ class MSVCCompiler(_MSVCCompiler):
40
+ def __init__(self, verbose=0, dry_run=0, force=0):
41
+ _MSVCCompiler.__init__(self, verbose, dry_run, force)
42
+
43
+ def initialize(self, plat_name=None):
44
+ # The 'lib' and 'include' variables may be overwritten
45
+ # by MSVCCompiler.initialize, so save them for later merge.
46
+ environ_lib = os.getenv('lib')
47
+ environ_include = os.getenv('include')
48
+ _MSVCCompiler.initialize(self, plat_name)
49
+
50
+ # Merge current and previous values of 'lib' and 'include'
51
+ os.environ['lib'] = _merge(environ_lib, os.environ['lib'])
52
+ os.environ['include'] = _merge(environ_include, os.environ['include'])
53
+
54
+ # msvc9 building for 32 bits requires SSE2 to work around a
55
+ # compiler bug.
56
+ if platform_bits == 32:
57
+ self.compile_options += ['/arch:SSE2']
58
+ self.compile_options_debug += ['/arch:SSE2']
59
+
60
+ def manifest_setup_ldargs(self, output_filename, build_temp, ld_args):
61
+ ld_args.append('/MANIFEST')
62
+ _MSVCCompiler.manifest_setup_ldargs(self, output_filename,
63
+ build_temp, ld_args)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/msvccompiler.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from distutils.msvccompiler import MSVCCompiler as _MSVCCompiler
3
+
4
+ from .system_info import platform_bits
5
+
6
+
7
+ def _merge(old, new):
8
+ """Concatenate two environment paths avoiding repeats.
9
+
10
+ Here `old` is the environment string before the base class initialize
11
+ function is called and `new` is the string after the call. The new string
12
+ will be a fixed string if it is not obtained from the current environment,
13
+ or the same as the old string if obtained from the same environment. The aim
14
+ here is not to append the new string if it is already contained in the old
15
+ string so as to limit the growth of the environment string.
16
+
17
+ Parameters
18
+ ----------
19
+ old : string
20
+ Previous environment string.
21
+ new : string
22
+ New environment string.
23
+
24
+ Returns
25
+ -------
26
+ ret : string
27
+ Updated environment string.
28
+
29
+ """
30
+ if new in old:
31
+ return old
32
+ if not old:
33
+ return new
34
+
35
+ # Neither new nor old is empty. Give old priority.
36
+ return ';'.join([old, new])
37
+
38
+
39
+ class MSVCCompiler(_MSVCCompiler):
40
+ def __init__(self, verbose=0, dry_run=0, force=0):
41
+ _MSVCCompiler.__init__(self, verbose, dry_run, force)
42
+
43
+ def initialize(self):
44
+ # The 'lib' and 'include' variables may be overwritten
45
+ # by MSVCCompiler.initialize, so save them for later merge.
46
+ environ_lib = os.getenv('lib', '')
47
+ environ_include = os.getenv('include', '')
48
+ _MSVCCompiler.initialize(self)
49
+
50
+ # Merge current and previous values of 'lib' and 'include'
51
+ os.environ['lib'] = _merge(environ_lib, os.environ['lib'])
52
+ os.environ['include'] = _merge(environ_include, os.environ['include'])
53
+
54
+ # msvc9 building for 32 bits requires SSE2 to work around a
55
+ # compiler bug.
56
+ if platform_bits == 32:
57
+ self.compile_options += ['/arch:SSE2']
58
+ self.compile_options_debug += ['/arch:SSE2']
59
+
60
+
61
+ def lib_opts_if_msvc(build_cmd):
62
+ """ Add flags if we are using MSVC compiler
63
+
64
+ We can't see `build_cmd` in our scope, because we have not initialized
65
+ the distutils build command, so use this deferred calculation to run
66
+ when we are building the library.
67
+ """
68
+ if build_cmd.compiler.compiler_type != 'msvc':
69
+ return []
70
+ # Explicitly disable whole-program optimization.
71
+ flags = ['/GL-']
72
+ # Disable voltbl section for vc142 to allow link using mingw-w64; see:
73
+ # https://github.com/matthew-brett/dll_investigation/issues/1#issuecomment-1100468171
74
+ if build_cmd.compiler_opt.cc_test_flags(['-d2VolatileMetadata-']):
75
+ flags.append('-d2VolatileMetadata-')
76
+ return flags
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/npy_pkg_config.py ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import re
3
+ import os
4
+
5
+ from configparser import RawConfigParser
6
+
7
+ __all__ = ['FormatError', 'PkgNotFound', 'LibraryInfo', 'VariableSet',
8
+ 'read_config', 'parse_flags']
9
+
10
+ _VAR = re.compile(r'\$\{([a-zA-Z0-9_-]+)\}')
11
+
12
+ class FormatError(OSError):
13
+ """
14
+ Exception thrown when there is a problem parsing a configuration file.
15
+
16
+ """
17
+ def __init__(self, msg):
18
+ self.msg = msg
19
+
20
+ def __str__(self):
21
+ return self.msg
22
+
23
+ class PkgNotFound(OSError):
24
+ """Exception raised when a package can not be located."""
25
+ def __init__(self, msg):
26
+ self.msg = msg
27
+
28
+ def __str__(self):
29
+ return self.msg
30
+
31
+ def parse_flags(line):
32
+ """
33
+ Parse a line from a config file containing compile flags.
34
+
35
+ Parameters
36
+ ----------
37
+ line : str
38
+ A single line containing one or more compile flags.
39
+
40
+ Returns
41
+ -------
42
+ d : dict
43
+ Dictionary of parsed flags, split into relevant categories.
44
+ These categories are the keys of `d`:
45
+
46
+ * 'include_dirs'
47
+ * 'library_dirs'
48
+ * 'libraries'
49
+ * 'macros'
50
+ * 'ignored'
51
+
52
+ """
53
+ d = {'include_dirs': [], 'library_dirs': [], 'libraries': [],
54
+ 'macros': [], 'ignored': []}
55
+
56
+ flags = (' ' + line).split(' -')
57
+ for flag in flags:
58
+ flag = '-' + flag
59
+ if len(flag) > 0:
60
+ if flag.startswith('-I'):
61
+ d['include_dirs'].append(flag[2:].strip())
62
+ elif flag.startswith('-L'):
63
+ d['library_dirs'].append(flag[2:].strip())
64
+ elif flag.startswith('-l'):
65
+ d['libraries'].append(flag[2:].strip())
66
+ elif flag.startswith('-D'):
67
+ d['macros'].append(flag[2:].strip())
68
+ else:
69
+ d['ignored'].append(flag)
70
+
71
+ return d
72
+
73
+ def _escape_backslash(val):
74
+ return val.replace('\\', '\\\\')
75
+
76
+ class LibraryInfo:
77
+ """
78
+ Object containing build information about a library.
79
+
80
+ Parameters
81
+ ----------
82
+ name : str
83
+ The library name.
84
+ description : str
85
+ Description of the library.
86
+ version : str
87
+ Version string.
88
+ sections : dict
89
+ The sections of the configuration file for the library. The keys are
90
+ the section headers, the values the text under each header.
91
+ vars : class instance
92
+ A `VariableSet` instance, which contains ``(name, value)`` pairs for
93
+ variables defined in the configuration file for the library.
94
+ requires : sequence, optional
95
+ The required libraries for the library to be installed.
96
+
97
+ Notes
98
+ -----
99
+ All input parameters (except "sections" which is a method) are available as
100
+ attributes of the same name.
101
+
102
+ """
103
+ def __init__(self, name, description, version, sections, vars, requires=None):
104
+ self.name = name
105
+ self.description = description
106
+ if requires:
107
+ self.requires = requires
108
+ else:
109
+ self.requires = []
110
+ self.version = version
111
+ self._sections = sections
112
+ self.vars = vars
113
+
114
+ def sections(self):
115
+ """
116
+ Return the section headers of the config file.
117
+
118
+ Parameters
119
+ ----------
120
+ None
121
+
122
+ Returns
123
+ -------
124
+ keys : list of str
125
+ The list of section headers.
126
+
127
+ """
128
+ return list(self._sections.keys())
129
+
130
+ def cflags(self, section="default"):
131
+ val = self.vars.interpolate(self._sections[section]['cflags'])
132
+ return _escape_backslash(val)
133
+
134
+ def libs(self, section="default"):
135
+ val = self.vars.interpolate(self._sections[section]['libs'])
136
+ return _escape_backslash(val)
137
+
138
+ def __str__(self):
139
+ m = ['Name: %s' % self.name, 'Description: %s' % self.description]
140
+ if self.requires:
141
+ m.append('Requires:')
142
+ else:
143
+ m.append('Requires: %s' % ",".join(self.requires))
144
+ m.append('Version: %s' % self.version)
145
+
146
+ return "\n".join(m)
147
+
148
+ class VariableSet:
149
+ """
150
+ Container object for the variables defined in a config file.
151
+
152
+ `VariableSet` can be used as a plain dictionary, with the variable names
153
+ as keys.
154
+
155
+ Parameters
156
+ ----------
157
+ d : dict
158
+ Dict of items in the "variables" section of the configuration file.
159
+
160
+ """
161
+ def __init__(self, d):
162
+ self._raw_data = dict([(k, v) for k, v in d.items()])
163
+
164
+ self._re = {}
165
+ self._re_sub = {}
166
+
167
+ self._init_parse()
168
+
169
+ def _init_parse(self):
170
+ for k, v in self._raw_data.items():
171
+ self._init_parse_var(k, v)
172
+
173
+ def _init_parse_var(self, name, value):
174
+ self._re[name] = re.compile(r'\$\{%s\}' % name)
175
+ self._re_sub[name] = value
176
+
177
+ def interpolate(self, value):
178
+ # Brute force: we keep interpolating until there is no '${var}' anymore
179
+ # or until interpolated string is equal to input string
180
+ def _interpolate(value):
181
+ for k in self._re.keys():
182
+ value = self._re[k].sub(self._re_sub[k], value)
183
+ return value
184
+ while _VAR.search(value):
185
+ nvalue = _interpolate(value)
186
+ if nvalue == value:
187
+ break
188
+ value = nvalue
189
+
190
+ return value
191
+
192
+ def variables(self):
193
+ """
194
+ Return the list of variable names.
195
+
196
+ Parameters
197
+ ----------
198
+ None
199
+
200
+ Returns
201
+ -------
202
+ names : list of str
203
+ The names of all variables in the `VariableSet` instance.
204
+
205
+ """
206
+ return list(self._raw_data.keys())
207
+
208
+ # Emulate a dict to set/get variables values
209
+ def __getitem__(self, name):
210
+ return self._raw_data[name]
211
+
212
+ def __setitem__(self, name, value):
213
+ self._raw_data[name] = value
214
+ self._init_parse_var(name, value)
215
+
216
+ def parse_meta(config):
217
+ if not config.has_section('meta'):
218
+ raise FormatError("No meta section found !")
219
+
220
+ d = dict(config.items('meta'))
221
+
222
+ for k in ['name', 'description', 'version']:
223
+ if not k in d:
224
+ raise FormatError("Option %s (section [meta]) is mandatory, "
225
+ "but not found" % k)
226
+
227
+ if not 'requires' in d:
228
+ d['requires'] = []
229
+
230
+ return d
231
+
232
+ def parse_variables(config):
233
+ if not config.has_section('variables'):
234
+ raise FormatError("No variables section found !")
235
+
236
+ d = {}
237
+
238
+ for name, value in config.items("variables"):
239
+ d[name] = value
240
+
241
+ return VariableSet(d)
242
+
243
+ def parse_sections(config):
244
+ return meta_d, r
245
+
246
+ def pkg_to_filename(pkg_name):
247
+ return "%s.ini" % pkg_name
248
+
249
+ def parse_config(filename, dirs=None):
250
+ if dirs:
251
+ filenames = [os.path.join(d, filename) for d in dirs]
252
+ else:
253
+ filenames = [filename]
254
+
255
+ config = RawConfigParser()
256
+
257
+ n = config.read(filenames)
258
+ if not len(n) >= 1:
259
+ raise PkgNotFound("Could not find file(s) %s" % str(filenames))
260
+
261
+ # Parse meta and variables sections
262
+ meta = parse_meta(config)
263
+
264
+ vars = {}
265
+ if config.has_section('variables'):
266
+ for name, value in config.items("variables"):
267
+ vars[name] = _escape_backslash(value)
268
+
269
+ # Parse "normal" sections
270
+ secs = [s for s in config.sections() if not s in ['meta', 'variables']]
271
+ sections = {}
272
+
273
+ requires = {}
274
+ for s in secs:
275
+ d = {}
276
+ if config.has_option(s, "requires"):
277
+ requires[s] = config.get(s, 'requires')
278
+
279
+ for name, value in config.items(s):
280
+ d[name] = value
281
+ sections[s] = d
282
+
283
+ return meta, vars, sections, requires
284
+
285
+ def _read_config_imp(filenames, dirs=None):
286
+ def _read_config(f):
287
+ meta, vars, sections, reqs = parse_config(f, dirs)
288
+ # recursively add sections and variables of required libraries
289
+ for rname, rvalue in reqs.items():
290
+ nmeta, nvars, nsections, nreqs = _read_config(pkg_to_filename(rvalue))
291
+
292
+ # Update var dict for variables not in 'top' config file
293
+ for k, v in nvars.items():
294
+ if not k in vars:
295
+ vars[k] = v
296
+
297
+ # Update sec dict
298
+ for oname, ovalue in nsections[rname].items():
299
+ if ovalue:
300
+ sections[rname][oname] += ' %s' % ovalue
301
+
302
+ return meta, vars, sections, reqs
303
+
304
+ meta, vars, sections, reqs = _read_config(filenames)
305
+
306
+ # FIXME: document this. If pkgname is defined in the variables section, and
307
+ # there is no pkgdir variable defined, pkgdir is automatically defined to
308
+ # the path of pkgname. This requires the package to be imported to work
309
+ if not 'pkgdir' in vars and "pkgname" in vars:
310
+ pkgname = vars["pkgname"]
311
+ if not pkgname in sys.modules:
312
+ raise ValueError("You should import %s to get information on %s" %
313
+ (pkgname, meta["name"]))
314
+
315
+ mod = sys.modules[pkgname]
316
+ vars["pkgdir"] = _escape_backslash(os.path.dirname(mod.__file__))
317
+
318
+ return LibraryInfo(name=meta["name"], description=meta["description"],
319
+ version=meta["version"], sections=sections, vars=VariableSet(vars))
320
+
321
+ # Trivial cache to cache LibraryInfo instances creation. To be really
322
+ # efficient, the cache should be handled in read_config, since a same file can
323
+ # be parsed many time outside LibraryInfo creation, but I doubt this will be a
324
+ # problem in practice
325
+ _CACHE = {}
326
+ def read_config(pkgname, dirs=None):
327
+ """
328
+ Return library info for a package from its configuration file.
329
+
330
+ Parameters
331
+ ----------
332
+ pkgname : str
333
+ Name of the package (should match the name of the .ini file, without
334
+ the extension, e.g. foo for the file foo.ini).
335
+ dirs : sequence, optional
336
+ If given, should be a sequence of directories - usually including
337
+ the NumPy base directory - where to look for npy-pkg-config files.
338
+
339
+ Returns
340
+ -------
341
+ pkginfo : class instance
342
+ The `LibraryInfo` instance containing the build information.
343
+
344
+ Raises
345
+ ------
346
+ PkgNotFound
347
+ If the package is not found.
348
+
349
+ See Also
350
+ --------
351
+ misc_util.get_info, misc_util.get_pkg_info
352
+
353
+ Examples
354
+ --------
355
+ >>> npymath_info = np.distutils.npy_pkg_config.read_config('npymath')
356
+ >>> type(npymath_info)
357
+ <class 'numpy.distutils.npy_pkg_config.LibraryInfo'>
358
+ >>> print(npymath_info)
359
+ Name: npymath
360
+ Description: Portable, core math library implementing C99 standard
361
+ Requires:
362
+ Version: 0.1 #random
363
+
364
+ """
365
+ try:
366
+ return _CACHE[pkgname]
367
+ except KeyError:
368
+ v = _read_config_imp(pkg_to_filename(pkgname), dirs)
369
+ _CACHE[pkgname] = v
370
+ return v
371
+
372
+ # TODO:
373
+ # - implements version comparison (modversion + atleast)
374
+
375
+ # pkg-config simple emulator - useful for debugging, and maybe later to query
376
+ # the system
377
+ if __name__ == '__main__':
378
+ from optparse import OptionParser
379
+ import glob
380
+
381
+ parser = OptionParser()
382
+ parser.add_option("--cflags", dest="cflags", action="store_true",
383
+ help="output all preprocessor and compiler flags")
384
+ parser.add_option("--libs", dest="libs", action="store_true",
385
+ help="output all linker flags")
386
+ parser.add_option("--use-section", dest="section",
387
+ help="use this section instead of default for options")
388
+ parser.add_option("--version", dest="version", action="store_true",
389
+ help="output version")
390
+ parser.add_option("--atleast-version", dest="min_version",
391
+ help="Minimal version")
392
+ parser.add_option("--list-all", dest="list_all", action="store_true",
393
+ help="Minimal version")
394
+ parser.add_option("--define-variable", dest="define_variable",
395
+ help="Replace variable with the given value")
396
+
397
+ (options, args) = parser.parse_args(sys.argv)
398
+
399
+ if len(args) < 2:
400
+ raise ValueError("Expect package name on the command line:")
401
+
402
+ if options.list_all:
403
+ files = glob.glob("*.ini")
404
+ for f in files:
405
+ info = read_config(f)
406
+ print("%s\t%s - %s" % (info.name, info.name, info.description))
407
+
408
+ pkg_name = args[1]
409
+ d = os.environ.get('NPY_PKG_CONFIG_PATH')
410
+ if d:
411
+ info = read_config(
412
+ pkg_name, ['numpy/_core/lib/npy-pkg-config', '.', d]
413
+ )
414
+ else:
415
+ info = read_config(
416
+ pkg_name, ['numpy/_core/lib/npy-pkg-config', '.']
417
+ )
418
+
419
+ if options.section:
420
+ section = options.section
421
+ else:
422
+ section = "default"
423
+
424
+ if options.define_variable:
425
+ m = re.search(r'([\S]+)=([\S]+)', options.define_variable)
426
+ if not m:
427
+ raise ValueError("--define-variable option should be of "
428
+ "the form --define-variable=foo=bar")
429
+ else:
430
+ name = m.group(1)
431
+ value = m.group(2)
432
+ info.vars[name] = value
433
+
434
+ if options.cflags:
435
+ print(info.cflags(section))
436
+ if options.libs:
437
+ print(info.libs(section))
438
+ if options.version:
439
+ print(info.version)
440
+ if options.min_version:
441
+ print(info.version >= options.min_version)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/numpy_distribution.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XXX: Handle setuptools ?
2
+ from distutils.core import Distribution
3
+
4
+ # This class is used because we add new files (sconscripts, and so on) with the
5
+ # scons command
6
+ class NumpyDistribution(Distribution):
7
+ def __init__(self, attrs = None):
8
+ # A list of (sconscripts, pre_hook, post_hook, src, parent_names)
9
+ self.scons_data = []
10
+ # A list of installable libraries
11
+ self.installed_libraries = []
12
+ # A dict of pkg_config files to generate/install
13
+ self.installed_pkg_config = {}
14
+ Distribution.__init__(self, attrs)
15
+
16
+ def has_scons_scripts(self):
17
+ return bool(self.scons_data)
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/pathccompiler.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from distutils.unixccompiler import UnixCCompiler
2
+
3
+ class PathScaleCCompiler(UnixCCompiler):
4
+
5
+ """
6
+ PathScale compiler compatible with an gcc built Python.
7
+ """
8
+
9
+ compiler_type = 'pathcc'
10
+ cc_exe = 'pathcc'
11
+ cxx_exe = 'pathCC'
12
+
13
+ def __init__ (self, verbose=0, dry_run=0, force=0):
14
+ UnixCCompiler.__init__ (self, verbose, dry_run, force)
15
+ cc_compiler = self.cc_exe
16
+ cxx_compiler = self.cxx_exe
17
+ self.set_executables(compiler=cc_compiler,
18
+ compiler_so=cc_compiler,
19
+ compiler_cxx=cxx_compiler,
20
+ linker_exe=cc_compiler,
21
+ linker_so=cc_compiler + ' -shared')
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/system_info.py ADDED
The diff for this file is too large to render. See raw diff
 
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/__init__.py ADDED
File without changes
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_build_ext.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''Tests for numpy.distutils.build_ext.'''
2
+
3
+ import os
4
+ import subprocess
5
+ import sys
6
+ from textwrap import indent, dedent
7
+ import pytest
8
+ from numpy.testing import IS_WASM
9
+
10
+ @pytest.mark.skipif(IS_WASM, reason="cannot start subprocess in wasm")
11
+ @pytest.mark.slow
12
+ def test_multi_fortran_libs_link(tmp_path):
13
+ '''
14
+ Ensures multiple "fake" static libraries are correctly linked.
15
+ see gh-18295
16
+ '''
17
+
18
+ # We need to make sure we actually have an f77 compiler.
19
+ # This is nontrivial, so we'll borrow the utilities
20
+ # from f2py tests:
21
+ from numpy.distutils.tests.utilities import has_f77_compiler
22
+ if not has_f77_compiler():
23
+ pytest.skip('No F77 compiler found')
24
+
25
+ # make some dummy sources
26
+ with open(tmp_path / '_dummy1.f', 'w') as fid:
27
+ fid.write(indent(dedent('''\
28
+ FUNCTION dummy_one()
29
+ RETURN
30
+ END FUNCTION'''), prefix=' '*6))
31
+ with open(tmp_path / '_dummy2.f', 'w') as fid:
32
+ fid.write(indent(dedent('''\
33
+ FUNCTION dummy_two()
34
+ RETURN
35
+ END FUNCTION'''), prefix=' '*6))
36
+ with open(tmp_path / '_dummy.c', 'w') as fid:
37
+ # doesn't need to load - just needs to exist
38
+ fid.write('int PyInit_dummyext;')
39
+
40
+ # make a setup file
41
+ with open(tmp_path / 'setup.py', 'w') as fid:
42
+ srctree = os.path.join(os.path.dirname(__file__), '..', '..', '..')
43
+ fid.write(dedent(f'''\
44
+ def configuration(parent_package="", top_path=None):
45
+ from numpy.distutils.misc_util import Configuration
46
+ config = Configuration("", parent_package, top_path)
47
+ config.add_library("dummy1", sources=["_dummy1.f"])
48
+ config.add_library("dummy2", sources=["_dummy2.f"])
49
+ config.add_extension("dummyext", sources=["_dummy.c"], libraries=["dummy1", "dummy2"])
50
+ return config
51
+
52
+
53
+ if __name__ == "__main__":
54
+ import sys
55
+ sys.path.insert(0, r"{srctree}")
56
+ from numpy.distutils.core import setup
57
+ setup(**configuration(top_path="").todict())'''))
58
+
59
+ # build the test extension and "install" into a temporary directory
60
+ build_dir = tmp_path
61
+ subprocess.check_call([sys.executable, 'setup.py', 'build', 'install',
62
+ '--prefix', str(tmp_path / 'installdir'),
63
+ '--record', str(tmp_path / 'tmp_install_log.txt'),
64
+ ],
65
+ cwd=str(build_dir),
66
+ )
67
+ # get the path to the so
68
+ so = None
69
+ with open(tmp_path /'tmp_install_log.txt') as fid:
70
+ for line in fid:
71
+ if 'dummyext' in line:
72
+ so = line.strip()
73
+ break
74
+ assert so is not None
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_ccompiler_opt.py ADDED
@@ -0,0 +1,808 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re, textwrap, os
2
+ from os import sys, path
3
+ from distutils.errors import DistutilsError
4
+
5
+ is_standalone = __name__ == '__main__' and __package__ is None
6
+ if is_standalone:
7
+ import unittest, contextlib, tempfile, shutil
8
+ sys.path.append(path.abspath(path.join(path.dirname(__file__), "..")))
9
+ from ccompiler_opt import CCompilerOpt
10
+
11
+ # from numpy/testing/_private/utils.py
12
+ @contextlib.contextmanager
13
+ def tempdir(*args, **kwargs):
14
+ tmpdir = tempfile.mkdtemp(*args, **kwargs)
15
+ try:
16
+ yield tmpdir
17
+ finally:
18
+ shutil.rmtree(tmpdir)
19
+
20
+ def assert_(expr, msg=''):
21
+ if not expr:
22
+ raise AssertionError(msg)
23
+ else:
24
+ from numpy.distutils.ccompiler_opt import CCompilerOpt
25
+ from numpy.testing import assert_, tempdir
26
+
27
+ # architectures and compilers to test
28
+ arch_compilers = dict(
29
+ x86 = ("gcc", "clang", "icc", "iccw", "msvc"),
30
+ x64 = ("gcc", "clang", "icc", "iccw", "msvc"),
31
+ ppc64 = ("gcc", "clang"),
32
+ ppc64le = ("gcc", "clang"),
33
+ armhf = ("gcc", "clang"),
34
+ aarch64 = ("gcc", "clang", "fcc"),
35
+ s390x = ("gcc", "clang"),
36
+ noarch = ("gcc",)
37
+ )
38
+
39
+ class FakeCCompilerOpt(CCompilerOpt):
40
+ fake_info = ""
41
+ def __init__(self, trap_files="", trap_flags="", *args, **kwargs):
42
+ self.fake_trap_files = trap_files
43
+ self.fake_trap_flags = trap_flags
44
+ CCompilerOpt.__init__(self, None, **kwargs)
45
+
46
+ def __repr__(self):
47
+ return textwrap.dedent("""\
48
+ <<<<
49
+ march : {}
50
+ compiler : {}
51
+ ----------------
52
+ {}
53
+ >>>>
54
+ """).format(self.cc_march, self.cc_name, self.report())
55
+
56
+ def dist_compile(self, sources, flags, **kwargs):
57
+ assert(isinstance(sources, list))
58
+ assert(isinstance(flags, list))
59
+ if self.fake_trap_files:
60
+ for src in sources:
61
+ if re.match(self.fake_trap_files, src):
62
+ self.dist_error("source is trapped by a fake interface")
63
+ if self.fake_trap_flags:
64
+ for f in flags:
65
+ if re.match(self.fake_trap_flags, f):
66
+ self.dist_error("flag is trapped by a fake interface")
67
+ # fake objects
68
+ return zip(sources, [' '.join(flags)] * len(sources))
69
+
70
+ def dist_info(self):
71
+ return FakeCCompilerOpt.fake_info
72
+
73
+ @staticmethod
74
+ def dist_log(*args, stderr=False):
75
+ pass
76
+
77
+ class _Test_CCompilerOpt:
78
+ arch = None # x86_64
79
+ cc = None # gcc
80
+
81
+ def setup_class(self):
82
+ FakeCCompilerOpt.conf_nocache = True
83
+ self._opt = None
84
+
85
+ def nopt(self, *args, **kwargs):
86
+ FakeCCompilerOpt.fake_info = (self.arch, self.cc, "")
87
+ return FakeCCompilerOpt(*args, **kwargs)
88
+
89
+ def opt(self):
90
+ if not self._opt:
91
+ self._opt = self.nopt()
92
+ return self._opt
93
+
94
+ def march(self):
95
+ return self.opt().cc_march
96
+
97
+ def cc_name(self):
98
+ return self.opt().cc_name
99
+
100
+ def get_targets(self, targets, groups, **kwargs):
101
+ FakeCCompilerOpt.conf_target_groups = groups
102
+ opt = self.nopt(
103
+ cpu_baseline=kwargs.get("baseline", "min"),
104
+ cpu_dispatch=kwargs.get("dispatch", "max"),
105
+ trap_files=kwargs.get("trap_files", ""),
106
+ trap_flags=kwargs.get("trap_flags", "")
107
+ )
108
+ with tempdir() as tmpdir:
109
+ file = os.path.join(tmpdir, "test_targets.c")
110
+ with open(file, 'w') as f:
111
+ f.write(targets)
112
+ gtargets = []
113
+ gflags = {}
114
+ fake_objects = opt.try_dispatch([file])
115
+ for source, flags in fake_objects:
116
+ gtar = path.basename(source).split('.')[1:-1]
117
+ glen = len(gtar)
118
+ if glen == 0:
119
+ gtar = "baseline"
120
+ elif glen == 1:
121
+ gtar = gtar[0].upper()
122
+ else:
123
+ # converting multi-target into parentheses str format to be equivalent
124
+ # to the configuration statements syntax.
125
+ gtar = ('('+' '.join(gtar)+')').upper()
126
+ gtargets.append(gtar)
127
+ gflags[gtar] = flags
128
+
129
+ has_baseline, targets = opt.sources_status[file]
130
+ targets = targets + ["baseline"] if has_baseline else targets
131
+ # convert tuple that represent multi-target into parentheses str format
132
+ targets = [
133
+ '('+' '.join(tar)+')' if isinstance(tar, tuple) else tar
134
+ for tar in targets
135
+ ]
136
+ if len(targets) != len(gtargets) or not all(t in gtargets for t in targets):
137
+ raise AssertionError(
138
+ "'sources_status' returns different targets than the compiled targets\n"
139
+ "%s != %s" % (targets, gtargets)
140
+ )
141
+ # return targets from 'sources_status' since the order is matters
142
+ return targets, gflags
143
+
144
+ def arg_regex(self, **kwargs):
145
+ map2origin = dict(
146
+ x64 = "x86",
147
+ ppc64le = "ppc64",
148
+ aarch64 = "armhf",
149
+ clang = "gcc",
150
+ )
151
+ march = self.march(); cc_name = self.cc_name()
152
+ map_march = map2origin.get(march, march)
153
+ map_cc = map2origin.get(cc_name, cc_name)
154
+ for key in (
155
+ march, cc_name, map_march, map_cc,
156
+ march + '_' + cc_name,
157
+ map_march + '_' + cc_name,
158
+ march + '_' + map_cc,
159
+ map_march + '_' + map_cc,
160
+ ) :
161
+ regex = kwargs.pop(key, None)
162
+ if regex is not None:
163
+ break
164
+ if regex:
165
+ if isinstance(regex, dict):
166
+ for k, v in regex.items():
167
+ if v[-1:] not in ')}$?\\.+*':
168
+ regex[k] = v + '$'
169
+ else:
170
+ assert(isinstance(regex, str))
171
+ if regex[-1:] not in ')}$?\\.+*':
172
+ regex += '$'
173
+ return regex
174
+
175
+ def expect(self, dispatch, baseline="", **kwargs):
176
+ match = self.arg_regex(**kwargs)
177
+ if match is None:
178
+ return
179
+ opt = self.nopt(
180
+ cpu_baseline=baseline, cpu_dispatch=dispatch,
181
+ trap_files=kwargs.get("trap_files", ""),
182
+ trap_flags=kwargs.get("trap_flags", "")
183
+ )
184
+ features = ' '.join(opt.cpu_dispatch_names())
185
+ if not match:
186
+ if len(features) != 0:
187
+ raise AssertionError(
188
+ 'expected empty features, not "%s"' % features
189
+ )
190
+ return
191
+ if not re.match(match, features, re.IGNORECASE):
192
+ raise AssertionError(
193
+ 'dispatch features "%s" not match "%s"' % (features, match)
194
+ )
195
+
196
+ def expect_baseline(self, baseline, dispatch="", **kwargs):
197
+ match = self.arg_regex(**kwargs)
198
+ if match is None:
199
+ return
200
+ opt = self.nopt(
201
+ cpu_baseline=baseline, cpu_dispatch=dispatch,
202
+ trap_files=kwargs.get("trap_files", ""),
203
+ trap_flags=kwargs.get("trap_flags", "")
204
+ )
205
+ features = ' '.join(opt.cpu_baseline_names())
206
+ if not match:
207
+ if len(features) != 0:
208
+ raise AssertionError(
209
+ 'expected empty features, not "%s"' % features
210
+ )
211
+ return
212
+ if not re.match(match, features, re.IGNORECASE):
213
+ raise AssertionError(
214
+ 'baseline features "%s" not match "%s"' % (features, match)
215
+ )
216
+
217
+ def expect_flags(self, baseline, dispatch="", **kwargs):
218
+ match = self.arg_regex(**kwargs)
219
+ if match is None:
220
+ return
221
+ opt = self.nopt(
222
+ cpu_baseline=baseline, cpu_dispatch=dispatch,
223
+ trap_files=kwargs.get("trap_files", ""),
224
+ trap_flags=kwargs.get("trap_flags", "")
225
+ )
226
+ flags = ' '.join(opt.cpu_baseline_flags())
227
+ if not match:
228
+ if len(flags) != 0:
229
+ raise AssertionError(
230
+ 'expected empty flags not "%s"' % flags
231
+ )
232
+ return
233
+ if not re.match(match, flags):
234
+ raise AssertionError(
235
+ 'flags "%s" not match "%s"' % (flags, match)
236
+ )
237
+
238
+ def expect_targets(self, targets, groups={}, **kwargs):
239
+ match = self.arg_regex(**kwargs)
240
+ if match is None:
241
+ return
242
+ targets, _ = self.get_targets(targets=targets, groups=groups, **kwargs)
243
+ targets = ' '.join(targets)
244
+ if not match:
245
+ if len(targets) != 0:
246
+ raise AssertionError(
247
+ 'expected empty targets, not "%s"' % targets
248
+ )
249
+ return
250
+ if not re.match(match, targets, re.IGNORECASE):
251
+ raise AssertionError(
252
+ 'targets "%s" not match "%s"' % (targets, match)
253
+ )
254
+
255
+ def expect_target_flags(self, targets, groups={}, **kwargs):
256
+ match_dict = self.arg_regex(**kwargs)
257
+ if match_dict is None:
258
+ return
259
+ assert(isinstance(match_dict, dict))
260
+ _, tar_flags = self.get_targets(targets=targets, groups=groups)
261
+
262
+ for match_tar, match_flags in match_dict.items():
263
+ if match_tar not in tar_flags:
264
+ raise AssertionError(
265
+ 'expected to find target "%s"' % match_tar
266
+ )
267
+ flags = tar_flags[match_tar]
268
+ if not match_flags:
269
+ if len(flags) != 0:
270
+ raise AssertionError(
271
+ 'expected to find empty flags in target "%s"' % match_tar
272
+ )
273
+ if not re.match(match_flags, flags):
274
+ raise AssertionError(
275
+ '"%s" flags "%s" not match "%s"' % (match_tar, flags, match_flags)
276
+ )
277
+
278
+ def test_interface(self):
279
+ wrong_arch = "ppc64" if self.arch != "ppc64" else "x86"
280
+ wrong_cc = "clang" if self.cc != "clang" else "icc"
281
+ opt = self.opt()
282
+ assert_(getattr(opt, "cc_on_" + self.arch))
283
+ assert_(not getattr(opt, "cc_on_" + wrong_arch))
284
+ assert_(getattr(opt, "cc_is_" + self.cc))
285
+ assert_(not getattr(opt, "cc_is_" + wrong_cc))
286
+
287
+ def test_args_empty(self):
288
+ for baseline, dispatch in (
289
+ ("", "none"),
290
+ (None, ""),
291
+ ("none +none", "none - none"),
292
+ ("none -max", "min - max"),
293
+ ("+vsx2 -VSX2", "vsx avx2 avx512f -max"),
294
+ ("max -vsx - avx + avx512f neon -MAX ",
295
+ "min -min + max -max -vsx + avx2 -avx2 +NONE")
296
+ ) :
297
+ opt = self.nopt(cpu_baseline=baseline, cpu_dispatch=dispatch)
298
+ assert(len(opt.cpu_baseline_names()) == 0)
299
+ assert(len(opt.cpu_dispatch_names()) == 0)
300
+
301
+ def test_args_validation(self):
302
+ if self.march() == "unknown":
303
+ return
304
+ # check sanity of argument's validation
305
+ for baseline, dispatch in (
306
+ ("unkown_feature - max +min", "unknown max min"), # unknowing features
307
+ ("#avx2", "$vsx") # groups and polices aren't acceptable
308
+ ) :
309
+ try:
310
+ self.nopt(cpu_baseline=baseline, cpu_dispatch=dispatch)
311
+ raise AssertionError("excepted an exception for invalid arguments")
312
+ except DistutilsError:
313
+ pass
314
+
315
+ def test_skip(self):
316
+ # only takes what platform supports and skip the others
317
+ # without casing exceptions
318
+ self.expect(
319
+ "sse vsx neon",
320
+ x86="sse", ppc64="vsx", armhf="neon", unknown=""
321
+ )
322
+ self.expect(
323
+ "sse41 avx avx2 vsx2 vsx3 neon_vfpv4 asimd",
324
+ x86 = "sse41 avx avx2",
325
+ ppc64 = "vsx2 vsx3",
326
+ armhf = "neon_vfpv4 asimd",
327
+ unknown = ""
328
+ )
329
+ # any features in cpu_dispatch must be ignored if it's part of baseline
330
+ self.expect(
331
+ "sse neon vsx", baseline="sse neon vsx",
332
+ x86="", ppc64="", armhf=""
333
+ )
334
+ self.expect(
335
+ "avx2 vsx3 asimdhp", baseline="avx2 vsx3 asimdhp",
336
+ x86="", ppc64="", armhf=""
337
+ )
338
+
339
+ def test_implies(self):
340
+ # baseline combining implied features, so we count
341
+ # on it instead of testing 'feature_implies()'' directly
342
+ self.expect_baseline(
343
+ "fma3 avx2 asimd vsx3",
344
+ # .* between two spaces can validate features in between
345
+ x86 = "sse .* sse41 .* fma3.*avx2",
346
+ ppc64 = "vsx vsx2 vsx3",
347
+ armhf = "neon neon_fp16 neon_vfpv4 asimd"
348
+ )
349
+ """
350
+ special cases
351
+ """
352
+ # in icc and msvc, FMA3 and AVX2 can't be separated
353
+ # both need to implies each other, same for avx512f & cd
354
+ for f0, f1 in (
355
+ ("fma3", "avx2"),
356
+ ("avx512f", "avx512cd"),
357
+ ):
358
+ diff = ".* sse42 .* %s .*%s$" % (f0, f1)
359
+ self.expect_baseline(f0,
360
+ x86_gcc=".* sse42 .* %s$" % f0,
361
+ x86_icc=diff, x86_iccw=diff
362
+ )
363
+ self.expect_baseline(f1,
364
+ x86_gcc=".* avx .* %s$" % f1,
365
+ x86_icc=diff, x86_iccw=diff
366
+ )
367
+ # in msvc, following features can't be separated too
368
+ for f in (("fma3", "avx2"), ("avx512f", "avx512cd", "avx512_skx")):
369
+ for ff in f:
370
+ self.expect_baseline(ff,
371
+ x86_msvc=".*%s" % ' '.join(f)
372
+ )
373
+
374
+ # in ppc64le VSX and VSX2 can't be separated
375
+ self.expect_baseline("vsx", ppc64le="vsx vsx2")
376
+ # in aarch64 following features can't be separated
377
+ for f in ("neon", "neon_fp16", "neon_vfpv4", "asimd"):
378
+ self.expect_baseline(f, aarch64="neon neon_fp16 neon_vfpv4 asimd")
379
+
380
+ def test_args_options(self):
381
+ # max & native
382
+ for o in ("max", "native"):
383
+ if o == "native" and self.cc_name() == "msvc":
384
+ continue
385
+ self.expect(o,
386
+ trap_files=".*cpu_(sse|vsx|neon|vx).c",
387
+ x86="", ppc64="", armhf="", s390x=""
388
+ )
389
+ self.expect(o,
390
+ trap_files=".*cpu_(sse3|vsx2|neon_vfpv4|vxe).c",
391
+ x86="sse sse2", ppc64="vsx", armhf="neon neon_fp16",
392
+ aarch64="", ppc64le="", s390x="vx"
393
+ )
394
+ self.expect(o,
395
+ trap_files=".*cpu_(popcnt|vsx3).c",
396
+ x86="sse .* sse41", ppc64="vsx vsx2",
397
+ armhf="neon neon_fp16 .* asimd .*",
398
+ s390x="vx vxe vxe2"
399
+ )
400
+ self.expect(o,
401
+ x86_gcc=".* xop fma4 .* avx512f .* avx512_knl avx512_knm avx512_skx .*",
402
+ # in icc, xop and fam4 aren't supported
403
+ x86_icc=".* avx512f .* avx512_knl avx512_knm avx512_skx .*",
404
+ x86_iccw=".* avx512f .* avx512_knl avx512_knm avx512_skx .*",
405
+ # in msvc, avx512_knl avx512_knm aren't supported
406
+ x86_msvc=".* xop fma4 .* avx512f .* avx512_skx .*",
407
+ armhf=".* asimd asimdhp asimddp .*",
408
+ ppc64="vsx vsx2 vsx3 vsx4.*",
409
+ s390x="vx vxe vxe2.*"
410
+ )
411
+ # min
412
+ self.expect("min",
413
+ x86="sse sse2", x64="sse sse2 sse3",
414
+ armhf="", aarch64="neon neon_fp16 .* asimd",
415
+ ppc64="", ppc64le="vsx vsx2", s390x=""
416
+ )
417
+ self.expect(
418
+ "min", trap_files=".*cpu_(sse2|vsx2).c",
419
+ x86="", ppc64le=""
420
+ )
421
+ # an exception must triggered if native flag isn't supported
422
+ # when option "native" is activated through the args
423
+ try:
424
+ self.expect("native",
425
+ trap_flags=".*(-march=native|-xHost|/QxHost|-mcpu=a64fx).*",
426
+ x86=".*", ppc64=".*", armhf=".*", s390x=".*", aarch64=".*",
427
+ )
428
+ if self.march() != "unknown":
429
+ raise AssertionError(
430
+ "excepted an exception for %s" % self.march()
431
+ )
432
+ except DistutilsError:
433
+ if self.march() == "unknown":
434
+ raise AssertionError("excepted no exceptions")
435
+
436
+ def test_flags(self):
437
+ self.expect_flags(
438
+ "sse sse2 vsx vsx2 neon neon_fp16 vx vxe",
439
+ x86_gcc="-msse -msse2", x86_icc="-msse -msse2",
440
+ x86_iccw="/arch:SSE2",
441
+ x86_msvc="/arch:SSE2" if self.march() == "x86" else "",
442
+ ppc64_gcc= "-mcpu=power8",
443
+ ppc64_clang="-mcpu=power8",
444
+ armhf_gcc="-mfpu=neon-fp16 -mfp16-format=ieee",
445
+ aarch64="",
446
+ s390x="-mzvector -march=arch12"
447
+ )
448
+ # testing normalize -march
449
+ self.expect_flags(
450
+ "asimd",
451
+ aarch64="",
452
+ armhf_gcc=r"-mfp16-format=ieee -mfpu=neon-fp-armv8 -march=armv8-a\+simd"
453
+ )
454
+ self.expect_flags(
455
+ "asimdhp",
456
+ aarch64_gcc=r"-march=armv8.2-a\+fp16",
457
+ armhf_gcc=r"-mfp16-format=ieee -mfpu=neon-fp-armv8 -march=armv8.2-a\+fp16"
458
+ )
459
+ self.expect_flags(
460
+ "asimddp", aarch64_gcc=r"-march=armv8.2-a\+dotprod"
461
+ )
462
+ self.expect_flags(
463
+ # asimdfhm implies asimdhp
464
+ "asimdfhm", aarch64_gcc=r"-march=armv8.2-a\+fp16\+fp16fml"
465
+ )
466
+ self.expect_flags(
467
+ "asimddp asimdhp asimdfhm",
468
+ aarch64_gcc=r"-march=armv8.2-a\+dotprod\+fp16\+fp16fml"
469
+ )
470
+ self.expect_flags(
471
+ "vx vxe vxe2",
472
+ s390x=r"-mzvector -march=arch13"
473
+ )
474
+
475
+ def test_targets_exceptions(self):
476
+ for targets in (
477
+ "bla bla", "/*@targets",
478
+ "/*@targets */",
479
+ "/*@targets unknown */",
480
+ "/*@targets $unknown_policy avx2 */",
481
+ "/*@targets #unknown_group avx2 */",
482
+ "/*@targets $ */",
483
+ "/*@targets # vsx */",
484
+ "/*@targets #$ vsx */",
485
+ "/*@targets vsx avx2 ) */",
486
+ "/*@targets vsx avx2 (avx2 */",
487
+ "/*@targets vsx avx2 () */",
488
+ "/*@targets vsx avx2 ($autovec) */", # no features
489
+ "/*@targets vsx avx2 (xxx) */",
490
+ "/*@targets vsx avx2 (baseline) */",
491
+ ) :
492
+ try:
493
+ self.expect_targets(
494
+ targets,
495
+ x86="", armhf="", ppc64="", s390x=""
496
+ )
497
+ if self.march() != "unknown":
498
+ raise AssertionError(
499
+ "excepted an exception for %s" % self.march()
500
+ )
501
+ except DistutilsError:
502
+ if self.march() == "unknown":
503
+ raise AssertionError("excepted no exceptions")
504
+
505
+ def test_targets_syntax(self):
506
+ for targets in (
507
+ "/*@targets $keep_baseline sse vsx neon vx*/",
508
+ "/*@targets,$keep_baseline,sse,vsx,neon vx*/",
509
+ "/*@targets*$keep_baseline*sse*vsx*neon*vx*/",
510
+ """
511
+ /*
512
+ ** @targets
513
+ ** $keep_baseline, sse vsx,neon, vx
514
+ */
515
+ """,
516
+ """
517
+ /*
518
+ ************@targets****************
519
+ ** $keep_baseline, sse vsx, neon, vx
520
+ ************************************
521
+ */
522
+ """,
523
+ """
524
+ /*
525
+ /////////////@targets/////////////////
526
+ //$keep_baseline//sse//vsx//neon//vx
527
+ /////////////////////////////////////
528
+ */
529
+ """,
530
+ """
531
+ /*
532
+ @targets
533
+ $keep_baseline
534
+ SSE VSX NEON VX*/
535
+ """
536
+ ) :
537
+ self.expect_targets(targets,
538
+ x86="sse", ppc64="vsx", armhf="neon", s390x="vx", unknown=""
539
+ )
540
+
541
+ def test_targets(self):
542
+ # test skipping baseline features
543
+ self.expect_targets(
544
+ """
545
+ /*@targets
546
+ sse sse2 sse41 avx avx2 avx512f
547
+ vsx vsx2 vsx3 vsx4
548
+ neon neon_fp16 asimdhp asimddp
549
+ vx vxe vxe2
550
+ */
551
+ """,
552
+ baseline="avx vsx2 asimd vx vxe",
553
+ x86="avx512f avx2", armhf="asimddp asimdhp", ppc64="vsx4 vsx3",
554
+ s390x="vxe2"
555
+ )
556
+ # test skipping non-dispatch features
557
+ self.expect_targets(
558
+ """
559
+ /*@targets
560
+ sse41 avx avx2 avx512f
561
+ vsx2 vsx3 vsx4
562
+ asimd asimdhp asimddp
563
+ vx vxe vxe2
564
+ */
565
+ """,
566
+ baseline="", dispatch="sse41 avx2 vsx2 asimd asimddp vxe2",
567
+ x86="avx2 sse41", armhf="asimddp asimd", ppc64="vsx2", s390x="vxe2"
568
+ )
569
+ # test skipping features that not supported
570
+ self.expect_targets(
571
+ """
572
+ /*@targets
573
+ sse2 sse41 avx2 avx512f
574
+ vsx2 vsx3 vsx4
575
+ neon asimdhp asimddp
576
+ vx vxe vxe2
577
+ */
578
+ """,
579
+ baseline="",
580
+ trap_files=".*(avx2|avx512f|vsx3|vsx4|asimddp|vxe2).c",
581
+ x86="sse41 sse2", ppc64="vsx2", armhf="asimdhp neon",
582
+ s390x="vxe vx"
583
+ )
584
+ # test skipping features that implies each other
585
+ self.expect_targets(
586
+ """
587
+ /*@targets
588
+ sse sse2 avx fma3 avx2 avx512f avx512cd
589
+ vsx vsx2 vsx3
590
+ neon neon_vfpv4 neon_fp16 neon_fp16 asimd asimdhp
591
+ asimddp asimdfhm
592
+ */
593
+ """,
594
+ baseline="",
595
+ x86_gcc="avx512cd avx512f avx2 fma3 avx sse2",
596
+ x86_msvc="avx512cd avx2 avx sse2",
597
+ x86_icc="avx512cd avx2 avx sse2",
598
+ x86_iccw="avx512cd avx2 avx sse2",
599
+ ppc64="vsx3 vsx2 vsx",
600
+ ppc64le="vsx3 vsx2",
601
+ armhf="asimdfhm asimddp asimdhp asimd neon_vfpv4 neon_fp16 neon",
602
+ aarch64="asimdfhm asimddp asimdhp asimd"
603
+ )
604
+
605
+ def test_targets_policies(self):
606
+ # 'keep_baseline', generate objects for baseline features
607
+ self.expect_targets(
608
+ """
609
+ /*@targets
610
+ $keep_baseline
611
+ sse2 sse42 avx2 avx512f
612
+ vsx2 vsx3
613
+ neon neon_vfpv4 asimd asimddp
614
+ vx vxe vxe2
615
+ */
616
+ """,
617
+ baseline="sse41 avx2 vsx2 asimd vsx3 vxe",
618
+ x86="avx512f avx2 sse42 sse2",
619
+ ppc64="vsx3 vsx2",
620
+ armhf="asimddp asimd neon_vfpv4 neon",
621
+ # neon, neon_vfpv4, asimd implies each other
622
+ aarch64="asimddp asimd",
623
+ s390x="vxe2 vxe vx"
624
+ )
625
+ # 'keep_sort', leave the sort as-is
626
+ self.expect_targets(
627
+ """
628
+ /*@targets
629
+ $keep_baseline $keep_sort
630
+ avx512f sse42 avx2 sse2
631
+ vsx2 vsx3
632
+ asimd neon neon_vfpv4 asimddp
633
+ vxe vxe2
634
+ */
635
+ """,
636
+ x86="avx512f sse42 avx2 sse2",
637
+ ppc64="vsx2 vsx3",
638
+ armhf="asimd neon neon_vfpv4 asimddp",
639
+ # neon, neon_vfpv4, asimd implies each other
640
+ aarch64="asimd asimddp",
641
+ s390x="vxe vxe2"
642
+ )
643
+ # 'autovec', skipping features that can't be
644
+ # vectorized by the compiler
645
+ self.expect_targets(
646
+ """
647
+ /*@targets
648
+ $keep_baseline $keep_sort $autovec
649
+ avx512f avx2 sse42 sse41 sse2
650
+ vsx3 vsx2
651
+ asimddp asimd neon_vfpv4 neon
652
+ */
653
+ """,
654
+ x86_gcc="avx512f avx2 sse42 sse41 sse2",
655
+ x86_icc="avx512f avx2 sse42 sse41 sse2",
656
+ x86_iccw="avx512f avx2 sse42 sse41 sse2",
657
+ x86_msvc="avx512f avx2 sse2"
658
+ if self.march() == 'x86' else "avx512f avx2",
659
+ ppc64="vsx3 vsx2",
660
+ armhf="asimddp asimd neon_vfpv4 neon",
661
+ # neon, neon_vfpv4, asimd implies each other
662
+ aarch64="asimddp asimd"
663
+ )
664
+ for policy in ("$maxopt", "$autovec"):
665
+ # 'maxopt' and autovec set the max acceptable optimization flags
666
+ self.expect_target_flags(
667
+ "/*@targets baseline %s */" % policy,
668
+ gcc={"baseline":".*-O3.*"}, icc={"baseline":".*-O3.*"},
669
+ iccw={"baseline":".*/O3.*"}, msvc={"baseline":".*/O2.*"},
670
+ unknown={"baseline":".*"}
671
+ )
672
+
673
+ # 'werror', force compilers to treat warnings as errors
674
+ self.expect_target_flags(
675
+ "/*@targets baseline $werror */",
676
+ gcc={"baseline":".*-Werror.*"}, icc={"baseline":".*-Werror.*"},
677
+ iccw={"baseline":".*/Werror.*"}, msvc={"baseline":".*/WX.*"},
678
+ unknown={"baseline":".*"}
679
+ )
680
+
681
+ def test_targets_groups(self):
682
+ self.expect_targets(
683
+ """
684
+ /*@targets $keep_baseline baseline #test_group */
685
+ """,
686
+ groups=dict(
687
+ test_group=("""
688
+ $keep_baseline
689
+ asimddp sse2 vsx2 avx2 vsx3
690
+ avx512f asimdhp
691
+ """)
692
+ ),
693
+ x86="avx512f avx2 sse2 baseline",
694
+ ppc64="vsx3 vsx2 baseline",
695
+ armhf="asimddp asimdhp baseline"
696
+ )
697
+ # test skip duplicating and sorting
698
+ self.expect_targets(
699
+ """
700
+ /*@targets
701
+ * sse42 avx avx512f
702
+ * #test_group_1
703
+ * vsx2
704
+ * #test_group_2
705
+ * asimddp asimdfhm
706
+ */
707
+ """,
708
+ groups=dict(
709
+ test_group_1=("""
710
+ VSX2 vsx3 asimd avx2 SSE41
711
+ """),
712
+ test_group_2=("""
713
+ vsx2 vsx3 asImd aVx2 sse41
714
+ """)
715
+ ),
716
+ x86="avx512f avx2 avx sse42 sse41",
717
+ ppc64="vsx3 vsx2",
718
+ # vsx2 part of the default baseline of ppc64le, option ("min")
719
+ ppc64le="vsx3",
720
+ armhf="asimdfhm asimddp asimd",
721
+ # asimd part of the default baseline of aarch64, option ("min")
722
+ aarch64="asimdfhm asimddp"
723
+ )
724
+
725
+ def test_targets_multi(self):
726
+ self.expect_targets(
727
+ """
728
+ /*@targets
729
+ (avx512_clx avx512_cnl) (asimdhp asimddp)
730
+ */
731
+ """,
732
+ x86=r"\(avx512_clx avx512_cnl\)",
733
+ armhf=r"\(asimdhp asimddp\)",
734
+ )
735
+ # test skipping implied features and auto-sort
736
+ self.expect_targets(
737
+ """
738
+ /*@targets
739
+ f16c (sse41 avx sse42) (sse3 avx2 avx512f)
740
+ vsx2 (vsx vsx3 vsx2)
741
+ (neon neon_vfpv4 asimd asimdhp asimddp)
742
+ */
743
+ """,
744
+ x86="avx512f f16c avx",
745
+ ppc64="vsx3 vsx2",
746
+ ppc64le="vsx3", # vsx2 part of baseline
747
+ armhf=r"\(asimdhp asimddp\)",
748
+ )
749
+ # test skipping implied features and keep sort
750
+ self.expect_targets(
751
+ """
752
+ /*@targets $keep_sort
753
+ (sse41 avx sse42) (sse3 avx2 avx512f)
754
+ (vsx vsx3 vsx2)
755
+ (asimddp neon neon_vfpv4 asimd asimdhp)
756
+ (vx vxe vxe2)
757
+ */
758
+ """,
759
+ x86="avx avx512f",
760
+ ppc64="vsx3",
761
+ armhf=r"\(asimdhp asimddp\)",
762
+ s390x="vxe2"
763
+ )
764
+ # test compiler variety and avoiding duplicating
765
+ self.expect_targets(
766
+ """
767
+ /*@targets $keep_sort
768
+ fma3 avx2 (fma3 avx2) (avx2 fma3) avx2 fma3
769
+ */
770
+ """,
771
+ x86_gcc=r"fma3 avx2 \(fma3 avx2\)",
772
+ x86_icc="avx2", x86_iccw="avx2",
773
+ x86_msvc="avx2"
774
+ )
775
+
776
+ def new_test(arch, cc):
777
+ if is_standalone: return textwrap.dedent("""\
778
+ class TestCCompilerOpt_{class_name}(_Test_CCompilerOpt, unittest.TestCase):
779
+ arch = '{arch}'
780
+ cc = '{cc}'
781
+ def __init__(self, methodName="runTest"):
782
+ unittest.TestCase.__init__(self, methodName)
783
+ self.setup_class()
784
+ """).format(
785
+ class_name=arch + '_' + cc, arch=arch, cc=cc
786
+ )
787
+ return textwrap.dedent("""\
788
+ class TestCCompilerOpt_{class_name}(_Test_CCompilerOpt):
789
+ arch = '{arch}'
790
+ cc = '{cc}'
791
+ """).format(
792
+ class_name=arch + '_' + cc, arch=arch, cc=cc
793
+ )
794
+ """
795
+ if 1 and is_standalone:
796
+ FakeCCompilerOpt.fake_info = "x86_icc"
797
+ cco = FakeCCompilerOpt(None, cpu_baseline="avx2")
798
+ print(' '.join(cco.cpu_baseline_names()))
799
+ print(cco.cpu_baseline_flags())
800
+ unittest.main()
801
+ sys.exit()
802
+ """
803
+ for arch, compilers in arch_compilers.items():
804
+ for cc in compilers:
805
+ exec(new_test(arch, cc))
806
+
807
+ if is_standalone:
808
+ unittest.main()
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_ccompiler_opt_conf.py ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+ from os import sys, path
3
+
4
+ is_standalone = __name__ == '__main__' and __package__ is None
5
+ if is_standalone:
6
+ sys.path.append(path.abspath(path.join(path.dirname(__file__), "..")))
7
+ from ccompiler_opt import CCompilerOpt
8
+ else:
9
+ from numpy.distutils.ccompiler_opt import CCompilerOpt
10
+
11
+ arch_compilers = dict(
12
+ x86 = ("gcc", "clang", "icc", "iccw", "msvc"),
13
+ x64 = ("gcc", "clang", "icc", "iccw", "msvc"),
14
+ ppc64 = ("gcc", "clang"),
15
+ ppc64le = ("gcc", "clang"),
16
+ armhf = ("gcc", "clang"),
17
+ aarch64 = ("gcc", "clang"),
18
+ narch = ("gcc",)
19
+ )
20
+
21
+ class FakeCCompilerOpt(CCompilerOpt):
22
+ fake_info = ("arch", "compiler", "extra_args")
23
+ def __init__(self, *args, **kwargs):
24
+ CCompilerOpt.__init__(self, None, **kwargs)
25
+ def dist_compile(self, sources, flags, **kwargs):
26
+ return sources
27
+ def dist_info(self):
28
+ return FakeCCompilerOpt.fake_info
29
+ @staticmethod
30
+ def dist_log(*args, stderr=False):
31
+ pass
32
+
33
+ class _TestConfFeatures(FakeCCompilerOpt):
34
+ """A hook to check the sanity of configured features
35
+ - before it called by the abstract class '_Feature'
36
+ """
37
+
38
+ def conf_features_partial(self):
39
+ conf_all = self.conf_features
40
+ for feature_name, feature in conf_all.items():
41
+ self.test_feature(
42
+ "attribute conf_features",
43
+ conf_all, feature_name, feature
44
+ )
45
+
46
+ conf_partial = FakeCCompilerOpt.conf_features_partial(self)
47
+ for feature_name, feature in conf_partial.items():
48
+ self.test_feature(
49
+ "conf_features_partial()",
50
+ conf_partial, feature_name, feature
51
+ )
52
+ return conf_partial
53
+
54
+ def test_feature(self, log, search_in, feature_name, feature_dict):
55
+ error_msg = (
56
+ "during validate '{}' within feature '{}', "
57
+ "march '{}' and compiler '{}'\n>> "
58
+ ).format(log, feature_name, self.cc_march, self.cc_name)
59
+
60
+ if not feature_name.isupper():
61
+ raise AssertionError(error_msg + "feature name must be in uppercase")
62
+
63
+ for option, val in feature_dict.items():
64
+ self.test_option_types(error_msg, option, val)
65
+ self.test_duplicates(error_msg, option, val)
66
+
67
+ self.test_implies(error_msg, search_in, feature_name, feature_dict)
68
+ self.test_group(error_msg, search_in, feature_name, feature_dict)
69
+ self.test_extra_checks(error_msg, search_in, feature_name, feature_dict)
70
+
71
+ def test_option_types(self, error_msg, option, val):
72
+ for tp, available in (
73
+ ((str, list), (
74
+ "implies", "headers", "flags", "group", "detect", "extra_checks"
75
+ )),
76
+ ((str,), ("disable",)),
77
+ ((int,), ("interest",)),
78
+ ((bool,), ("implies_detect",)),
79
+ ((bool, type(None)), ("autovec",)),
80
+ ) :
81
+ found_it = option in available
82
+ if not found_it:
83
+ continue
84
+ if not isinstance(val, tp):
85
+ error_tp = [t.__name__ for t in (*tp,)]
86
+ error_tp = ' or '.join(error_tp)
87
+ raise AssertionError(error_msg +
88
+ "expected '%s' type for option '%s' not '%s'" % (
89
+ error_tp, option, type(val).__name__
90
+ ))
91
+ break
92
+
93
+ if not found_it:
94
+ raise AssertionError(error_msg + "invalid option name '%s'" % option)
95
+
96
+ def test_duplicates(self, error_msg, option, val):
97
+ if option not in (
98
+ "implies", "headers", "flags", "group", "detect", "extra_checks"
99
+ ) : return
100
+
101
+ if isinstance(val, str):
102
+ val = val.split()
103
+
104
+ if len(val) != len(set(val)):
105
+ raise AssertionError(error_msg + "duplicated values in option '%s'" % option)
106
+
107
+ def test_implies(self, error_msg, search_in, feature_name, feature_dict):
108
+ if feature_dict.get("disabled") is not None:
109
+ return
110
+ implies = feature_dict.get("implies", "")
111
+ if not implies:
112
+ return
113
+ if isinstance(implies, str):
114
+ implies = implies.split()
115
+
116
+ if feature_name in implies:
117
+ raise AssertionError(error_msg + "feature implies itself")
118
+
119
+ for impl in implies:
120
+ impl_dict = search_in.get(impl)
121
+ if impl_dict is not None:
122
+ if "disable" in impl_dict:
123
+ raise AssertionError(error_msg + "implies disabled feature '%s'" % impl)
124
+ continue
125
+ raise AssertionError(error_msg + "implies non-exist feature '%s'" % impl)
126
+
127
+ def test_group(self, error_msg, search_in, feature_name, feature_dict):
128
+ if feature_dict.get("disabled") is not None:
129
+ return
130
+ group = feature_dict.get("group", "")
131
+ if not group:
132
+ return
133
+ if isinstance(group, str):
134
+ group = group.split()
135
+
136
+ for f in group:
137
+ impl_dict = search_in.get(f)
138
+ if not impl_dict or "disable" in impl_dict:
139
+ continue
140
+ raise AssertionError(error_msg +
141
+ "in option 'group', '%s' already exists as a feature name" % f
142
+ )
143
+
144
+ def test_extra_checks(self, error_msg, search_in, feature_name, feature_dict):
145
+ if feature_dict.get("disabled") is not None:
146
+ return
147
+ extra_checks = feature_dict.get("extra_checks", "")
148
+ if not extra_checks:
149
+ return
150
+ if isinstance(extra_checks, str):
151
+ extra_checks = extra_checks.split()
152
+
153
+ for f in extra_checks:
154
+ impl_dict = search_in.get(f)
155
+ if not impl_dict or "disable" in impl_dict:
156
+ continue
157
+ raise AssertionError(error_msg +
158
+ "in option 'extra_checks', extra test case '%s' already exists as a feature name" % f
159
+ )
160
+
161
+ class TestConfFeatures(unittest.TestCase):
162
+ def __init__(self, methodName="runTest"):
163
+ unittest.TestCase.__init__(self, methodName)
164
+ self._setup()
165
+
166
+ def _setup(self):
167
+ FakeCCompilerOpt.conf_nocache = True
168
+
169
+ def test_features(self):
170
+ for arch, compilers in arch_compilers.items():
171
+ for cc in compilers:
172
+ FakeCCompilerOpt.fake_info = (arch, cc, "")
173
+ _TestConfFeatures()
174
+
175
+ if is_standalone:
176
+ unittest.main()
pace_revision_2/.venv-pace/lib/python3.11/site-packages/numpy/distutils/tests/test_exec_command.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pytest
3
+ import sys
4
+ from tempfile import TemporaryFile
5
+
6
+ from numpy.distutils import exec_command
7
+ from numpy.distutils.exec_command import get_pythonexe
8
+ from numpy.testing import tempdir, assert_, assert_warns, IS_WASM
9
+
10
+
11
+ # In python 3 stdout, stderr are text (unicode compliant) devices, so to
12
+ # emulate them import StringIO from the io module.
13
+ from io import StringIO
14
+
15
+ class redirect_stdout:
16
+ """Context manager to redirect stdout for exec_command test."""
17
+ def __init__(self, stdout=None):
18
+ self._stdout = stdout or sys.stdout
19
+
20
+ def __enter__(self):
21
+ self.old_stdout = sys.stdout
22
+ sys.stdout = self._stdout
23
+
24
+ def __exit__(self, exc_type, exc_value, traceback):
25
+ self._stdout.flush()
26
+ sys.stdout = self.old_stdout
27
+ # note: closing sys.stdout won't close it.
28
+ self._stdout.close()
29
+
30
+ class redirect_stderr:
31
+ """Context manager to redirect stderr for exec_command test."""
32
+ def __init__(self, stderr=None):
33
+ self._stderr = stderr or sys.stderr
34
+
35
+ def __enter__(self):
36
+ self.old_stderr = sys.stderr
37
+ sys.stderr = self._stderr
38
+
39
+ def __exit__(self, exc_type, exc_value, traceback):
40
+ self._stderr.flush()
41
+ sys.stderr = self.old_stderr
42
+ # note: closing sys.stderr won't close it.
43
+ self._stderr.close()
44
+
45
+ class emulate_nonposix:
46
+ """Context manager to emulate os.name != 'posix' """
47
+ def __init__(self, osname='non-posix'):
48
+ self._new_name = osname
49
+
50
+ def __enter__(self):
51
+ self._old_name = os.name
52
+ os.name = self._new_name
53
+
54
+ def __exit__(self, exc_type, exc_value, traceback):
55
+ os.name = self._old_name
56
+
57
+
58
+ def test_exec_command_stdout():
59
+ # Regression test for gh-2999 and gh-2915.
60
+ # There are several packages (nose, scipy.weave.inline, Sage inline
61
+ # Fortran) that replace stdout, in which case it doesn't have a fileno
62
+ # method. This is tested here, with a do-nothing command that fails if the
63
+ # presence of fileno() is assumed in exec_command.
64
+
65
+ # The code has a special case for posix systems, so if we are on posix test
66
+ # both that the special case works and that the generic code works.
67
+
68
+ # Test posix version:
69
+ with redirect_stdout(StringIO()):
70
+ with redirect_stderr(TemporaryFile()):
71
+ with assert_warns(DeprecationWarning):
72
+ exec_command.exec_command("cd '.'")
73
+
74
+ if os.name == 'posix':
75
+ # Test general (non-posix) version:
76
+ with emulate_nonposix():
77
+ with redirect_stdout(StringIO()):
78
+ with redirect_stderr(TemporaryFile()):
79
+ with assert_warns(DeprecationWarning):
80
+ exec_command.exec_command("cd '.'")
81
+
82
+ def test_exec_command_stderr():
83
+ # Test posix version:
84
+ with redirect_stdout(TemporaryFile(mode='w+')):
85
+ with redirect_stderr(StringIO()):
86
+ with assert_warns(DeprecationWarning):
87
+ exec_command.exec_command("cd '.'")
88
+
89
+ if os.name == 'posix':
90
+ # Test general (non-posix) version:
91
+ with emulate_nonposix():
92
+ with redirect_stdout(TemporaryFile()):
93
+ with redirect_stderr(StringIO()):
94
+ with assert_warns(DeprecationWarning):
95
+ exec_command.exec_command("cd '.'")
96
+
97
+
98
+ @pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
99
+ class TestExecCommand:
100
+ def setup_method(self):
101
+ self.pyexe = get_pythonexe()
102
+
103
+ def check_nt(self, **kws):
104
+ s, o = exec_command.exec_command('cmd /C echo path=%path%')
105
+ assert_(s == 0)
106
+ assert_(o != '')
107
+
108
+ s, o = exec_command.exec_command(
109
+ '"%s" -c "import sys;sys.stderr.write(sys.platform)"' % self.pyexe)
110
+ assert_(s == 0)
111
+ assert_(o == 'win32')
112
+
113
+ def check_posix(self, **kws):
114
+ s, o = exec_command.exec_command("echo Hello", **kws)
115
+ assert_(s == 0)
116
+ assert_(o == 'Hello')
117
+
118
+ s, o = exec_command.exec_command('echo $AAA', **kws)
119
+ assert_(s == 0)
120
+ assert_(o == '')
121
+
122
+ s, o = exec_command.exec_command('echo "$AAA"', AAA='Tere', **kws)
123
+ assert_(s == 0)
124
+ assert_(o == 'Tere')
125
+
126
+ s, o = exec_command.exec_command('echo "$AAA"', **kws)
127
+ assert_(s == 0)
128
+ assert_(o == '')
129
+
130
+ if 'BBB' not in os.environ:
131
+ os.environ['BBB'] = 'Hi'
132
+ s, o = exec_command.exec_command('echo "$BBB"', **kws)
133
+ assert_(s == 0)
134
+ assert_(o == 'Hi')
135
+
136
+ s, o = exec_command.exec_command('echo "$BBB"', BBB='Hey', **kws)
137
+ assert_(s == 0)
138
+ assert_(o == 'Hey')
139
+
140
+ s, o = exec_command.exec_command('echo "$BBB"', **kws)
141
+ assert_(s == 0)
142
+ assert_(o == 'Hi')
143
+
144
+ del os.environ['BBB']
145
+
146
+ s, o = exec_command.exec_command('echo "$BBB"', **kws)
147
+ assert_(s == 0)
148
+ assert_(o == '')
149
+
150
+
151
+ s, o = exec_command.exec_command('this_is_not_a_command', **kws)
152
+ assert_(s != 0)
153
+ assert_(o != '')
154
+
155
+ s, o = exec_command.exec_command('echo path=$PATH', **kws)
156
+ assert_(s == 0)
157
+ assert_(o != '')
158
+
159
+ s, o = exec_command.exec_command(
160
+ '"%s" -c "import sys,os;sys.stderr.write(os.name)"' %
161
+ self.pyexe, **kws)
162
+ assert_(s == 0)
163
+ assert_(o == 'posix')
164
+
165
+ def check_basic(self, *kws):
166
+ s, o = exec_command.exec_command(
167
+ '"%s" -c "raise \'Ignore me.\'"' % self.pyexe, **kws)
168
+ assert_(s != 0)
169
+ assert_(o != '')
170
+
171
+ s, o = exec_command.exec_command(
172
+ '"%s" -c "import sys;sys.stderr.write(\'0\');'
173
+ 'sys.stderr.write(\'1\');sys.stderr.write(\'2\')"' %
174
+ self.pyexe, **kws)
175
+ assert_(s == 0)
176
+ assert_(o == '012')
177
+
178
+ s, o = exec_command.exec_command(
179
+ '"%s" -c "import sys;sys.exit(15)"' % self.pyexe, **kws)
180
+ assert_(s == 15)
181
+ assert_(o == '')
182
+
183
+ s, o = exec_command.exec_command(
184
+ '"%s" -c "print(\'Heipa\'")' % self.pyexe, **kws)
185
+ assert_(s == 0)
186
+ assert_(o == 'Heipa')
187
+
188
+ def check_execute_in(self, **kws):
189
+ with tempdir() as tmpdir:
190
+ fn = "file"
191
+ tmpfile = os.path.join(tmpdir, fn)
192
+ with open(tmpfile, 'w') as f:
193
+ f.write('Hello')
194
+
195
+ s, o = exec_command.exec_command(
196
+ '"%s" -c "f = open(\'%s\', \'r\'); f.close()"' %
197
+ (self.pyexe, fn), **kws)
198
+ assert_(s != 0)
199
+ assert_(o != '')
200
+ s, o = exec_command.exec_command(
201
+ '"%s" -c "f = open(\'%s\', \'r\'); print(f.read()); '
202
+ 'f.close()"' % (self.pyexe, fn), execute_in=tmpdir, **kws)
203
+ assert_(s == 0)
204
+ assert_(o == 'Hello')
205
+
206
+ def test_basic(self):
207
+ with redirect_stdout(StringIO()):
208
+ with redirect_stderr(StringIO()):
209
+ with assert_warns(DeprecationWarning):
210
+ if os.name == "posix":
211
+ self.check_posix(use_tee=0)
212
+ self.check_posix(use_tee=1)
213
+ elif os.name == "nt":
214
+ self.check_nt(use_tee=0)
215
+ self.check_nt(use_tee=1)
216
+ self.check_execute_in(use_tee=0)
217
+ self.check_execute_in(use_tee=1)