Add files using upload-large-folder tool
Browse files- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/build_py.py +31 -0
- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/build_scripts.py +49 -0
- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/build_src.py +773 -0
- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/config.py +516 -0
- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/config_compiler.py +126 -0
- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/develop.py +15 -0
- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/egg_info.py +25 -0
- pythonProject/.venv/Lib/site-packages/numpy/distutils/command/install.py +79 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh23598Warn.f90 +11 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh23879.f90 +20 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh27697.f90 +12 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh2848.f90 +13 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/operators.f90 +49 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/privatemod.f90 +11 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/publicmod.f90 +10 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/pubprivmod.f90 +10 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/unicode_comment.f90 +4 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/f2cmap/.f2py_f2cmap +1 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/f2cmap/isoFortranEnvMap.f90 +9 -0
- pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/isocintrin/isoCtests.f90 +34 -0
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/build_py.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from distutils.command.build_py import build_py as old_build_py
|
| 2 |
+
from numpy.distutils.misc_util import is_string
|
| 3 |
+
|
| 4 |
+
class build_py(old_build_py):
|
| 5 |
+
|
| 6 |
+
def run(self):
|
| 7 |
+
build_src = self.get_finalized_command('build_src')
|
| 8 |
+
if build_src.py_modules_dict and self.packages is None:
|
| 9 |
+
self.packages = list(build_src.py_modules_dict.keys ())
|
| 10 |
+
old_build_py.run(self)
|
| 11 |
+
|
| 12 |
+
def find_package_modules(self, package, package_dir):
|
| 13 |
+
modules = old_build_py.find_package_modules(self, package, package_dir)
|
| 14 |
+
|
| 15 |
+
# Find build_src generated *.py files.
|
| 16 |
+
build_src = self.get_finalized_command('build_src')
|
| 17 |
+
modules += build_src.py_modules_dict.get(package, [])
|
| 18 |
+
|
| 19 |
+
return modules
|
| 20 |
+
|
| 21 |
+
def find_modules(self):
|
| 22 |
+
old_py_modules = self.py_modules[:]
|
| 23 |
+
new_py_modules = [_m for _m in self.py_modules if is_string(_m)]
|
| 24 |
+
self.py_modules[:] = new_py_modules
|
| 25 |
+
modules = old_build_py.find_modules(self)
|
| 26 |
+
self.py_modules[:] = old_py_modules
|
| 27 |
+
|
| 28 |
+
return modules
|
| 29 |
+
|
| 30 |
+
# XXX: Fix find_source_files for item in py_modules such that item is 3-tuple
|
| 31 |
+
# and item[2] is source file.
|
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/build_scripts.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
""" Modified version of build_scripts that handles building scripts from functions.
|
| 2 |
+
|
| 3 |
+
"""
|
| 4 |
+
from distutils.command.build_scripts import build_scripts as old_build_scripts
|
| 5 |
+
from numpy.distutils import log
|
| 6 |
+
from numpy.distutils.misc_util import is_string
|
| 7 |
+
|
| 8 |
+
class build_scripts(old_build_scripts):
|
| 9 |
+
|
| 10 |
+
def generate_scripts(self, scripts):
|
| 11 |
+
new_scripts = []
|
| 12 |
+
func_scripts = []
|
| 13 |
+
for script in scripts:
|
| 14 |
+
if is_string(script):
|
| 15 |
+
new_scripts.append(script)
|
| 16 |
+
else:
|
| 17 |
+
func_scripts.append(script)
|
| 18 |
+
if not func_scripts:
|
| 19 |
+
return new_scripts
|
| 20 |
+
|
| 21 |
+
build_dir = self.build_dir
|
| 22 |
+
self.mkpath(build_dir)
|
| 23 |
+
for func in func_scripts:
|
| 24 |
+
script = func(build_dir)
|
| 25 |
+
if not script:
|
| 26 |
+
continue
|
| 27 |
+
if is_string(script):
|
| 28 |
+
log.info(" adding '%s' to scripts" % (script,))
|
| 29 |
+
new_scripts.append(script)
|
| 30 |
+
else:
|
| 31 |
+
[log.info(" adding '%s' to scripts" % (s,)) for s in script]
|
| 32 |
+
new_scripts.extend(list(script))
|
| 33 |
+
return new_scripts
|
| 34 |
+
|
| 35 |
+
def run (self):
|
| 36 |
+
if not self.scripts:
|
| 37 |
+
return
|
| 38 |
+
|
| 39 |
+
self.scripts = self.generate_scripts(self.scripts)
|
| 40 |
+
# Now make sure that the distribution object has this list of scripts.
|
| 41 |
+
# setuptools' develop command requires that this be a list of filenames,
|
| 42 |
+
# not functions.
|
| 43 |
+
self.distribution.scripts = self.scripts
|
| 44 |
+
|
| 45 |
+
return old_build_scripts.run(self)
|
| 46 |
+
|
| 47 |
+
def get_source_files(self):
|
| 48 |
+
from numpy.distutils.misc_util import get_script_files
|
| 49 |
+
return get_script_files(self.scripts)
|
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/build_src.py
ADDED
|
@@ -0,0 +1,773 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
""" Build swig and f2py sources.
|
| 2 |
+
"""
|
| 3 |
+
import os
|
| 4 |
+
import re
|
| 5 |
+
import sys
|
| 6 |
+
import shlex
|
| 7 |
+
import copy
|
| 8 |
+
|
| 9 |
+
from distutils.command import build_ext
|
| 10 |
+
from distutils.dep_util import newer_group, newer
|
| 11 |
+
from distutils.util import get_platform
|
| 12 |
+
from distutils.errors import DistutilsError, DistutilsSetupError
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# this import can't be done here, as it uses numpy stuff only available
|
| 16 |
+
# after it's installed
|
| 17 |
+
#import numpy.f2py
|
| 18 |
+
from numpy.distutils import log
|
| 19 |
+
from numpy.distutils.misc_util import (
|
| 20 |
+
fortran_ext_match, appendpath, is_string, is_sequence, get_cmd
|
| 21 |
+
)
|
| 22 |
+
from numpy.distutils.from_template import process_file as process_f_file
|
| 23 |
+
from numpy.distutils.conv_template import process_file as process_c_file
|
| 24 |
+
|
| 25 |
+
def subst_vars(target, source, d):
|
| 26 |
+
"""Substitute any occurrence of @foo@ by d['foo'] from source file into
|
| 27 |
+
target."""
|
| 28 |
+
var = re.compile('@([a-zA-Z_]+)@')
|
| 29 |
+
with open(source, 'r') as fs:
|
| 30 |
+
with open(target, 'w') as ft:
|
| 31 |
+
for l in fs:
|
| 32 |
+
m = var.search(l)
|
| 33 |
+
if m:
|
| 34 |
+
ft.write(l.replace('@%s@' % m.group(1), d[m.group(1)]))
|
| 35 |
+
else:
|
| 36 |
+
ft.write(l)
|
| 37 |
+
|
| 38 |
+
class build_src(build_ext.build_ext):
|
| 39 |
+
|
| 40 |
+
description = "build sources from SWIG, F2PY files or a function"
|
| 41 |
+
|
| 42 |
+
user_options = [
|
| 43 |
+
('build-src=', 'd', "directory to \"build\" sources to"),
|
| 44 |
+
('f2py-opts=', None, "list of f2py command line options"),
|
| 45 |
+
('swig=', None, "path to the SWIG executable"),
|
| 46 |
+
('swig-opts=', None, "list of SWIG command line options"),
|
| 47 |
+
('swig-cpp', None, "make SWIG create C++ files (default is autodetected from sources)"),
|
| 48 |
+
('f2pyflags=', None, "additional flags to f2py (use --f2py-opts= instead)"), # obsolete
|
| 49 |
+
('swigflags=', None, "additional flags to swig (use --swig-opts= instead)"), # obsolete
|
| 50 |
+
('force', 'f', "forcibly build everything (ignore file timestamps)"),
|
| 51 |
+
('inplace', 'i',
|
| 52 |
+
"ignore build-lib and put compiled extensions into the source " +
|
| 53 |
+
"directory alongside your pure Python modules"),
|
| 54 |
+
('verbose-cfg', None,
|
| 55 |
+
"change logging level from WARN to INFO which will show all " +
|
| 56 |
+
"compiler output")
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
boolean_options = ['force', 'inplace', 'verbose-cfg']
|
| 60 |
+
|
| 61 |
+
help_options = []
|
| 62 |
+
|
| 63 |
+
def initialize_options(self):
|
| 64 |
+
self.extensions = None
|
| 65 |
+
self.package = None
|
| 66 |
+
self.py_modules = None
|
| 67 |
+
self.py_modules_dict = None
|
| 68 |
+
self.build_src = None
|
| 69 |
+
self.build_lib = None
|
| 70 |
+
self.build_base = None
|
| 71 |
+
self.force = None
|
| 72 |
+
self.inplace = None
|
| 73 |
+
self.package_dir = None
|
| 74 |
+
self.f2pyflags = None # obsolete
|
| 75 |
+
self.f2py_opts = None
|
| 76 |
+
self.swigflags = None # obsolete
|
| 77 |
+
self.swig_opts = None
|
| 78 |
+
self.swig_cpp = None
|
| 79 |
+
self.swig = None
|
| 80 |
+
self.verbose_cfg = None
|
| 81 |
+
|
| 82 |
+
def finalize_options(self):
|
| 83 |
+
self.set_undefined_options('build',
|
| 84 |
+
('build_base', 'build_base'),
|
| 85 |
+
('build_lib', 'build_lib'),
|
| 86 |
+
('force', 'force'))
|
| 87 |
+
if self.package is None:
|
| 88 |
+
self.package = self.distribution.ext_package
|
| 89 |
+
self.extensions = self.distribution.ext_modules
|
| 90 |
+
self.libraries = self.distribution.libraries or []
|
| 91 |
+
self.py_modules = self.distribution.py_modules or []
|
| 92 |
+
self.data_files = self.distribution.data_files or []
|
| 93 |
+
|
| 94 |
+
if self.build_src is None:
|
| 95 |
+
plat_specifier = ".{}-{}.{}".format(get_platform(), *sys.version_info[:2])
|
| 96 |
+
self.build_src = os.path.join(self.build_base, 'src'+plat_specifier)
|
| 97 |
+
|
| 98 |
+
# py_modules_dict is used in build_py.find_package_modules
|
| 99 |
+
self.py_modules_dict = {}
|
| 100 |
+
|
| 101 |
+
if self.f2pyflags:
|
| 102 |
+
if self.f2py_opts:
|
| 103 |
+
log.warn('ignoring --f2pyflags as --f2py-opts already used')
|
| 104 |
+
else:
|
| 105 |
+
self.f2py_opts = self.f2pyflags
|
| 106 |
+
self.f2pyflags = None
|
| 107 |
+
if self.f2py_opts is None:
|
| 108 |
+
self.f2py_opts = []
|
| 109 |
+
else:
|
| 110 |
+
self.f2py_opts = shlex.split(self.f2py_opts)
|
| 111 |
+
|
| 112 |
+
if self.swigflags:
|
| 113 |
+
if self.swig_opts:
|
| 114 |
+
log.warn('ignoring --swigflags as --swig-opts already used')
|
| 115 |
+
else:
|
| 116 |
+
self.swig_opts = self.swigflags
|
| 117 |
+
self.swigflags = None
|
| 118 |
+
|
| 119 |
+
if self.swig_opts is None:
|
| 120 |
+
self.swig_opts = []
|
| 121 |
+
else:
|
| 122 |
+
self.swig_opts = shlex.split(self.swig_opts)
|
| 123 |
+
|
| 124 |
+
# use options from build_ext command
|
| 125 |
+
build_ext = self.get_finalized_command('build_ext')
|
| 126 |
+
if self.inplace is None:
|
| 127 |
+
self.inplace = build_ext.inplace
|
| 128 |
+
if self.swig_cpp is None:
|
| 129 |
+
self.swig_cpp = build_ext.swig_cpp
|
| 130 |
+
for c in ['swig', 'swig_opt']:
|
| 131 |
+
o = '--'+c.replace('_', '-')
|
| 132 |
+
v = getattr(build_ext, c, None)
|
| 133 |
+
if v:
|
| 134 |
+
if getattr(self, c):
|
| 135 |
+
log.warn('both build_src and build_ext define %s option' % (o))
|
| 136 |
+
else:
|
| 137 |
+
log.info('using "%s=%s" option from build_ext command' % (o, v))
|
| 138 |
+
setattr(self, c, v)
|
| 139 |
+
|
| 140 |
+
def run(self):
|
| 141 |
+
log.info("build_src")
|
| 142 |
+
if not (self.extensions or self.libraries):
|
| 143 |
+
return
|
| 144 |
+
self.build_sources()
|
| 145 |
+
|
| 146 |
+
def build_sources(self):
|
| 147 |
+
|
| 148 |
+
if self.inplace:
|
| 149 |
+
self.get_package_dir = \
|
| 150 |
+
self.get_finalized_command('build_py').get_package_dir
|
| 151 |
+
|
| 152 |
+
self.build_py_modules_sources()
|
| 153 |
+
|
| 154 |
+
for libname_info in self.libraries:
|
| 155 |
+
self.build_library_sources(*libname_info)
|
| 156 |
+
|
| 157 |
+
if self.extensions:
|
| 158 |
+
self.check_extensions_list(self.extensions)
|
| 159 |
+
|
| 160 |
+
for ext in self.extensions:
|
| 161 |
+
self.build_extension_sources(ext)
|
| 162 |
+
|
| 163 |
+
self.build_data_files_sources()
|
| 164 |
+
self.build_npy_pkg_config()
|
| 165 |
+
|
| 166 |
+
def build_data_files_sources(self):
|
| 167 |
+
if not self.data_files:
|
| 168 |
+
return
|
| 169 |
+
log.info('building data_files sources')
|
| 170 |
+
from numpy.distutils.misc_util import get_data_files
|
| 171 |
+
new_data_files = []
|
| 172 |
+
for data in self.data_files:
|
| 173 |
+
if isinstance(data, str):
|
| 174 |
+
new_data_files.append(data)
|
| 175 |
+
elif isinstance(data, tuple):
|
| 176 |
+
d, files = data
|
| 177 |
+
if self.inplace:
|
| 178 |
+
build_dir = self.get_package_dir('.'.join(d.split(os.sep)))
|
| 179 |
+
else:
|
| 180 |
+
build_dir = os.path.join(self.build_src, d)
|
| 181 |
+
funcs = [f for f in files if hasattr(f, '__call__')]
|
| 182 |
+
files = [f for f in files if not hasattr(f, '__call__')]
|
| 183 |
+
for f in funcs:
|
| 184 |
+
if f.__code__.co_argcount==1:
|
| 185 |
+
s = f(build_dir)
|
| 186 |
+
else:
|
| 187 |
+
s = f()
|
| 188 |
+
if s is not None:
|
| 189 |
+
if isinstance(s, list):
|
| 190 |
+
files.extend(s)
|
| 191 |
+
elif isinstance(s, str):
|
| 192 |
+
files.append(s)
|
| 193 |
+
else:
|
| 194 |
+
raise TypeError(repr(s))
|
| 195 |
+
filenames = get_data_files((d, files))
|
| 196 |
+
new_data_files.append((d, filenames))
|
| 197 |
+
else:
|
| 198 |
+
raise TypeError(repr(data))
|
| 199 |
+
self.data_files[:] = new_data_files
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def _build_npy_pkg_config(self, info, gd):
|
| 203 |
+
template, install_dir, subst_dict = info
|
| 204 |
+
template_dir = os.path.dirname(template)
|
| 205 |
+
for k, v in gd.items():
|
| 206 |
+
subst_dict[k] = v
|
| 207 |
+
|
| 208 |
+
if self.inplace == 1:
|
| 209 |
+
generated_dir = os.path.join(template_dir, install_dir)
|
| 210 |
+
else:
|
| 211 |
+
generated_dir = os.path.join(self.build_src, template_dir,
|
| 212 |
+
install_dir)
|
| 213 |
+
generated = os.path.basename(os.path.splitext(template)[0])
|
| 214 |
+
generated_path = os.path.join(generated_dir, generated)
|
| 215 |
+
if not os.path.exists(generated_dir):
|
| 216 |
+
os.makedirs(generated_dir)
|
| 217 |
+
|
| 218 |
+
subst_vars(generated_path, template, subst_dict)
|
| 219 |
+
|
| 220 |
+
# Where to install relatively to install prefix
|
| 221 |
+
full_install_dir = os.path.join(template_dir, install_dir)
|
| 222 |
+
return full_install_dir, generated_path
|
| 223 |
+
|
| 224 |
+
def build_npy_pkg_config(self):
|
| 225 |
+
log.info('build_src: building npy-pkg config files')
|
| 226 |
+
|
| 227 |
+
# XXX: another ugly workaround to circumvent distutils brain damage. We
|
| 228 |
+
# need the install prefix here, but finalizing the options of the
|
| 229 |
+
# install command when only building sources cause error. Instead, we
|
| 230 |
+
# copy the install command instance, and finalize the copy so that it
|
| 231 |
+
# does not disrupt how distutils want to do things when with the
|
| 232 |
+
# original install command instance.
|
| 233 |
+
install_cmd = copy.copy(get_cmd('install'))
|
| 234 |
+
if not install_cmd.finalized == 1:
|
| 235 |
+
install_cmd.finalize_options()
|
| 236 |
+
build_npkg = False
|
| 237 |
+
if self.inplace == 1:
|
| 238 |
+
top_prefix = '.'
|
| 239 |
+
build_npkg = True
|
| 240 |
+
elif hasattr(install_cmd, 'install_libbase'):
|
| 241 |
+
top_prefix = install_cmd.install_libbase
|
| 242 |
+
build_npkg = True
|
| 243 |
+
|
| 244 |
+
if build_npkg:
|
| 245 |
+
for pkg, infos in self.distribution.installed_pkg_config.items():
|
| 246 |
+
pkg_path = self.distribution.package_dir[pkg]
|
| 247 |
+
prefix = os.path.join(os.path.abspath(top_prefix), pkg_path)
|
| 248 |
+
d = {'prefix': prefix}
|
| 249 |
+
for info in infos:
|
| 250 |
+
install_dir, generated = self._build_npy_pkg_config(info, d)
|
| 251 |
+
self.distribution.data_files.append((install_dir,
|
| 252 |
+
[generated]))
|
| 253 |
+
|
| 254 |
+
def build_py_modules_sources(self):
|
| 255 |
+
if not self.py_modules:
|
| 256 |
+
return
|
| 257 |
+
log.info('building py_modules sources')
|
| 258 |
+
new_py_modules = []
|
| 259 |
+
for source in self.py_modules:
|
| 260 |
+
if is_sequence(source) and len(source)==3:
|
| 261 |
+
package, module_base, source = source
|
| 262 |
+
if self.inplace:
|
| 263 |
+
build_dir = self.get_package_dir(package)
|
| 264 |
+
else:
|
| 265 |
+
build_dir = os.path.join(self.build_src,
|
| 266 |
+
os.path.join(*package.split('.')))
|
| 267 |
+
if hasattr(source, '__call__'):
|
| 268 |
+
target = os.path.join(build_dir, module_base + '.py')
|
| 269 |
+
source = source(target)
|
| 270 |
+
if source is None:
|
| 271 |
+
continue
|
| 272 |
+
modules = [(package, module_base, source)]
|
| 273 |
+
if package not in self.py_modules_dict:
|
| 274 |
+
self.py_modules_dict[package] = []
|
| 275 |
+
self.py_modules_dict[package] += modules
|
| 276 |
+
else:
|
| 277 |
+
new_py_modules.append(source)
|
| 278 |
+
self.py_modules[:] = new_py_modules
|
| 279 |
+
|
| 280 |
+
def build_library_sources(self, lib_name, build_info):
|
| 281 |
+
sources = list(build_info.get('sources', []))
|
| 282 |
+
|
| 283 |
+
if not sources:
|
| 284 |
+
return
|
| 285 |
+
|
| 286 |
+
log.info('building library "%s" sources' % (lib_name))
|
| 287 |
+
|
| 288 |
+
sources = self.generate_sources(sources, (lib_name, build_info))
|
| 289 |
+
|
| 290 |
+
sources = self.template_sources(sources, (lib_name, build_info))
|
| 291 |
+
|
| 292 |
+
sources, h_files = self.filter_h_files(sources)
|
| 293 |
+
|
| 294 |
+
if h_files:
|
| 295 |
+
log.info('%s - nothing done with h_files = %s',
|
| 296 |
+
self.package, h_files)
|
| 297 |
+
|
| 298 |
+
#for f in h_files:
|
| 299 |
+
# self.distribution.headers.append((lib_name,f))
|
| 300 |
+
|
| 301 |
+
build_info['sources'] = sources
|
| 302 |
+
return
|
| 303 |
+
|
| 304 |
+
def build_extension_sources(self, ext):
|
| 305 |
+
|
| 306 |
+
sources = list(ext.sources)
|
| 307 |
+
|
| 308 |
+
log.info('building extension "%s" sources' % (ext.name))
|
| 309 |
+
|
| 310 |
+
fullname = self.get_ext_fullname(ext.name)
|
| 311 |
+
|
| 312 |
+
modpath = fullname.split('.')
|
| 313 |
+
package = '.'.join(modpath[0:-1])
|
| 314 |
+
|
| 315 |
+
if self.inplace:
|
| 316 |
+
self.ext_target_dir = self.get_package_dir(package)
|
| 317 |
+
|
| 318 |
+
sources = self.generate_sources(sources, ext)
|
| 319 |
+
sources = self.template_sources(sources, ext)
|
| 320 |
+
sources = self.swig_sources(sources, ext)
|
| 321 |
+
sources = self.f2py_sources(sources, ext)
|
| 322 |
+
sources = self.pyrex_sources(sources, ext)
|
| 323 |
+
|
| 324 |
+
sources, py_files = self.filter_py_files(sources)
|
| 325 |
+
|
| 326 |
+
if package not in self.py_modules_dict:
|
| 327 |
+
self.py_modules_dict[package] = []
|
| 328 |
+
modules = []
|
| 329 |
+
for f in py_files:
|
| 330 |
+
module = os.path.splitext(os.path.basename(f))[0]
|
| 331 |
+
modules.append((package, module, f))
|
| 332 |
+
self.py_modules_dict[package] += modules
|
| 333 |
+
|
| 334 |
+
sources, h_files = self.filter_h_files(sources)
|
| 335 |
+
|
| 336 |
+
if h_files:
|
| 337 |
+
log.info('%s - nothing done with h_files = %s',
|
| 338 |
+
package, h_files)
|
| 339 |
+
#for f in h_files:
|
| 340 |
+
# self.distribution.headers.append((package,f))
|
| 341 |
+
|
| 342 |
+
ext.sources = sources
|
| 343 |
+
|
| 344 |
+
def generate_sources(self, sources, extension):
|
| 345 |
+
new_sources = []
|
| 346 |
+
func_sources = []
|
| 347 |
+
for source in sources:
|
| 348 |
+
if is_string(source):
|
| 349 |
+
new_sources.append(source)
|
| 350 |
+
else:
|
| 351 |
+
func_sources.append(source)
|
| 352 |
+
if not func_sources:
|
| 353 |
+
return new_sources
|
| 354 |
+
if self.inplace and not is_sequence(extension):
|
| 355 |
+
build_dir = self.ext_target_dir
|
| 356 |
+
else:
|
| 357 |
+
if is_sequence(extension):
|
| 358 |
+
name = extension[0]
|
| 359 |
+
# if 'include_dirs' not in extension[1]:
|
| 360 |
+
# extension[1]['include_dirs'] = []
|
| 361 |
+
# incl_dirs = extension[1]['include_dirs']
|
| 362 |
+
else:
|
| 363 |
+
name = extension.name
|
| 364 |
+
# incl_dirs = extension.include_dirs
|
| 365 |
+
#if self.build_src not in incl_dirs:
|
| 366 |
+
# incl_dirs.append(self.build_src)
|
| 367 |
+
build_dir = os.path.join(*([self.build_src]
|
| 368 |
+
+name.split('.')[:-1]))
|
| 369 |
+
self.mkpath(build_dir)
|
| 370 |
+
|
| 371 |
+
if self.verbose_cfg:
|
| 372 |
+
new_level = log.INFO
|
| 373 |
+
else:
|
| 374 |
+
new_level = log.WARN
|
| 375 |
+
old_level = log.set_threshold(new_level)
|
| 376 |
+
|
| 377 |
+
for func in func_sources:
|
| 378 |
+
source = func(extension, build_dir)
|
| 379 |
+
if not source:
|
| 380 |
+
continue
|
| 381 |
+
if is_sequence(source):
|
| 382 |
+
[log.info(" adding '%s' to sources." % (s,)) for s in source]
|
| 383 |
+
new_sources.extend(source)
|
| 384 |
+
else:
|
| 385 |
+
log.info(" adding '%s' to sources." % (source,))
|
| 386 |
+
new_sources.append(source)
|
| 387 |
+
log.set_threshold(old_level)
|
| 388 |
+
return new_sources
|
| 389 |
+
|
| 390 |
+
def filter_py_files(self, sources):
|
| 391 |
+
return self.filter_files(sources, ['.py'])
|
| 392 |
+
|
| 393 |
+
def filter_h_files(self, sources):
|
| 394 |
+
return self.filter_files(sources, ['.h', '.hpp', '.inc'])
|
| 395 |
+
|
| 396 |
+
def filter_files(self, sources, exts = []):
|
| 397 |
+
new_sources = []
|
| 398 |
+
files = []
|
| 399 |
+
for source in sources:
|
| 400 |
+
(base, ext) = os.path.splitext(source)
|
| 401 |
+
if ext in exts:
|
| 402 |
+
files.append(source)
|
| 403 |
+
else:
|
| 404 |
+
new_sources.append(source)
|
| 405 |
+
return new_sources, files
|
| 406 |
+
|
| 407 |
+
def template_sources(self, sources, extension):
|
| 408 |
+
new_sources = []
|
| 409 |
+
if is_sequence(extension):
|
| 410 |
+
depends = extension[1].get('depends')
|
| 411 |
+
include_dirs = extension[1].get('include_dirs')
|
| 412 |
+
else:
|
| 413 |
+
depends = extension.depends
|
| 414 |
+
include_dirs = extension.include_dirs
|
| 415 |
+
for source in sources:
|
| 416 |
+
(base, ext) = os.path.splitext(source)
|
| 417 |
+
if ext == '.src': # Template file
|
| 418 |
+
if self.inplace:
|
| 419 |
+
target_dir = os.path.dirname(base)
|
| 420 |
+
else:
|
| 421 |
+
target_dir = appendpath(self.build_src, os.path.dirname(base))
|
| 422 |
+
self.mkpath(target_dir)
|
| 423 |
+
target_file = os.path.join(target_dir, os.path.basename(base))
|
| 424 |
+
if (self.force or newer_group([source] + depends, target_file)):
|
| 425 |
+
if _f_pyf_ext_match(base):
|
| 426 |
+
log.info("from_template:> %s" % (target_file))
|
| 427 |
+
outstr = process_f_file(source)
|
| 428 |
+
else:
|
| 429 |
+
log.info("conv_template:> %s" % (target_file))
|
| 430 |
+
outstr = process_c_file(source)
|
| 431 |
+
with open(target_file, 'w') as fid:
|
| 432 |
+
fid.write(outstr)
|
| 433 |
+
if _header_ext_match(target_file):
|
| 434 |
+
d = os.path.dirname(target_file)
|
| 435 |
+
if d not in include_dirs:
|
| 436 |
+
log.info(" adding '%s' to include_dirs." % (d))
|
| 437 |
+
include_dirs.append(d)
|
| 438 |
+
new_sources.append(target_file)
|
| 439 |
+
else:
|
| 440 |
+
new_sources.append(source)
|
| 441 |
+
return new_sources
|
| 442 |
+
|
| 443 |
+
def pyrex_sources(self, sources, extension):
|
| 444 |
+
"""Pyrex not supported; this remains for Cython support (see below)"""
|
| 445 |
+
new_sources = []
|
| 446 |
+
ext_name = extension.name.split('.')[-1]
|
| 447 |
+
for source in sources:
|
| 448 |
+
(base, ext) = os.path.splitext(source)
|
| 449 |
+
if ext == '.pyx':
|
| 450 |
+
target_file = self.generate_a_pyrex_source(base, ext_name,
|
| 451 |
+
source,
|
| 452 |
+
extension)
|
| 453 |
+
new_sources.append(target_file)
|
| 454 |
+
else:
|
| 455 |
+
new_sources.append(source)
|
| 456 |
+
return new_sources
|
| 457 |
+
|
| 458 |
+
def generate_a_pyrex_source(self, base, ext_name, source, extension):
|
| 459 |
+
"""Pyrex is not supported, but some projects monkeypatch this method.
|
| 460 |
+
|
| 461 |
+
That allows compiling Cython code, see gh-6955.
|
| 462 |
+
This method will remain here for compatibility reasons.
|
| 463 |
+
"""
|
| 464 |
+
return []
|
| 465 |
+
|
| 466 |
+
def f2py_sources(self, sources, extension):
|
| 467 |
+
new_sources = []
|
| 468 |
+
f2py_sources = []
|
| 469 |
+
f_sources = []
|
| 470 |
+
f2py_targets = {}
|
| 471 |
+
target_dirs = []
|
| 472 |
+
ext_name = extension.name.split('.')[-1]
|
| 473 |
+
skip_f2py = 0
|
| 474 |
+
|
| 475 |
+
for source in sources:
|
| 476 |
+
(base, ext) = os.path.splitext(source)
|
| 477 |
+
if ext == '.pyf': # F2PY interface file
|
| 478 |
+
if self.inplace:
|
| 479 |
+
target_dir = os.path.dirname(base)
|
| 480 |
+
else:
|
| 481 |
+
target_dir = appendpath(self.build_src, os.path.dirname(base))
|
| 482 |
+
if os.path.isfile(source):
|
| 483 |
+
name = get_f2py_modulename(source)
|
| 484 |
+
if name != ext_name:
|
| 485 |
+
raise DistutilsSetupError('mismatch of extension names: %s '
|
| 486 |
+
'provides %r but expected %r' % (
|
| 487 |
+
source, name, ext_name))
|
| 488 |
+
target_file = os.path.join(target_dir, name+'module.c')
|
| 489 |
+
else:
|
| 490 |
+
log.debug(' source %s does not exist: skipping f2py\'ing.' \
|
| 491 |
+
% (source))
|
| 492 |
+
name = ext_name
|
| 493 |
+
skip_f2py = 1
|
| 494 |
+
target_file = os.path.join(target_dir, name+'module.c')
|
| 495 |
+
if not os.path.isfile(target_file):
|
| 496 |
+
log.warn(' target %s does not exist:\n '\
|
| 497 |
+
'Assuming %smodule.c was generated with '\
|
| 498 |
+
'"build_src --inplace" command.' \
|
| 499 |
+
% (target_file, name))
|
| 500 |
+
target_dir = os.path.dirname(base)
|
| 501 |
+
target_file = os.path.join(target_dir, name+'module.c')
|
| 502 |
+
if not os.path.isfile(target_file):
|
| 503 |
+
raise DistutilsSetupError("%r missing" % (target_file,))
|
| 504 |
+
log.info(' Yes! Using %r as up-to-date target.' \
|
| 505 |
+
% (target_file))
|
| 506 |
+
target_dirs.append(target_dir)
|
| 507 |
+
f2py_sources.append(source)
|
| 508 |
+
f2py_targets[source] = target_file
|
| 509 |
+
new_sources.append(target_file)
|
| 510 |
+
elif fortran_ext_match(ext):
|
| 511 |
+
f_sources.append(source)
|
| 512 |
+
else:
|
| 513 |
+
new_sources.append(source)
|
| 514 |
+
|
| 515 |
+
if not (f2py_sources or f_sources):
|
| 516 |
+
return new_sources
|
| 517 |
+
|
| 518 |
+
for d in target_dirs:
|
| 519 |
+
self.mkpath(d)
|
| 520 |
+
|
| 521 |
+
f2py_options = extension.f2py_options + self.f2py_opts
|
| 522 |
+
|
| 523 |
+
if self.distribution.libraries:
|
| 524 |
+
for name, build_info in self.distribution.libraries:
|
| 525 |
+
if name in extension.libraries:
|
| 526 |
+
f2py_options.extend(build_info.get('f2py_options', []))
|
| 527 |
+
|
| 528 |
+
log.info("f2py options: %s" % (f2py_options))
|
| 529 |
+
|
| 530 |
+
if f2py_sources:
|
| 531 |
+
if len(f2py_sources) != 1:
|
| 532 |
+
raise DistutilsSetupError(
|
| 533 |
+
'only one .pyf file is allowed per extension module but got'\
|
| 534 |
+
' more: %r' % (f2py_sources,))
|
| 535 |
+
source = f2py_sources[0]
|
| 536 |
+
target_file = f2py_targets[source]
|
| 537 |
+
target_dir = os.path.dirname(target_file) or '.'
|
| 538 |
+
depends = [source] + extension.depends
|
| 539 |
+
if (self.force or newer_group(depends, target_file, 'newer')) \
|
| 540 |
+
and not skip_f2py:
|
| 541 |
+
log.info("f2py: %s" % (source))
|
| 542 |
+
from numpy.f2py import f2py2e
|
| 543 |
+
f2py2e.run_main(f2py_options
|
| 544 |
+
+ ['--build-dir', target_dir, source])
|
| 545 |
+
else:
|
| 546 |
+
log.debug(" skipping '%s' f2py interface (up-to-date)" % (source))
|
| 547 |
+
else:
|
| 548 |
+
#XXX TODO: --inplace support for sdist command
|
| 549 |
+
if is_sequence(extension):
|
| 550 |
+
name = extension[0]
|
| 551 |
+
else: name = extension.name
|
| 552 |
+
target_dir = os.path.join(*([self.build_src]
|
| 553 |
+
+name.split('.')[:-1]))
|
| 554 |
+
target_file = os.path.join(target_dir, ext_name + 'module.c')
|
| 555 |
+
new_sources.append(target_file)
|
| 556 |
+
depends = f_sources + extension.depends
|
| 557 |
+
if (self.force or newer_group(depends, target_file, 'newer')) \
|
| 558 |
+
and not skip_f2py:
|
| 559 |
+
log.info("f2py:> %s" % (target_file))
|
| 560 |
+
self.mkpath(target_dir)
|
| 561 |
+
from numpy.f2py import f2py2e
|
| 562 |
+
f2py2e.run_main(f2py_options + ['--lower',
|
| 563 |
+
'--build-dir', target_dir]+\
|
| 564 |
+
['-m', ext_name]+f_sources)
|
| 565 |
+
else:
|
| 566 |
+
log.debug(" skipping f2py fortran files for '%s' (up-to-date)"\
|
| 567 |
+
% (target_file))
|
| 568 |
+
|
| 569 |
+
if not os.path.isfile(target_file):
|
| 570 |
+
raise DistutilsError("f2py target file %r not generated" % (target_file,))
|
| 571 |
+
|
| 572 |
+
build_dir = os.path.join(self.build_src, target_dir)
|
| 573 |
+
target_c = os.path.join(build_dir, 'fortranobject.c')
|
| 574 |
+
target_h = os.path.join(build_dir, 'fortranobject.h')
|
| 575 |
+
log.info(" adding '%s' to sources." % (target_c))
|
| 576 |
+
new_sources.append(target_c)
|
| 577 |
+
if build_dir not in extension.include_dirs:
|
| 578 |
+
log.info(" adding '%s' to include_dirs." % (build_dir))
|
| 579 |
+
extension.include_dirs.append(build_dir)
|
| 580 |
+
|
| 581 |
+
if not skip_f2py:
|
| 582 |
+
import numpy.f2py
|
| 583 |
+
d = os.path.dirname(numpy.f2py.__file__)
|
| 584 |
+
source_c = os.path.join(d, 'src', 'fortranobject.c')
|
| 585 |
+
source_h = os.path.join(d, 'src', 'fortranobject.h')
|
| 586 |
+
if newer(source_c, target_c) or newer(source_h, target_h):
|
| 587 |
+
self.mkpath(os.path.dirname(target_c))
|
| 588 |
+
self.copy_file(source_c, target_c)
|
| 589 |
+
self.copy_file(source_h, target_h)
|
| 590 |
+
else:
|
| 591 |
+
if not os.path.isfile(target_c):
|
| 592 |
+
raise DistutilsSetupError("f2py target_c file %r not found" % (target_c,))
|
| 593 |
+
if not os.path.isfile(target_h):
|
| 594 |
+
raise DistutilsSetupError("f2py target_h file %r not found" % (target_h,))
|
| 595 |
+
|
| 596 |
+
for name_ext in ['-f2pywrappers.f', '-f2pywrappers2.f90']:
|
| 597 |
+
filename = os.path.join(target_dir, ext_name + name_ext)
|
| 598 |
+
if os.path.isfile(filename):
|
| 599 |
+
log.info(" adding '%s' to sources." % (filename))
|
| 600 |
+
f_sources.append(filename)
|
| 601 |
+
|
| 602 |
+
return new_sources + f_sources
|
| 603 |
+
|
| 604 |
+
def swig_sources(self, sources, extension):
|
| 605 |
+
# Assuming SWIG 1.3.14 or later. See compatibility note in
|
| 606 |
+
# http://www.swig.org/Doc1.3/Python.html#Python_nn6
|
| 607 |
+
|
| 608 |
+
new_sources = []
|
| 609 |
+
swig_sources = []
|
| 610 |
+
swig_targets = {}
|
| 611 |
+
target_dirs = []
|
| 612 |
+
py_files = [] # swig generated .py files
|
| 613 |
+
target_ext = '.c'
|
| 614 |
+
if '-c++' in extension.swig_opts:
|
| 615 |
+
typ = 'c++'
|
| 616 |
+
is_cpp = True
|
| 617 |
+
extension.swig_opts.remove('-c++')
|
| 618 |
+
elif self.swig_cpp:
|
| 619 |
+
typ = 'c++'
|
| 620 |
+
is_cpp = True
|
| 621 |
+
else:
|
| 622 |
+
typ = None
|
| 623 |
+
is_cpp = False
|
| 624 |
+
skip_swig = 0
|
| 625 |
+
ext_name = extension.name.split('.')[-1]
|
| 626 |
+
|
| 627 |
+
for source in sources:
|
| 628 |
+
(base, ext) = os.path.splitext(source)
|
| 629 |
+
if ext == '.i': # SWIG interface file
|
| 630 |
+
# the code below assumes that the sources list
|
| 631 |
+
# contains not more than one .i SWIG interface file
|
| 632 |
+
if self.inplace:
|
| 633 |
+
target_dir = os.path.dirname(base)
|
| 634 |
+
py_target_dir = self.ext_target_dir
|
| 635 |
+
else:
|
| 636 |
+
target_dir = appendpath(self.build_src, os.path.dirname(base))
|
| 637 |
+
py_target_dir = target_dir
|
| 638 |
+
if os.path.isfile(source):
|
| 639 |
+
name = get_swig_modulename(source)
|
| 640 |
+
if name != ext_name[1:]:
|
| 641 |
+
raise DistutilsSetupError(
|
| 642 |
+
'mismatch of extension names: %s provides %r'
|
| 643 |
+
' but expected %r' % (source, name, ext_name[1:]))
|
| 644 |
+
if typ is None:
|
| 645 |
+
typ = get_swig_target(source)
|
| 646 |
+
is_cpp = typ=='c++'
|
| 647 |
+
else:
|
| 648 |
+
typ2 = get_swig_target(source)
|
| 649 |
+
if typ2 is None:
|
| 650 |
+
log.warn('source %r does not define swig target, assuming %s swig target' \
|
| 651 |
+
% (source, typ))
|
| 652 |
+
elif typ!=typ2:
|
| 653 |
+
log.warn('expected %r but source %r defines %r swig target' \
|
| 654 |
+
% (typ, source, typ2))
|
| 655 |
+
if typ2=='c++':
|
| 656 |
+
log.warn('resetting swig target to c++ (some targets may have .c extension)')
|
| 657 |
+
is_cpp = True
|
| 658 |
+
else:
|
| 659 |
+
log.warn('assuming that %r has c++ swig target' % (source))
|
| 660 |
+
if is_cpp:
|
| 661 |
+
target_ext = '.cpp'
|
| 662 |
+
target_file = os.path.join(target_dir, '%s_wrap%s' \
|
| 663 |
+
% (name, target_ext))
|
| 664 |
+
else:
|
| 665 |
+
log.warn(' source %s does not exist: skipping swig\'ing.' \
|
| 666 |
+
% (source))
|
| 667 |
+
name = ext_name[1:]
|
| 668 |
+
skip_swig = 1
|
| 669 |
+
target_file = _find_swig_target(target_dir, name)
|
| 670 |
+
if not os.path.isfile(target_file):
|
| 671 |
+
log.warn(' target %s does not exist:\n '\
|
| 672 |
+
'Assuming %s_wrap.{c,cpp} was generated with '\
|
| 673 |
+
'"build_src --inplace" command.' \
|
| 674 |
+
% (target_file, name))
|
| 675 |
+
target_dir = os.path.dirname(base)
|
| 676 |
+
target_file = _find_swig_target(target_dir, name)
|
| 677 |
+
if not os.path.isfile(target_file):
|
| 678 |
+
raise DistutilsSetupError("%r missing" % (target_file,))
|
| 679 |
+
log.warn(' Yes! Using %r as up-to-date target.' \
|
| 680 |
+
% (target_file))
|
| 681 |
+
target_dirs.append(target_dir)
|
| 682 |
+
new_sources.append(target_file)
|
| 683 |
+
py_files.append(os.path.join(py_target_dir, name+'.py'))
|
| 684 |
+
swig_sources.append(source)
|
| 685 |
+
swig_targets[source] = new_sources[-1]
|
| 686 |
+
else:
|
| 687 |
+
new_sources.append(source)
|
| 688 |
+
|
| 689 |
+
if not swig_sources:
|
| 690 |
+
return new_sources
|
| 691 |
+
|
| 692 |
+
if skip_swig:
|
| 693 |
+
return new_sources + py_files
|
| 694 |
+
|
| 695 |
+
for d in target_dirs:
|
| 696 |
+
self.mkpath(d)
|
| 697 |
+
|
| 698 |
+
swig = self.swig or self.find_swig()
|
| 699 |
+
swig_cmd = [swig, "-python"] + extension.swig_opts
|
| 700 |
+
if is_cpp:
|
| 701 |
+
swig_cmd.append('-c++')
|
| 702 |
+
for d in extension.include_dirs:
|
| 703 |
+
swig_cmd.append('-I'+d)
|
| 704 |
+
for source in swig_sources:
|
| 705 |
+
target = swig_targets[source]
|
| 706 |
+
depends = [source] + extension.depends
|
| 707 |
+
if self.force or newer_group(depends, target, 'newer'):
|
| 708 |
+
log.info("%s: %s" % (os.path.basename(swig) \
|
| 709 |
+
+ (is_cpp and '++' or ''), source))
|
| 710 |
+
self.spawn(swig_cmd + self.swig_opts \
|
| 711 |
+
+ ["-o", target, '-outdir', py_target_dir, source])
|
| 712 |
+
else:
|
| 713 |
+
log.debug(" skipping '%s' swig interface (up-to-date)" \
|
| 714 |
+
% (source))
|
| 715 |
+
|
| 716 |
+
return new_sources + py_files
|
| 717 |
+
|
| 718 |
+
_f_pyf_ext_match = re.compile(r'.*\.(f90|f95|f77|for|ftn|f|pyf)\Z', re.I).match
|
| 719 |
+
_header_ext_match = re.compile(r'.*\.(inc|h|hpp)\Z', re.I).match
|
| 720 |
+
|
| 721 |
+
#### SWIG related auxiliary functions ####
|
| 722 |
+
_swig_module_name_match = re.compile(r'\s*%module\s*(.*\(\s*package\s*=\s*"(?P<package>[\w_]+)".*\)|)\s*(?P<name>[\w_]+)',
|
| 723 |
+
re.I).match
|
| 724 |
+
_has_c_header = re.compile(r'-\*-\s*c\s*-\*-', re.I).search
|
| 725 |
+
_has_cpp_header = re.compile(r'-\*-\s*c\+\+\s*-\*-', re.I).search
|
| 726 |
+
|
| 727 |
+
def get_swig_target(source):
|
| 728 |
+
with open(source) as f:
|
| 729 |
+
result = None
|
| 730 |
+
line = f.readline()
|
| 731 |
+
if _has_cpp_header(line):
|
| 732 |
+
result = 'c++'
|
| 733 |
+
if _has_c_header(line):
|
| 734 |
+
result = 'c'
|
| 735 |
+
return result
|
| 736 |
+
|
| 737 |
+
def get_swig_modulename(source):
|
| 738 |
+
with open(source) as f:
|
| 739 |
+
name = None
|
| 740 |
+
for line in f:
|
| 741 |
+
m = _swig_module_name_match(line)
|
| 742 |
+
if m:
|
| 743 |
+
name = m.group('name')
|
| 744 |
+
break
|
| 745 |
+
return name
|
| 746 |
+
|
| 747 |
+
def _find_swig_target(target_dir, name):
|
| 748 |
+
for ext in ['.cpp', '.c']:
|
| 749 |
+
target = os.path.join(target_dir, '%s_wrap%s' % (name, ext))
|
| 750 |
+
if os.path.isfile(target):
|
| 751 |
+
break
|
| 752 |
+
return target
|
| 753 |
+
|
| 754 |
+
#### F2PY related auxiliary functions ####
|
| 755 |
+
|
| 756 |
+
_f2py_module_name_match = re.compile(r'\s*python\s*module\s*(?P<name>[\w_]+)',
|
| 757 |
+
re.I).match
|
| 758 |
+
_f2py_user_module_name_match = re.compile(r'\s*python\s*module\s*(?P<name>[\w_]*?'
|
| 759 |
+
r'__user__[\w_]*)', re.I).match
|
| 760 |
+
|
| 761 |
+
def get_f2py_modulename(source):
|
| 762 |
+
name = None
|
| 763 |
+
with open(source) as f:
|
| 764 |
+
for line in f:
|
| 765 |
+
m = _f2py_module_name_match(line)
|
| 766 |
+
if m:
|
| 767 |
+
if _f2py_user_module_name_match(line): # skip *__user__* names
|
| 768 |
+
continue
|
| 769 |
+
name = m.group('name')
|
| 770 |
+
break
|
| 771 |
+
return name
|
| 772 |
+
|
| 773 |
+
##########################################
|
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/config.py
ADDED
|
@@ -0,0 +1,516 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Added Fortran compiler support to config. Currently useful only for
|
| 2 |
+
# try_compile call. try_run works but is untested for most of Fortran
|
| 3 |
+
# compilers (they must define linker_exe first).
|
| 4 |
+
# Pearu Peterson
|
| 5 |
+
import os
|
| 6 |
+
import signal
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
import textwrap
|
| 10 |
+
import warnings
|
| 11 |
+
|
| 12 |
+
from distutils.command.config import config as old_config
|
| 13 |
+
from distutils.command.config import LANG_EXT
|
| 14 |
+
from distutils import log
|
| 15 |
+
from distutils.file_util import copy_file
|
| 16 |
+
from distutils.ccompiler import CompileError, LinkError
|
| 17 |
+
import distutils
|
| 18 |
+
from numpy.distutils.exec_command import filepath_from_subprocess_output
|
| 19 |
+
from numpy.distutils.mingw32ccompiler import generate_manifest
|
| 20 |
+
from numpy.distutils.command.autodist import (check_gcc_function_attribute,
|
| 21 |
+
check_gcc_function_attribute_with_intrinsics,
|
| 22 |
+
check_gcc_variable_attribute,
|
| 23 |
+
check_gcc_version_at_least,
|
| 24 |
+
check_inline,
|
| 25 |
+
check_restrict,
|
| 26 |
+
check_compiler_gcc)
|
| 27 |
+
|
| 28 |
+
LANG_EXT['f77'] = '.f'
|
| 29 |
+
LANG_EXT['f90'] = '.f90'
|
| 30 |
+
|
| 31 |
+
class config(old_config):
|
| 32 |
+
old_config.user_options += [
|
| 33 |
+
('fcompiler=', None, "specify the Fortran compiler type"),
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
def initialize_options(self):
|
| 37 |
+
self.fcompiler = None
|
| 38 |
+
old_config.initialize_options(self)
|
| 39 |
+
|
| 40 |
+
def _check_compiler (self):
|
| 41 |
+
old_config._check_compiler(self)
|
| 42 |
+
from numpy.distutils.fcompiler import FCompiler, new_fcompiler
|
| 43 |
+
|
| 44 |
+
if sys.platform == 'win32' and (self.compiler.compiler_type in
|
| 45 |
+
('msvc', 'intelw', 'intelemw')):
|
| 46 |
+
# XXX: hack to circumvent a python 2.6 bug with msvc9compiler:
|
| 47 |
+
# initialize call query_vcvarsall, which throws an OSError, and
|
| 48 |
+
# causes an error along the way without much information. We try to
|
| 49 |
+
# catch it here, hoping it is early enough, and print a helpful
|
| 50 |
+
# message instead of Error: None.
|
| 51 |
+
if not self.compiler.initialized:
|
| 52 |
+
try:
|
| 53 |
+
self.compiler.initialize()
|
| 54 |
+
except OSError as e:
|
| 55 |
+
msg = textwrap.dedent("""\
|
| 56 |
+
Could not initialize compiler instance: do you have Visual Studio
|
| 57 |
+
installed? If you are trying to build with MinGW, please use "python setup.py
|
| 58 |
+
build -c mingw32" instead. If you have Visual Studio installed, check it is
|
| 59 |
+
correctly installed, and the right version (VS 2015 as of this writing).
|
| 60 |
+
|
| 61 |
+
Original exception was: %s, and the Compiler class was %s
|
| 62 |
+
============================================================================""") \
|
| 63 |
+
% (e, self.compiler.__class__.__name__)
|
| 64 |
+
print(textwrap.dedent("""\
|
| 65 |
+
============================================================================"""))
|
| 66 |
+
raise distutils.errors.DistutilsPlatformError(msg) from e
|
| 67 |
+
|
| 68 |
+
# After MSVC is initialized, add an explicit /MANIFEST to linker
|
| 69 |
+
# flags. See issues gh-4245 and gh-4101 for details. Also
|
| 70 |
+
# relevant are issues 4431 and 16296 on the Python bug tracker.
|
| 71 |
+
from distutils import msvc9compiler
|
| 72 |
+
if msvc9compiler.get_build_version() >= 10:
|
| 73 |
+
for ldflags in [self.compiler.ldflags_shared,
|
| 74 |
+
self.compiler.ldflags_shared_debug]:
|
| 75 |
+
if '/MANIFEST' not in ldflags:
|
| 76 |
+
ldflags.append('/MANIFEST')
|
| 77 |
+
|
| 78 |
+
if not isinstance(self.fcompiler, FCompiler):
|
| 79 |
+
self.fcompiler = new_fcompiler(compiler=self.fcompiler,
|
| 80 |
+
dry_run=self.dry_run, force=1,
|
| 81 |
+
c_compiler=self.compiler)
|
| 82 |
+
if self.fcompiler is not None:
|
| 83 |
+
self.fcompiler.customize(self.distribution)
|
| 84 |
+
if self.fcompiler.get_version():
|
| 85 |
+
self.fcompiler.customize_cmd(self)
|
| 86 |
+
self.fcompiler.show_customization()
|
| 87 |
+
|
| 88 |
+
def _wrap_method(self, mth, lang, args):
|
| 89 |
+
from distutils.ccompiler import CompileError
|
| 90 |
+
from distutils.errors import DistutilsExecError
|
| 91 |
+
save_compiler = self.compiler
|
| 92 |
+
if lang in ['f77', 'f90']:
|
| 93 |
+
self.compiler = self.fcompiler
|
| 94 |
+
if self.compiler is None:
|
| 95 |
+
raise CompileError('%s compiler is not set' % (lang,))
|
| 96 |
+
try:
|
| 97 |
+
ret = mth(*((self,)+args))
|
| 98 |
+
except (DistutilsExecError, CompileError) as e:
|
| 99 |
+
self.compiler = save_compiler
|
| 100 |
+
raise CompileError from e
|
| 101 |
+
self.compiler = save_compiler
|
| 102 |
+
return ret
|
| 103 |
+
|
| 104 |
+
def _compile (self, body, headers, include_dirs, lang):
|
| 105 |
+
src, obj = self._wrap_method(old_config._compile, lang,
|
| 106 |
+
(body, headers, include_dirs, lang))
|
| 107 |
+
# _compile in unixcompiler.py sometimes creates .d dependency files.
|
| 108 |
+
# Clean them up.
|
| 109 |
+
self.temp_files.append(obj + '.d')
|
| 110 |
+
return src, obj
|
| 111 |
+
|
| 112 |
+
def _link (self, body,
|
| 113 |
+
headers, include_dirs,
|
| 114 |
+
libraries, library_dirs, lang):
|
| 115 |
+
if self.compiler.compiler_type=='msvc':
|
| 116 |
+
libraries = (libraries or [])[:]
|
| 117 |
+
library_dirs = (library_dirs or [])[:]
|
| 118 |
+
if lang in ['f77', 'f90']:
|
| 119 |
+
lang = 'c' # always use system linker when using MSVC compiler
|
| 120 |
+
if self.fcompiler:
|
| 121 |
+
for d in self.fcompiler.library_dirs or []:
|
| 122 |
+
# correct path when compiling in Cygwin but with
|
| 123 |
+
# normal Win Python
|
| 124 |
+
if d.startswith('/usr/lib'):
|
| 125 |
+
try:
|
| 126 |
+
d = subprocess.check_output(['cygpath',
|
| 127 |
+
'-w', d])
|
| 128 |
+
except (OSError, subprocess.CalledProcessError):
|
| 129 |
+
pass
|
| 130 |
+
else:
|
| 131 |
+
d = filepath_from_subprocess_output(d)
|
| 132 |
+
library_dirs.append(d)
|
| 133 |
+
for libname in self.fcompiler.libraries or []:
|
| 134 |
+
if libname not in libraries:
|
| 135 |
+
libraries.append(libname)
|
| 136 |
+
for libname in libraries:
|
| 137 |
+
if libname.startswith('msvc'): continue
|
| 138 |
+
fileexists = False
|
| 139 |
+
for libdir in library_dirs or []:
|
| 140 |
+
libfile = os.path.join(libdir, '%s.lib' % (libname))
|
| 141 |
+
if os.path.isfile(libfile):
|
| 142 |
+
fileexists = True
|
| 143 |
+
break
|
| 144 |
+
if fileexists: continue
|
| 145 |
+
# make g77-compiled static libs available to MSVC
|
| 146 |
+
fileexists = False
|
| 147 |
+
for libdir in library_dirs:
|
| 148 |
+
libfile = os.path.join(libdir, 'lib%s.a' % (libname))
|
| 149 |
+
if os.path.isfile(libfile):
|
| 150 |
+
# copy libname.a file to name.lib so that MSVC linker
|
| 151 |
+
# can find it
|
| 152 |
+
libfile2 = os.path.join(libdir, '%s.lib' % (libname))
|
| 153 |
+
copy_file(libfile, libfile2)
|
| 154 |
+
self.temp_files.append(libfile2)
|
| 155 |
+
fileexists = True
|
| 156 |
+
break
|
| 157 |
+
if fileexists: continue
|
| 158 |
+
log.warn('could not find library %r in directories %s' \
|
| 159 |
+
% (libname, library_dirs))
|
| 160 |
+
elif self.compiler.compiler_type == 'mingw32':
|
| 161 |
+
generate_manifest(self)
|
| 162 |
+
return self._wrap_method(old_config._link, lang,
|
| 163 |
+
(body, headers, include_dirs,
|
| 164 |
+
libraries, library_dirs, lang))
|
| 165 |
+
|
| 166 |
+
def check_header(self, header, include_dirs=None, library_dirs=None, lang='c'):
|
| 167 |
+
self._check_compiler()
|
| 168 |
+
return self.try_compile(
|
| 169 |
+
"/* we need a dummy line to make distutils happy */",
|
| 170 |
+
[header], include_dirs)
|
| 171 |
+
|
| 172 |
+
def check_decl(self, symbol,
|
| 173 |
+
headers=None, include_dirs=None):
|
| 174 |
+
self._check_compiler()
|
| 175 |
+
body = textwrap.dedent("""
|
| 176 |
+
int main(void)
|
| 177 |
+
{
|
| 178 |
+
#ifndef %s
|
| 179 |
+
(void) %s;
|
| 180 |
+
#endif
|
| 181 |
+
;
|
| 182 |
+
return 0;
|
| 183 |
+
}""") % (symbol, symbol)
|
| 184 |
+
|
| 185 |
+
return self.try_compile(body, headers, include_dirs)
|
| 186 |
+
|
| 187 |
+
def check_macro_true(self, symbol,
|
| 188 |
+
headers=None, include_dirs=None):
|
| 189 |
+
self._check_compiler()
|
| 190 |
+
body = textwrap.dedent("""
|
| 191 |
+
int main(void)
|
| 192 |
+
{
|
| 193 |
+
#if %s
|
| 194 |
+
#else
|
| 195 |
+
#error false or undefined macro
|
| 196 |
+
#endif
|
| 197 |
+
;
|
| 198 |
+
return 0;
|
| 199 |
+
}""") % (symbol,)
|
| 200 |
+
|
| 201 |
+
return self.try_compile(body, headers, include_dirs)
|
| 202 |
+
|
| 203 |
+
def check_type(self, type_name, headers=None, include_dirs=None,
|
| 204 |
+
library_dirs=None):
|
| 205 |
+
"""Check type availability. Return True if the type can be compiled,
|
| 206 |
+
False otherwise"""
|
| 207 |
+
self._check_compiler()
|
| 208 |
+
|
| 209 |
+
# First check the type can be compiled
|
| 210 |
+
body = textwrap.dedent(r"""
|
| 211 |
+
int main(void) {
|
| 212 |
+
if ((%(name)s *) 0)
|
| 213 |
+
return 0;
|
| 214 |
+
if (sizeof (%(name)s))
|
| 215 |
+
return 0;
|
| 216 |
+
}
|
| 217 |
+
""") % {'name': type_name}
|
| 218 |
+
|
| 219 |
+
st = False
|
| 220 |
+
try:
|
| 221 |
+
try:
|
| 222 |
+
self._compile(body % {'type': type_name},
|
| 223 |
+
headers, include_dirs, 'c')
|
| 224 |
+
st = True
|
| 225 |
+
except distutils.errors.CompileError:
|
| 226 |
+
st = False
|
| 227 |
+
finally:
|
| 228 |
+
self._clean()
|
| 229 |
+
|
| 230 |
+
return st
|
| 231 |
+
|
| 232 |
+
def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None):
|
| 233 |
+
"""Check size of a given type."""
|
| 234 |
+
self._check_compiler()
|
| 235 |
+
|
| 236 |
+
# First check the type can be compiled
|
| 237 |
+
body = textwrap.dedent(r"""
|
| 238 |
+
typedef %(type)s npy_check_sizeof_type;
|
| 239 |
+
int main (void)
|
| 240 |
+
{
|
| 241 |
+
static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) >= 0)];
|
| 242 |
+
test_array [0] = 0
|
| 243 |
+
|
| 244 |
+
;
|
| 245 |
+
return 0;
|
| 246 |
+
}
|
| 247 |
+
""")
|
| 248 |
+
self._compile(body % {'type': type_name},
|
| 249 |
+
headers, include_dirs, 'c')
|
| 250 |
+
self._clean()
|
| 251 |
+
|
| 252 |
+
if expected:
|
| 253 |
+
body = textwrap.dedent(r"""
|
| 254 |
+
typedef %(type)s npy_check_sizeof_type;
|
| 255 |
+
int main (void)
|
| 256 |
+
{
|
| 257 |
+
static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) == %(size)s)];
|
| 258 |
+
test_array [0] = 0
|
| 259 |
+
|
| 260 |
+
;
|
| 261 |
+
return 0;
|
| 262 |
+
}
|
| 263 |
+
""")
|
| 264 |
+
for size in expected:
|
| 265 |
+
try:
|
| 266 |
+
self._compile(body % {'type': type_name, 'size': size},
|
| 267 |
+
headers, include_dirs, 'c')
|
| 268 |
+
self._clean()
|
| 269 |
+
return size
|
| 270 |
+
except CompileError:
|
| 271 |
+
pass
|
| 272 |
+
|
| 273 |
+
# this fails to *compile* if size > sizeof(type)
|
| 274 |
+
body = textwrap.dedent(r"""
|
| 275 |
+
typedef %(type)s npy_check_sizeof_type;
|
| 276 |
+
int main (void)
|
| 277 |
+
{
|
| 278 |
+
static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) <= %(size)s)];
|
| 279 |
+
test_array [0] = 0
|
| 280 |
+
|
| 281 |
+
;
|
| 282 |
+
return 0;
|
| 283 |
+
}
|
| 284 |
+
""")
|
| 285 |
+
|
| 286 |
+
# The principle is simple: we first find low and high bounds of size
|
| 287 |
+
# for the type, where low/high are looked up on a log scale. Then, we
|
| 288 |
+
# do a binary search to find the exact size between low and high
|
| 289 |
+
low = 0
|
| 290 |
+
mid = 0
|
| 291 |
+
while True:
|
| 292 |
+
try:
|
| 293 |
+
self._compile(body % {'type': type_name, 'size': mid},
|
| 294 |
+
headers, include_dirs, 'c')
|
| 295 |
+
self._clean()
|
| 296 |
+
break
|
| 297 |
+
except CompileError:
|
| 298 |
+
#log.info("failure to test for bound %d" % mid)
|
| 299 |
+
low = mid + 1
|
| 300 |
+
mid = 2 * mid + 1
|
| 301 |
+
|
| 302 |
+
high = mid
|
| 303 |
+
# Binary search:
|
| 304 |
+
while low != high:
|
| 305 |
+
mid = (high - low) // 2 + low
|
| 306 |
+
try:
|
| 307 |
+
self._compile(body % {'type': type_name, 'size': mid},
|
| 308 |
+
headers, include_dirs, 'c')
|
| 309 |
+
self._clean()
|
| 310 |
+
high = mid
|
| 311 |
+
except CompileError:
|
| 312 |
+
low = mid + 1
|
| 313 |
+
return low
|
| 314 |
+
|
| 315 |
+
def check_func(self, func,
|
| 316 |
+
headers=None, include_dirs=None,
|
| 317 |
+
libraries=None, library_dirs=None,
|
| 318 |
+
decl=False, call=False, call_args=None):
|
| 319 |
+
# clean up distutils's config a bit: add void to main(), and
|
| 320 |
+
# return a value.
|
| 321 |
+
self._check_compiler()
|
| 322 |
+
body = []
|
| 323 |
+
if decl:
|
| 324 |
+
if type(decl) == str:
|
| 325 |
+
body.append(decl)
|
| 326 |
+
else:
|
| 327 |
+
body.append("int %s (void);" % func)
|
| 328 |
+
# Handle MSVC intrinsics: force MS compiler to make a function call.
|
| 329 |
+
# Useful to test for some functions when built with optimization on, to
|
| 330 |
+
# avoid build error because the intrinsic and our 'fake' test
|
| 331 |
+
# declaration do not match.
|
| 332 |
+
body.append("#ifdef _MSC_VER")
|
| 333 |
+
body.append("#pragma function(%s)" % func)
|
| 334 |
+
body.append("#endif")
|
| 335 |
+
body.append("int main (void) {")
|
| 336 |
+
if call:
|
| 337 |
+
if call_args is None:
|
| 338 |
+
call_args = ''
|
| 339 |
+
body.append(" %s(%s);" % (func, call_args))
|
| 340 |
+
else:
|
| 341 |
+
body.append(" %s;" % func)
|
| 342 |
+
body.append(" return 0;")
|
| 343 |
+
body.append("}")
|
| 344 |
+
body = '\n'.join(body) + "\n"
|
| 345 |
+
|
| 346 |
+
return self.try_link(body, headers, include_dirs,
|
| 347 |
+
libraries, library_dirs)
|
| 348 |
+
|
| 349 |
+
def check_funcs_once(self, funcs,
|
| 350 |
+
headers=None, include_dirs=None,
|
| 351 |
+
libraries=None, library_dirs=None,
|
| 352 |
+
decl=False, call=False, call_args=None):
|
| 353 |
+
"""Check a list of functions at once.
|
| 354 |
+
|
| 355 |
+
This is useful to speed up things, since all the functions in the funcs
|
| 356 |
+
list will be put in one compilation unit.
|
| 357 |
+
|
| 358 |
+
Arguments
|
| 359 |
+
---------
|
| 360 |
+
funcs : seq
|
| 361 |
+
list of functions to test
|
| 362 |
+
include_dirs : seq
|
| 363 |
+
list of header paths
|
| 364 |
+
libraries : seq
|
| 365 |
+
list of libraries to link the code snippet to
|
| 366 |
+
library_dirs : seq
|
| 367 |
+
list of library paths
|
| 368 |
+
decl : dict
|
| 369 |
+
for every (key, value), the declaration in the value will be
|
| 370 |
+
used for function in key. If a function is not in the
|
| 371 |
+
dictionary, no declaration will be used.
|
| 372 |
+
call : dict
|
| 373 |
+
for every item (f, value), if the value is True, a call will be
|
| 374 |
+
done to the function f.
|
| 375 |
+
"""
|
| 376 |
+
self._check_compiler()
|
| 377 |
+
body = []
|
| 378 |
+
if decl:
|
| 379 |
+
for f, v in decl.items():
|
| 380 |
+
if v:
|
| 381 |
+
body.append("int %s (void);" % f)
|
| 382 |
+
|
| 383 |
+
# Handle MS intrinsics. See check_func for more info.
|
| 384 |
+
body.append("#ifdef _MSC_VER")
|
| 385 |
+
for func in funcs:
|
| 386 |
+
body.append("#pragma function(%s)" % func)
|
| 387 |
+
body.append("#endif")
|
| 388 |
+
|
| 389 |
+
body.append("int main (void) {")
|
| 390 |
+
if call:
|
| 391 |
+
for f in funcs:
|
| 392 |
+
if f in call and call[f]:
|
| 393 |
+
if not (call_args and f in call_args and call_args[f]):
|
| 394 |
+
args = ''
|
| 395 |
+
else:
|
| 396 |
+
args = call_args[f]
|
| 397 |
+
body.append(" %s(%s);" % (f, args))
|
| 398 |
+
else:
|
| 399 |
+
body.append(" %s;" % f)
|
| 400 |
+
else:
|
| 401 |
+
for f in funcs:
|
| 402 |
+
body.append(" %s;" % f)
|
| 403 |
+
body.append(" return 0;")
|
| 404 |
+
body.append("}")
|
| 405 |
+
body = '\n'.join(body) + "\n"
|
| 406 |
+
|
| 407 |
+
return self.try_link(body, headers, include_dirs,
|
| 408 |
+
libraries, library_dirs)
|
| 409 |
+
|
| 410 |
+
def check_inline(self):
|
| 411 |
+
"""Return the inline keyword recognized by the compiler, empty string
|
| 412 |
+
otherwise."""
|
| 413 |
+
return check_inline(self)
|
| 414 |
+
|
| 415 |
+
def check_restrict(self):
|
| 416 |
+
"""Return the restrict keyword recognized by the compiler, empty string
|
| 417 |
+
otherwise."""
|
| 418 |
+
return check_restrict(self)
|
| 419 |
+
|
| 420 |
+
def check_compiler_gcc(self):
|
| 421 |
+
"""Return True if the C compiler is gcc"""
|
| 422 |
+
return check_compiler_gcc(self)
|
| 423 |
+
|
| 424 |
+
def check_gcc_function_attribute(self, attribute, name):
|
| 425 |
+
return check_gcc_function_attribute(self, attribute, name)
|
| 426 |
+
|
| 427 |
+
def check_gcc_function_attribute_with_intrinsics(self, attribute, name,
|
| 428 |
+
code, include):
|
| 429 |
+
return check_gcc_function_attribute_with_intrinsics(self, attribute,
|
| 430 |
+
name, code, include)
|
| 431 |
+
|
| 432 |
+
def check_gcc_variable_attribute(self, attribute):
|
| 433 |
+
return check_gcc_variable_attribute(self, attribute)
|
| 434 |
+
|
| 435 |
+
def check_gcc_version_at_least(self, major, minor=0, patchlevel=0):
|
| 436 |
+
"""Return True if the GCC version is greater than or equal to the
|
| 437 |
+
specified version."""
|
| 438 |
+
return check_gcc_version_at_least(self, major, minor, patchlevel)
|
| 439 |
+
|
| 440 |
+
def get_output(self, body, headers=None, include_dirs=None,
|
| 441 |
+
libraries=None, library_dirs=None,
|
| 442 |
+
lang="c", use_tee=None):
|
| 443 |
+
"""Try to compile, link to an executable, and run a program
|
| 444 |
+
built from 'body' and 'headers'. Returns the exit status code
|
| 445 |
+
of the program and its output.
|
| 446 |
+
"""
|
| 447 |
+
# 2008-11-16, RemoveMe
|
| 448 |
+
warnings.warn("\n+++++++++++++++++++++++++++++++++++++++++++++++++\n"
|
| 449 |
+
"Usage of get_output is deprecated: please do not \n"
|
| 450 |
+
"use it anymore, and avoid configuration checks \n"
|
| 451 |
+
"involving running executable on the target machine.\n"
|
| 452 |
+
"+++++++++++++++++++++++++++++++++++++++++++++++++\n",
|
| 453 |
+
DeprecationWarning, stacklevel=2)
|
| 454 |
+
self._check_compiler()
|
| 455 |
+
exitcode, output = 255, ''
|
| 456 |
+
try:
|
| 457 |
+
grabber = GrabStdout()
|
| 458 |
+
try:
|
| 459 |
+
src, obj, exe = self._link(body, headers, include_dirs,
|
| 460 |
+
libraries, library_dirs, lang)
|
| 461 |
+
grabber.restore()
|
| 462 |
+
except Exception:
|
| 463 |
+
output = grabber.data
|
| 464 |
+
grabber.restore()
|
| 465 |
+
raise
|
| 466 |
+
exe = os.path.join('.', exe)
|
| 467 |
+
try:
|
| 468 |
+
# specify cwd arg for consistency with
|
| 469 |
+
# historic usage pattern of exec_command()
|
| 470 |
+
# also, note that exe appears to be a string,
|
| 471 |
+
# which exec_command() handled, but we now
|
| 472 |
+
# use a list for check_output() -- this assumes
|
| 473 |
+
# that exe is always a single command
|
| 474 |
+
output = subprocess.check_output([exe], cwd='.')
|
| 475 |
+
except subprocess.CalledProcessError as exc:
|
| 476 |
+
exitstatus = exc.returncode
|
| 477 |
+
output = ''
|
| 478 |
+
except OSError:
|
| 479 |
+
# preserve the EnvironmentError exit status
|
| 480 |
+
# used historically in exec_command()
|
| 481 |
+
exitstatus = 127
|
| 482 |
+
output = ''
|
| 483 |
+
else:
|
| 484 |
+
output = filepath_from_subprocess_output(output)
|
| 485 |
+
if hasattr(os, 'WEXITSTATUS'):
|
| 486 |
+
exitcode = os.WEXITSTATUS(exitstatus)
|
| 487 |
+
if os.WIFSIGNALED(exitstatus):
|
| 488 |
+
sig = os.WTERMSIG(exitstatus)
|
| 489 |
+
log.error('subprocess exited with signal %d' % (sig,))
|
| 490 |
+
if sig == signal.SIGINT:
|
| 491 |
+
# control-C
|
| 492 |
+
raise KeyboardInterrupt
|
| 493 |
+
else:
|
| 494 |
+
exitcode = exitstatus
|
| 495 |
+
log.info("success!")
|
| 496 |
+
except (CompileError, LinkError):
|
| 497 |
+
log.info("failure.")
|
| 498 |
+
self._clean()
|
| 499 |
+
return exitcode, output
|
| 500 |
+
|
| 501 |
+
class GrabStdout:
|
| 502 |
+
|
| 503 |
+
def __init__(self):
|
| 504 |
+
self.sys_stdout = sys.stdout
|
| 505 |
+
self.data = ''
|
| 506 |
+
sys.stdout = self
|
| 507 |
+
|
| 508 |
+
def write (self, data):
|
| 509 |
+
self.sys_stdout.write(data)
|
| 510 |
+
self.data += data
|
| 511 |
+
|
| 512 |
+
def flush (self):
|
| 513 |
+
self.sys_stdout.flush()
|
| 514 |
+
|
| 515 |
+
def restore(self):
|
| 516 |
+
sys.stdout = self.sys_stdout
|
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/config_compiler.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from distutils.core import Command
|
| 2 |
+
from numpy.distutils import log
|
| 3 |
+
|
| 4 |
+
#XXX: Linker flags
|
| 5 |
+
|
| 6 |
+
def show_fortran_compilers(_cache=None):
|
| 7 |
+
# Using cache to prevent infinite recursion.
|
| 8 |
+
if _cache:
|
| 9 |
+
return
|
| 10 |
+
elif _cache is None:
|
| 11 |
+
_cache = []
|
| 12 |
+
_cache.append(1)
|
| 13 |
+
from numpy.distutils.fcompiler import show_fcompilers
|
| 14 |
+
import distutils.core
|
| 15 |
+
dist = distutils.core._setup_distribution
|
| 16 |
+
show_fcompilers(dist)
|
| 17 |
+
|
| 18 |
+
class config_fc(Command):
|
| 19 |
+
""" Distutils command to hold user specified options
|
| 20 |
+
to Fortran compilers.
|
| 21 |
+
|
| 22 |
+
config_fc command is used by the FCompiler.customize() method.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
description = "specify Fortran 77/Fortran 90 compiler information"
|
| 26 |
+
|
| 27 |
+
user_options = [
|
| 28 |
+
('fcompiler=', None, "specify Fortran compiler type"),
|
| 29 |
+
('f77exec=', None, "specify F77 compiler command"),
|
| 30 |
+
('f90exec=', None, "specify F90 compiler command"),
|
| 31 |
+
('f77flags=', None, "specify F77 compiler flags"),
|
| 32 |
+
('f90flags=', None, "specify F90 compiler flags"),
|
| 33 |
+
('opt=', None, "specify optimization flags"),
|
| 34 |
+
('arch=', None, "specify architecture specific optimization flags"),
|
| 35 |
+
('debug', 'g', "compile with debugging information"),
|
| 36 |
+
('noopt', None, "compile without optimization"),
|
| 37 |
+
('noarch', None, "compile without arch-dependent optimization"),
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
help_options = [
|
| 41 |
+
('help-fcompiler', None, "list available Fortran compilers",
|
| 42 |
+
show_fortran_compilers),
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
boolean_options = ['debug', 'noopt', 'noarch']
|
| 46 |
+
|
| 47 |
+
def initialize_options(self):
|
| 48 |
+
self.fcompiler = None
|
| 49 |
+
self.f77exec = None
|
| 50 |
+
self.f90exec = None
|
| 51 |
+
self.f77flags = None
|
| 52 |
+
self.f90flags = None
|
| 53 |
+
self.opt = None
|
| 54 |
+
self.arch = None
|
| 55 |
+
self.debug = None
|
| 56 |
+
self.noopt = None
|
| 57 |
+
self.noarch = None
|
| 58 |
+
|
| 59 |
+
def finalize_options(self):
|
| 60 |
+
log.info('unifying config_fc, config, build_clib, build_ext, build commands --fcompiler options')
|
| 61 |
+
build_clib = self.get_finalized_command('build_clib')
|
| 62 |
+
build_ext = self.get_finalized_command('build_ext')
|
| 63 |
+
config = self.get_finalized_command('config')
|
| 64 |
+
build = self.get_finalized_command('build')
|
| 65 |
+
cmd_list = [self, config, build_clib, build_ext, build]
|
| 66 |
+
for a in ['fcompiler']:
|
| 67 |
+
l = []
|
| 68 |
+
for c in cmd_list:
|
| 69 |
+
v = getattr(c, a)
|
| 70 |
+
if v is not None:
|
| 71 |
+
if not isinstance(v, str): v = v.compiler_type
|
| 72 |
+
if v not in l: l.append(v)
|
| 73 |
+
if not l: v1 = None
|
| 74 |
+
else: v1 = l[0]
|
| 75 |
+
if len(l)>1:
|
| 76 |
+
log.warn(' commands have different --%s options: %s'\
|
| 77 |
+
', using first in list as default' % (a, l))
|
| 78 |
+
if v1:
|
| 79 |
+
for c in cmd_list:
|
| 80 |
+
if getattr(c, a) is None: setattr(c, a, v1)
|
| 81 |
+
|
| 82 |
+
def run(self):
|
| 83 |
+
# Do nothing.
|
| 84 |
+
return
|
| 85 |
+
|
| 86 |
+
class config_cc(Command):
|
| 87 |
+
""" Distutils command to hold user specified options
|
| 88 |
+
to C/C++ compilers.
|
| 89 |
+
"""
|
| 90 |
+
|
| 91 |
+
description = "specify C/C++ compiler information"
|
| 92 |
+
|
| 93 |
+
user_options = [
|
| 94 |
+
('compiler=', None, "specify C/C++ compiler type"),
|
| 95 |
+
]
|
| 96 |
+
|
| 97 |
+
def initialize_options(self):
|
| 98 |
+
self.compiler = None
|
| 99 |
+
|
| 100 |
+
def finalize_options(self):
|
| 101 |
+
log.info('unifying config_cc, config, build_clib, build_ext, build commands --compiler options')
|
| 102 |
+
build_clib = self.get_finalized_command('build_clib')
|
| 103 |
+
build_ext = self.get_finalized_command('build_ext')
|
| 104 |
+
config = self.get_finalized_command('config')
|
| 105 |
+
build = self.get_finalized_command('build')
|
| 106 |
+
cmd_list = [self, config, build_clib, build_ext, build]
|
| 107 |
+
for a in ['compiler']:
|
| 108 |
+
l = []
|
| 109 |
+
for c in cmd_list:
|
| 110 |
+
v = getattr(c, a)
|
| 111 |
+
if v is not None:
|
| 112 |
+
if not isinstance(v, str): v = v.compiler_type
|
| 113 |
+
if v not in l: l.append(v)
|
| 114 |
+
if not l: v1 = None
|
| 115 |
+
else: v1 = l[0]
|
| 116 |
+
if len(l)>1:
|
| 117 |
+
log.warn(' commands have different --%s options: %s'\
|
| 118 |
+
', using first in list as default' % (a, l))
|
| 119 |
+
if v1:
|
| 120 |
+
for c in cmd_list:
|
| 121 |
+
if getattr(c, a) is None: setattr(c, a, v1)
|
| 122 |
+
return
|
| 123 |
+
|
| 124 |
+
def run(self):
|
| 125 |
+
# Do nothing.
|
| 126 |
+
return
|
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/develop.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
""" Override the develop command from setuptools so we can ensure that our
|
| 2 |
+
generated files (from build_src or build_scripts) are properly converted to real
|
| 3 |
+
files with filenames.
|
| 4 |
+
|
| 5 |
+
"""
|
| 6 |
+
from setuptools.command.develop import develop as old_develop
|
| 7 |
+
|
| 8 |
+
class develop(old_develop):
|
| 9 |
+
__doc__ = old_develop.__doc__
|
| 10 |
+
def install_for_development(self):
|
| 11 |
+
# Build sources in-place, too.
|
| 12 |
+
self.reinitialize_command('build_src', inplace=1)
|
| 13 |
+
# Make sure scripts are built.
|
| 14 |
+
self.run_command('build_scripts')
|
| 15 |
+
old_develop.install_for_development(self)
|
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/egg_info.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
|
| 3 |
+
from setuptools.command.egg_info import egg_info as _egg_info
|
| 4 |
+
|
| 5 |
+
class egg_info(_egg_info):
|
| 6 |
+
def run(self):
|
| 7 |
+
if 'sdist' in sys.argv:
|
| 8 |
+
import warnings
|
| 9 |
+
import textwrap
|
| 10 |
+
msg = textwrap.dedent("""
|
| 11 |
+
`build_src` is being run, this may lead to missing
|
| 12 |
+
files in your sdist! You want to use distutils.sdist
|
| 13 |
+
instead of the setuptools version:
|
| 14 |
+
|
| 15 |
+
from distutils.command.sdist import sdist
|
| 16 |
+
cmdclass={'sdist': sdist}"
|
| 17 |
+
|
| 18 |
+
See numpy's setup.py or gh-7131 for details.""")
|
| 19 |
+
warnings.warn(msg, UserWarning, stacklevel=2)
|
| 20 |
+
|
| 21 |
+
# We need to ensure that build_src has been executed in order to give
|
| 22 |
+
# setuptools' egg_info command real filenames instead of functions which
|
| 23 |
+
# generate files.
|
| 24 |
+
self.run_command("build_src")
|
| 25 |
+
_egg_info.run(self)
|
pythonProject/.venv/Lib/site-packages/numpy/distutils/command/install.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
if 'setuptools' in sys.modules:
|
| 3 |
+
import setuptools.command.install as old_install_mod
|
| 4 |
+
have_setuptools = True
|
| 5 |
+
else:
|
| 6 |
+
import distutils.command.install as old_install_mod
|
| 7 |
+
have_setuptools = False
|
| 8 |
+
from distutils.file_util import write_file
|
| 9 |
+
|
| 10 |
+
old_install = old_install_mod.install
|
| 11 |
+
|
| 12 |
+
class install(old_install):
|
| 13 |
+
|
| 14 |
+
# Always run install_clib - the command is cheap, so no need to bypass it;
|
| 15 |
+
# but it's not run by setuptools -- so it's run again in install_data
|
| 16 |
+
sub_commands = old_install.sub_commands + [
|
| 17 |
+
('install_clib', lambda x: True)
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
def finalize_options (self):
|
| 21 |
+
old_install.finalize_options(self)
|
| 22 |
+
self.install_lib = self.install_libbase
|
| 23 |
+
|
| 24 |
+
def setuptools_run(self):
|
| 25 |
+
""" The setuptools version of the .run() method.
|
| 26 |
+
|
| 27 |
+
We must pull in the entire code so we can override the level used in the
|
| 28 |
+
_getframe() call since we wrap this call by one more level.
|
| 29 |
+
"""
|
| 30 |
+
from distutils.command.install import install as distutils_install
|
| 31 |
+
|
| 32 |
+
# Explicit request for old-style install? Just do it
|
| 33 |
+
if self.old_and_unmanageable or self.single_version_externally_managed:
|
| 34 |
+
return distutils_install.run(self)
|
| 35 |
+
|
| 36 |
+
# Attempt to detect whether we were called from setup() or by another
|
| 37 |
+
# command. If we were called by setup(), our caller will be the
|
| 38 |
+
# 'run_command' method in 'distutils.dist', and *its* caller will be
|
| 39 |
+
# the 'run_commands' method. If we were called any other way, our
|
| 40 |
+
# immediate caller *might* be 'run_command', but it won't have been
|
| 41 |
+
# called by 'run_commands'. This is slightly kludgy, but seems to
|
| 42 |
+
# work.
|
| 43 |
+
#
|
| 44 |
+
caller = sys._getframe(3)
|
| 45 |
+
caller_module = caller.f_globals.get('__name__', '')
|
| 46 |
+
caller_name = caller.f_code.co_name
|
| 47 |
+
|
| 48 |
+
if caller_module != 'distutils.dist' or caller_name!='run_commands':
|
| 49 |
+
# We weren't called from the command line or setup(), so we
|
| 50 |
+
# should run in backward-compatibility mode to support bdist_*
|
| 51 |
+
# commands.
|
| 52 |
+
distutils_install.run(self)
|
| 53 |
+
else:
|
| 54 |
+
self.do_egg_install()
|
| 55 |
+
|
| 56 |
+
def run(self):
|
| 57 |
+
if not have_setuptools:
|
| 58 |
+
r = old_install.run(self)
|
| 59 |
+
else:
|
| 60 |
+
r = self.setuptools_run()
|
| 61 |
+
if self.record:
|
| 62 |
+
# bdist_rpm fails when INSTALLED_FILES contains
|
| 63 |
+
# paths with spaces. Such paths must be enclosed
|
| 64 |
+
# with double-quotes.
|
| 65 |
+
with open(self.record) as f:
|
| 66 |
+
lines = []
|
| 67 |
+
need_rewrite = False
|
| 68 |
+
for l in f:
|
| 69 |
+
l = l.rstrip()
|
| 70 |
+
if ' ' in l:
|
| 71 |
+
need_rewrite = True
|
| 72 |
+
l = '"%s"' % (l)
|
| 73 |
+
lines.append(l)
|
| 74 |
+
if need_rewrite:
|
| 75 |
+
self.execute(write_file,
|
| 76 |
+
(self.record, lines),
|
| 77 |
+
"re-writing list of installed files to '%s'" %
|
| 78 |
+
self.record)
|
| 79 |
+
return r
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh23598Warn.f90
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module test_bug
|
| 2 |
+
implicit none
|
| 3 |
+
private
|
| 4 |
+
public :: intproduct
|
| 5 |
+
|
| 6 |
+
contains
|
| 7 |
+
integer function intproduct(a, b) result(res)
|
| 8 |
+
integer, intent(in) :: a, b
|
| 9 |
+
res = a*b
|
| 10 |
+
end function
|
| 11 |
+
end module
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh23879.f90
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module gh23879
|
| 2 |
+
implicit none
|
| 3 |
+
private
|
| 4 |
+
public :: foo
|
| 5 |
+
|
| 6 |
+
contains
|
| 7 |
+
|
| 8 |
+
subroutine foo(a, b)
|
| 9 |
+
integer, intent(in) :: a
|
| 10 |
+
integer, intent(out) :: b
|
| 11 |
+
b = a
|
| 12 |
+
call bar(b)
|
| 13 |
+
end subroutine
|
| 14 |
+
|
| 15 |
+
subroutine bar(x)
|
| 16 |
+
integer, intent(inout) :: x
|
| 17 |
+
x = 2*x
|
| 18 |
+
end subroutine
|
| 19 |
+
|
| 20 |
+
end module gh23879
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh27697.f90
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module utils
|
| 2 |
+
implicit none
|
| 3 |
+
contains
|
| 4 |
+
subroutine my_abort(message)
|
| 5 |
+
implicit none
|
| 6 |
+
character(len=*), intent(in) :: message
|
| 7 |
+
!f2py callstatement PyErr_SetString(PyExc_ValueError, message);f2py_success = 0;
|
| 8 |
+
!f2py callprotoargument char*
|
| 9 |
+
write(0,*) "THIS SHOULD NOT APPEAR"
|
| 10 |
+
stop 1
|
| 11 |
+
end subroutine my_abort
|
| 12 |
+
end module utils
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/gh2848.f90
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
subroutine gh2848( &
|
| 2 |
+
! first 2 parameters
|
| 3 |
+
par1, par2,&
|
| 4 |
+
! last 2 parameters
|
| 5 |
+
par3, par4)
|
| 6 |
+
|
| 7 |
+
integer, intent(in) :: par1, par2
|
| 8 |
+
integer, intent(out) :: par3, par4
|
| 9 |
+
|
| 10 |
+
par3 = par1
|
| 11 |
+
par4 = par2
|
| 12 |
+
|
| 13 |
+
end subroutine gh2848
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/operators.f90
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module foo
|
| 2 |
+
type bar
|
| 3 |
+
character(len = 32) :: item
|
| 4 |
+
end type bar
|
| 5 |
+
interface operator(.item.)
|
| 6 |
+
module procedure item_int, item_real
|
| 7 |
+
end interface operator(.item.)
|
| 8 |
+
interface operator(==)
|
| 9 |
+
module procedure items_are_equal
|
| 10 |
+
end interface operator(==)
|
| 11 |
+
interface assignment(=)
|
| 12 |
+
module procedure get_int, get_real
|
| 13 |
+
end interface assignment(=)
|
| 14 |
+
contains
|
| 15 |
+
function item_int(val) result(elem)
|
| 16 |
+
integer, intent(in) :: val
|
| 17 |
+
type(bar) :: elem
|
| 18 |
+
|
| 19 |
+
write(elem%item, "(I32)") val
|
| 20 |
+
end function item_int
|
| 21 |
+
|
| 22 |
+
function item_real(val) result(elem)
|
| 23 |
+
real, intent(in) :: val
|
| 24 |
+
type(bar) :: elem
|
| 25 |
+
|
| 26 |
+
write(elem%item, "(1PE32.12)") val
|
| 27 |
+
end function item_real
|
| 28 |
+
|
| 29 |
+
function items_are_equal(val1, val2) result(equal)
|
| 30 |
+
type(bar), intent(in) :: val1, val2
|
| 31 |
+
logical :: equal
|
| 32 |
+
|
| 33 |
+
equal = (val1%item == val2%item)
|
| 34 |
+
end function items_are_equal
|
| 35 |
+
|
| 36 |
+
subroutine get_real(rval, item)
|
| 37 |
+
real, intent(out) :: rval
|
| 38 |
+
type(bar), intent(in) :: item
|
| 39 |
+
|
| 40 |
+
read(item%item, *) rval
|
| 41 |
+
end subroutine get_real
|
| 42 |
+
|
| 43 |
+
subroutine get_int(rval, item)
|
| 44 |
+
integer, intent(out) :: rval
|
| 45 |
+
type(bar), intent(in) :: item
|
| 46 |
+
|
| 47 |
+
read(item%item, *) rval
|
| 48 |
+
end subroutine get_int
|
| 49 |
+
end module foo
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/privatemod.f90
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module foo
|
| 2 |
+
private
|
| 3 |
+
integer :: a
|
| 4 |
+
public :: setA
|
| 5 |
+
integer :: b
|
| 6 |
+
contains
|
| 7 |
+
subroutine setA(v)
|
| 8 |
+
integer, intent(in) :: v
|
| 9 |
+
a = v
|
| 10 |
+
end subroutine setA
|
| 11 |
+
end module foo
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/publicmod.f90
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module foo
|
| 2 |
+
public
|
| 3 |
+
integer, private :: a
|
| 4 |
+
public :: setA
|
| 5 |
+
contains
|
| 6 |
+
subroutine setA(v)
|
| 7 |
+
integer, intent(in) :: v
|
| 8 |
+
a = v
|
| 9 |
+
end subroutine setA
|
| 10 |
+
end module foo
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/pubprivmod.f90
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module foo
|
| 2 |
+
public
|
| 3 |
+
integer, private :: a
|
| 4 |
+
integer :: b
|
| 5 |
+
contains
|
| 6 |
+
subroutine setA(v)
|
| 7 |
+
integer, intent(in) :: v
|
| 8 |
+
a = v
|
| 9 |
+
end subroutine setA
|
| 10 |
+
end module foo
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/crackfortran/unicode_comment.f90
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
subroutine foo(x)
|
| 2 |
+
real(8), intent(in) :: x
|
| 3 |
+
! Écrit à l'écran la valeur de x
|
| 4 |
+
end subroutine
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/f2cmap/.f2py_f2cmap
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
dict(real=dict(real32='float', real64='double'), integer=dict(int64='long_long'))
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/f2cmap/isoFortranEnvMap.f90
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
subroutine func1(n, x, res)
|
| 2 |
+
use, intrinsic :: iso_fortran_env, only: int64, real64
|
| 3 |
+
implicit none
|
| 4 |
+
integer(int64), intent(in) :: n
|
| 5 |
+
real(real64), intent(in) :: x(n)
|
| 6 |
+
real(real64), intent(out) :: res
|
| 7 |
+
!f2py intent(hide) :: n
|
| 8 |
+
res = sum(x)
|
| 9 |
+
end
|
pythonProject/.venv/Lib/site-packages/numpy/f2py/tests/src/isocintrin/isoCtests.f90
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module coddity
|
| 2 |
+
use iso_c_binding, only: c_double, c_int, c_int64_t
|
| 3 |
+
implicit none
|
| 4 |
+
contains
|
| 5 |
+
subroutine c_add(a, b, c) bind(c, name="c_add")
|
| 6 |
+
real(c_double), intent(in) :: a, b
|
| 7 |
+
real(c_double), intent(out) :: c
|
| 8 |
+
c = a + b
|
| 9 |
+
end subroutine c_add
|
| 10 |
+
! gh-9693
|
| 11 |
+
function wat(x, y) result(z) bind(c)
|
| 12 |
+
integer(c_int), intent(in) :: x, y
|
| 13 |
+
integer(c_int) :: z
|
| 14 |
+
|
| 15 |
+
z = x + 7
|
| 16 |
+
end function wat
|
| 17 |
+
! gh-25207
|
| 18 |
+
subroutine c_add_int64(a, b, c) bind(c)
|
| 19 |
+
integer(c_int64_t), intent(in) :: a, b
|
| 20 |
+
integer(c_int64_t), intent(out) :: c
|
| 21 |
+
c = a + b
|
| 22 |
+
end subroutine c_add_int64
|
| 23 |
+
! gh-25207
|
| 24 |
+
subroutine add_arr(A, B, C)
|
| 25 |
+
integer(c_int64_t), intent(in) :: A(3)
|
| 26 |
+
integer(c_int64_t), intent(in) :: B(3)
|
| 27 |
+
integer(c_int64_t), intent(out) :: C(3)
|
| 28 |
+
integer :: j
|
| 29 |
+
|
| 30 |
+
do j = 1, 3
|
| 31 |
+
C(j) = A(j)+B(j)
|
| 32 |
+
end do
|
| 33 |
+
end subroutine
|
| 34 |
+
end module coddity
|