8000 TST: Cleanup old distutils builder [f2py] · numpy/numpy@26bc735 · GitHub
[go: up one dir, main page]

Skip to content

Commit 26bc735

Browse files
committed
TST: Cleanup old distutils builder [f2py]
1 parent c4028e0 commit 26bc735

File tree

1 file changed

+0
-67
lines changed

1 file changed

+0
-67
lines changed

numpy/f2py/tests/util.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -275,73 +275,6 @@ def has_f77_compiler():
275275
def has_f90_compiler():
276276
return checker.has_f90
277277

278-
#
279-
# Building with distutils
280-
#
281-
282-
283-
@_memoize
284-
def build_module_distutils(source_files, config_code, module_name, **kw):
285-
"""
286-
Build a module via distutils and import it.
287-
288-
"""
289-
d = get_module_dir()
290-
291-
# Copy files
292-
dst_sources = []
293-
for fn in source_files:
294-
if not os.path.isfile(fn):
295-
raise RuntimeError("%s is not a file" % fn)
296-
dst = os.path.join(d, os.path.basename(fn))
297-
shutil.copyfile(fn, dst)
298-
dst_sources.append(dst)
299-
300-
# Build script
301-
config_code = textwrap.dedent(config_code).replace("\n", "\n ")
302-
303-
code = fr"""
304-
import os
305-
import sys
306-
sys.path = {repr(sys.path)}
307-
308-
def configuration(parent_name='',top_path=None):
309-
from numpy.distutils.misc_util import Configuration
310-
config = Configuration('', parent_name, top_path)
311-
{config_code}
312-
return config
313-
314-
if __name__ == "__main__":
315-
from numpy.distutils.core import setup
316-
setup(configuration=configuration)
317-
"""
318-
script = os.path.join(d, get_temp_module_name() + ".py")
319-
dst_sources.append(script)
320-
with open(script, "wb") as f:
321-
f.write(code.encode('latin1'))
322-
323-
# Build
324-
cwd = os.getcwd()
325-
try:
326-
os.chdir(d)
327-
cmd = [sys.executable, script, "build_ext", "-i"]
328-
p = subprocess.Popen(cmd,
329-
stdout=subprocess.PIPE,
330-
stderr=subprocess.STDOUT)
331-
out, err = p.communicate()
332-
if p.returncode != 0:
333-
raise RuntimeError("Running distutils build failed: %s\n%s" %
334-
(cmd[4:], asstr(out)))
335-
finally:
336-
os.chdir(cwd)
337-
338-
# Partial cleanup
339-
for fn in dst_sources:
340-
os.unlink(fn)
341-
342-
return import_module(module_name)
343-
344-
345278
#
346279
# Building with meson
347280
#

0 commit comments

Comments
 (0)
0