GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MAINT: Vendor in distutils testing requirement · numpy/numpy@c411a21

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • numpy/distutils/tests
    • test_build_ext.py
    • utilities.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎numpy/distutils/tests/test_build_ext.py‎

Copy file name to clipboardExpand all lines: numpy/distutils/tests/test_build_ext.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_multi_fortran_libs_link(tmp_path):
1818
# We need to make sure we actually have an f77 compiler.
1919
# This is nontrivial, so we'll borrow the utilities
2020
# from f2py tests:
21-
from numpy.f2py.tests.util import has_f77_compiler
21+
from numpy.distutils.tests.utilities import has_f77_compiler
2222
if not has_f77_compiler():
2323
pytest.skip('No F77 compiler found')
2424

Collapse file

‎numpy/distutils/tests/utilities.py‎

Copy file name to clipboard
+81Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Kanged out of numpy.f2py.tests.util for test_build_ext
2+
3+
#
4+
# Check if compilers are available at all...
5+
#
6+
7+
_compiler_status = None
8+
9+
10+
def _get_compiler_status():
11+
global _compiler_status
12+
if _compiler_status is not None:
13+
return _compiler_status
14+
15+
_compiler_status = (False, False, False)
16+
if IS_WASM:
17+
# Can't run compiler from inside WASM.
18+
return _compiler_status
19+
20+
# XXX: this is really ugly. But I don't know how to invoke Distutils
21+
# in a safer way...
22+
code = textwrap.dedent(f"""\
23+
import os
24+
import sys
25+
sys.path = {repr(sys.path)}
26+
27+
def configuration(parent_name='',top_path=None):
28+
global config
29+
from numpy.distutils.misc_util import Configuration
30+
config = Configuration('', parent_name, top_path)
31+
return config
32+
33+
from numpy.distutils.core import setup
34+
setup(configuration=configuration)
35+
36+
config_cmd = config.get_config_cmd()
37+
have_c = config_cmd.try_compile('void foo() {{}}')
38+
print('COMPILERS:%%d,%%d,%%d' %% (have_c,
39+
config.have_f77c(),
40+
config.have_f90c()))
41+
sys.exit(99)
42+
""")
43+
code = code % dict(syspath=repr(sys.path))
44+
45+
tmpdir = tempfile.mkdtemp()
46+
try:
47+
script = os.path.join(tmpdir, "setup.py")
48+
49+
with open(script, "w") as f:
50+
f.write(code)
51+
52+
cmd = [sys.executable, "setup.py", "config"]
53+
p = subprocess.Popen(cmd,
54+
stdout=subprocess.PIPE,
55+
stderr=subprocess.STDOUT,
56+
cwd=tmpdir)
57+
out, err = p.communicate()
58+
finally:
59+
shutil.rmtree(tmpdir)
60+
61+
m = re.search(br"COMPILERS:(\d+),(\d+),(\d+)", out)
62+
if m:
63+
_compiler_status = (
64+
bool(int(m.group(1))),
65+
bool(int(m.group(2))),
66+
bool(int(m.group(3))),
67+
)
68+
# Finished
69+
return _compiler_status
70+
71+
72+
def has_c_compiler():
73+
return _get_compiler_status()[0]
74+
75+
76+
def has_f77_compiler():
77+
return _get_compiler_status()[1]
78+
79+
80+
def has_f90_compiler():
81+
return _get_compiler_status()[2]

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.