diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2016-01-07 05:59:00 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2016-01-07 05:59:00 -0700 |
commit | 8a76291c76aa9b33b18ceb06f6e8f37f990c9e27 (patch) | |
tree | f762c9fcc1cf2e0cd8d879a73aa9f061b8db2a2e /numpy | |
parent | 881ae912eb5b88f6224a938b136969dc48cbbac7 (diff) | |
parent | 04bee1c34e40bc6c82c8df476baeac8c2edd863c (diff) | |
download | numpy-8a76291c76aa9b33b18ceb06f6e8f37f990c9e27.tar.gz |
Merge pull request #6955 from rgommers/distutils-cleanup
MAINT: distutils cleanup for Pyrex support and unused f2py/swig tests
Diffstat (limited to 'numpy')
29 files changed, 8 insertions, 392 deletions
diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py index 7463a0e17..2efcdea60 100644 --- a/numpy/distutils/command/build_src.py +++ b/numpy/distutils/command/build_src.py @@ -1,4 +1,4 @@ -""" Build swig, f2py, pyrex sources. +""" Build swig and f2py sources. """ from __future__ import division, absolute_import, print_function @@ -13,12 +13,6 @@ from distutils.dep_util import newer_group, newer from distutils.util import get_platform from distutils.errors import DistutilsError, DistutilsSetupError -def have_pyrex(): - try: - import Pyrex.Compiler.Main - return True - except ImportError: - return False # this import can't be done here, as it uses numpy stuff only available # after it's installed @@ -327,13 +321,9 @@ class build_src(build_ext.build_ext): self.ext_target_dir = self.get_package_dir(package) sources = self.generate_sources(sources, ext) - sources = self.template_sources(sources, ext) - sources = self.swig_sources(sources, ext) - sources = self.f2py_sources(sources, ext) - sources = self.pyrex_sources(sources, ext) sources, py_files = self.filter_py_files(sources) @@ -450,6 +440,7 @@ class build_src(build_ext.build_ext): return new_sources def pyrex_sources(self, sources, extension): + """Pyrex not supported; this remains for Cython support (see below)""" new_sources = [] ext_name = extension.name.split('.')[-1] for source in sources: @@ -464,34 +455,12 @@ class build_src(build_ext.build_ext): return new_sources def generate_a_pyrex_source(self, base, ext_name, source, extension): - if self.inplace or not have_pyrex(): - target_dir = os.path.dirname(base) - else: - target_dir = appendpath(self.build_src, os.path.dirname(base)) - target_file = os.path.join(target_dir, ext_name + '.c') - depends = [source] + extension.depends - if self.force or newer_group(depends, target_file, 'newer'): - if have_pyrex(): - import Pyrex.Compiler.Main - log.info("pyrexc:> %s" % (target_file)) - self.mkpath(target_dir) - options = Pyrex.Compiler.Main.CompilationOptions( - defaults=Pyrex.Compiler.Main.default_options, - include_path=extension.include_dirs, - output_file=target_file) - pyrex_result = Pyrex.Compiler.Main.compile(source, - options=options) - if pyrex_result.num_errors != 0: - raise DistutilsError("%d errors while compiling %r with Pyrex" \ - % (pyrex_result.num_errors, source)) - elif os.path.isfile(target_file): - log.warn("Pyrex required for compiling %r but not available,"\ - " using old target %r"\ - % (source, target_file)) - else: - raise DistutilsError("Pyrex required for compiling %r"\ - " but notavailable" % (source,)) - return target_file + """Pyrex is not supported, but some projects monkeypatch this method. + + That allows compiling Cython code, see gh-6955. + This method will remain here for compatibility reasons. + """ + return [] def f2py_sources(self, sources, extension): new_sources = [] diff --git a/numpy/distutils/tests/f2py_ext/__init__.py b/numpy/distutils/tests/f2py_ext/__init__.py deleted file mode 100644 index 1d0f69b67..000000000 --- a/numpy/distutils/tests/f2py_ext/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import division, absolute_import, print_function diff --git a/numpy/distutils/tests/f2py_ext/setup.py b/numpy/distutils/tests/f2py_ext/setup.py deleted file mode 100644 index bb7d4bc1c..000000000 --- a/numpy/distutils/tests/f2py_ext/setup.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -from __future__ import division, print_function - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration('f2py_ext', parent_package, top_path) - config.add_extension('fib2', ['src/fib2.pyf', 'src/fib1.f']) - config.add_data_dir('tests') - return config - -if __name__ == "__main__": - from numpy.distutils.core import setup - setup(configuration=configuration) diff --git a/numpy/distutils/tests/f2py_ext/src/fib1.f b/numpy/distutils/tests/f2py_ext/src/fib1.f deleted file mode 100644 index cfbb1eea0..000000000 --- a/numpy/distutils/tests/f2py_ext/src/fib1.f +++ /dev/null @@ -1,18 +0,0 @@ -C FILE: FIB1.F - SUBROUTINE FIB(A,N) -C -C CALCULATE FIRST N FIBONACCI NUMBERS -C - INTEGER N - REAL*8 A(N) - DO I=1,N - IF (I.EQ.1) THEN - A(I) = 0.0D0 - ELSEIF (I.EQ.2) THEN - A(I) = 1.0D0 - ELSE - A(I) = A(I-1) + A(I-2) - ENDIF - ENDDO - END -C END FILE FIB1.F diff --git a/numpy/distutils/tests/f2py_ext/src/fib2.pyf b/numpy/distutils/tests/f2py_ext/src/fib2.pyf deleted file mode 100644 index 90a8cf00c..000000000 --- a/numpy/distutils/tests/f2py_ext/src/fib2.pyf +++ /dev/null @@ -1,9 +0,0 @@ -! -*- f90 -*- -python module fib2 - interface - subroutine fib(a,n) - real*8 dimension(n),intent(out),depend(n) :: a - integer intent(in) :: n - end subroutine fib - end interface -end python module fib2 diff --git a/numpy/distutils/tests/f2py_ext/tests/test_fib2.py b/numpy/distutils/tests/f2py_ext/tests/test_fib2.py deleted file mode 100644 index 0e5bab925..000000000 --- a/numpy/distutils/tests/f2py_ext/tests/test_fib2.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import division, absolute_import, print_function - -from numpy.testing import TestCase, run_module_suite, assert_array_equal -from f2py_ext import fib2 - -class TestFib2(TestCase): - - def test_fib(self): - assert_array_equal(fib2.fib(6), [0, 1, 1, 2, 3, 5]) - -if __name__ == "__main__": - run_module_suite() diff --git a/numpy/distutils/tests/f2py_f90_ext/__init__.py b/numpy/distutils/tests/f2py_f90_ext/__init__.py deleted file mode 100644 index 1d0f69b67..000000000 --- a/numpy/distutils/tests/f2py_f90_ext/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import division, absolute_import, print_function diff --git a/numpy/distutils/tests/f2py_f90_ext/include/body.f90 b/numpy/distutils/tests/f2py_f90_ext/include/body.f90 deleted file mode 100644 index 90b44e29d..000000000 --- a/numpy/distutils/tests/f2py_f90_ext/include/body.f90 +++ /dev/null @@ -1,5 +0,0 @@ - subroutine bar13(a) - !f2py intent(out) a - integer a - a = 13 - end subroutine bar13 diff --git a/numpy/distutils/tests/f2py_f90_ext/setup.py b/numpy/distutils/tests/f2py_f90_ext/setup.py deleted file mode 100644 index 7cca81637..000000000 --- a/numpy/distutils/tests/f2py_f90_ext/setup.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -from __future__ import division, print_function - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration('f2py_f90_ext', parent_package, top_path) - config.add_extension('foo', - ['src/foo_free.f90'], - include_dirs=['include'], - f2py_options=['--include_paths', - config.paths('include')[0]] - ) - config.add_data_dir('tests') - return config - -if __name__ == "__main__": - from numpy.distutils.core import setup - setup(configuration=configuration) diff --git a/numpy/distutils/tests/f2py_f90_ext/src/foo_free.f90 b/numpy/distutils/tests/f2py_f90_ext/src/foo_free.f90 deleted file mode 100644 index c7713be59..000000000 --- a/numpy/distutils/tests/f2py_f90_ext/src/foo_free.f90 +++ /dev/null @@ -1,6 +0,0 @@ -module foo_free -contains - -include "body.f90" - -end module foo_free diff --git a/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py b/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py deleted file mode 100644 index 499b9ebc3..000000000 --- a/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import division, absolute_import, print_function - -from numpy.testing import TestCase, run_module_suite, assert_equal -from f2py_f90_ext import foo - -class TestFoo(TestCase): - def test_foo_free(self): - assert_equal(foo.foo_free.bar13(), 13) - -if __name__ == "__main__": - run_module_suite() diff --git a/numpy/distutils/tests/gen_ext/__init__.py b/numpy/distutils/tests/gen_ext/__init__.py deleted file mode 100644 index 1d0f69b67..000000000 --- a/numpy/distutils/tests/gen_ext/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import division, absolute_import, print_function diff --git a/numpy/distutils/tests/gen_ext/setup.py b/numpy/distutils/tests/gen_ext/setup.py deleted file mode 100644 index de6b941e0..000000000 --- a/numpy/distutils/tests/gen_ext/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -from __future__ import division, print_function - -fib3_f = ''' -C FILE: FIB3.F - SUBROUTINE FIB(A,N) -C -C CALCULATE FIRST N FIBONACCI NUMBERS -C - INTEGER N - REAL*8 A(N) -Cf2py intent(in) n -Cf2py intent(out) a -Cf2py depend(n) a - DO I=1,N - IF (I.EQ.1) THEN - A(I) = 0.0D0 - ELSEIF (I.EQ.2) THEN - A(I) = 1.0D0 - ELSE - A(I) = A(I-1) + A(I-2) - ENDIF - ENDDO - END -C END FILE FIB3.F -''' - -def source_func(ext, build_dir): - import os - from distutils.dep_util import newer - target = os.path.join(build_dir, 'fib3.f') - if newer(__file__, target): - f = open(target, 'w') - f.write(fib3_f) - f.close() - return [target] - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration('gen_ext', parent_package, top_path) - config.add_extension('fib3', - [source_func] - ) - return config - -if __name__ == "__main__": - from numpy.distutils.core import setup - setup(configuration=configuration) diff --git a/numpy/distutils/tests/gen_ext/tests/test_fib3.py b/numpy/distutils/tests/gen_ext/tests/test_fib3.py deleted file mode 100644 index e02ca8103..000000000 --- a/numpy/distutils/tests/gen_ext/tests/test_fib3.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import division, absolute_import, print_function - -from gen_ext import fib3 -from numpy.testing import TestCase, run_module_suite, assert_array_equal - -class TestFib3(TestCase): - def test_fib(self): - assert_array_equal(fib3.fib(6), [0, 1, 1, 2, 3, 5]) - -if __name__ == "__main__": - run_module_suite() diff --git a/numpy/distutils/tests/pyrex_ext/__init__.py b/numpy/distutils/tests/pyrex_ext/__init__.py deleted file mode 100644 index 1d0f69b67..000000000 --- a/numpy/distutils/tests/pyrex_ext/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import division, absolute_import, print_function diff --git a/numpy/distutils/tests/pyrex_ext/primes.pyx b/numpy/distutils/tests/pyrex_ext/primes.pyx deleted file mode 100644 index 2ada0c5a0..000000000 --- a/numpy/distutils/tests/pyrex_ext/primes.pyx +++ /dev/null @@ -1,22 +0,0 @@ -# -# Calculate prime numbers -# - -def primes(int kmax): - cdef int n, k, i - cdef int p[1000] - result = [] - if kmax > 1000: - kmax = 1000 - k = 0 - n = 2 - while k < kmax: - i = 0 - while i < k and n % p[i] <> 0: - i = i + 1 - if i == k: - p[k] = n - k = k + 1 - result.append(n) - n = n + 1 - return result diff --git a/numpy/distutils/tests/pyrex_ext/setup.py b/numpy/distutils/tests/pyrex_ext/setup.py deleted file mode 100644 index 819dd3154..000000000 --- a/numpy/distutils/tests/pyrex_ext/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python -from __future__ import division, print_function - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration('pyrex_ext', parent_package, top_path) - config.add_extension('primes', - ['primes.pyx']) - config.add_data_dir('tests') - return config - -if __name__ == "__main__": - from numpy.distutils.core import setup - setup(configuration=configuration) diff --git a/numpy/distutils/tests/pyrex_ext/tests/test_primes.py b/numpy/distutils/tests/pyrex_ext/tests/test_primes.py deleted file mode 100644 index 1ae436b65..000000000 --- a/numpy/distutils/tests/pyrex_ext/tests/test_primes.py +++ /dev/null @@ -1,13 +0,0 @@ -from __future__ import division, absolute_import, print_function - -from numpy.testing import TestCase, run_module_suite, assert_equal -from pyrex_ext.primes import primes - -class TestPrimes(TestCase): - def test_simple(self, level=1): - l = primes(10) - assert_equal(l, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) - - -if __name__ == "__main__": - run_module_suite() diff --git a/numpy/distutils/tests/setup.py b/numpy/distutils/tests/setup.py deleted file mode 100644 index 135de7c47..000000000 --- a/numpy/distutils/tests/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python -from __future__ import division, print_function - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration('testnumpydistutils', parent_package, top_path) - config.add_subpackage('pyrex_ext') - config.add_subpackage('f2py_ext') - #config.add_subpackage('f2py_f90_ext') - config.add_subpackage('swig_ext') - config.add_subpackage('gen_ext') - return config - -if __name__ == "__main__": - from numpy.distutils.core import setup - setup(configuration=configuration) diff --git a/numpy/distutils/tests/swig_ext/__init__.py b/numpy/distutils/tests/swig_ext/__init__.py deleted file mode 100644 index 1d0f69b67..000000000 --- a/numpy/distutils/tests/swig_ext/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import division, absolute_import, print_function diff --git a/numpy/distutils/tests/swig_ext/setup.py b/numpy/distutils/tests/swig_ext/setup.py deleted file mode 100644 index f6e07303b..000000000 --- a/numpy/distutils/tests/swig_ext/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -from __future__ import division, print_function - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration('swig_ext', parent_package, top_path) - config.add_extension('_example', - ['src/example.i', 'src/example.c'] - ) - config.add_extension('_example2', - ['src/zoo.i', 'src/zoo.cc'], - depends=['src/zoo.h'], - include_dirs=['src'] - ) - config.add_data_dir('tests') - return config - -if __name__ == "__main__": - from numpy.distutils.core import setup - setup(configuration=configuration) diff --git a/numpy/distutils/tests/swig_ext/src/example.c b/numpy/distutils/tests/swig_ext/src/example.c deleted file mode 100644 index be151725c..000000000 --- a/numpy/distutils/tests/swig_ext/src/example.c +++ /dev/null @@ -1,14 +0,0 @@ -/* File : example.c */ - -double My_variable = 3.0; - -/* Compute factorial of n */ -int fact(int n) { - if (n <= 1) return 1; - else return n*fact(n-1); -} - -/* Compute n mod m */ -int my_mod(int n, int m) { - return(n % m); -} diff --git a/numpy/distutils/tests/swig_ext/src/example.i b/numpy/distutils/tests/swig_ext/src/example.i deleted file mode 100644 index f4fc11e66..000000000 --- a/numpy/distutils/tests/swig_ext/src/example.i +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- c -*- */ - -/* File : example.i */ -%module example -%{ -/* Put headers and other declarations here */ -extern double My_variable; -extern int fact(int); -extern int my_mod(int n, int m); -%} - -extern double My_variable; -extern int fact(int); -extern int my_mod(int n, int m); diff --git a/numpy/distutils/tests/swig_ext/src/zoo.cc b/numpy/distutils/tests/swig_ext/src/zoo.cc deleted file mode 100644 index 0a643d1e5..000000000 --- a/numpy/distutils/tests/swig_ext/src/zoo.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include "zoo.h" -#include <cstdio> -#include <cstring> - -Zoo::Zoo() -{ - n = 0; -} - -void Zoo::shut_up(char *animal) -{ - if (n < 10) { - strcpy(animals[n], animal); - n++; - } -} - -void Zoo::display() -{ - int i; - for(i = 0; i < n; i++) - printf("%s\n", animals[i]); -} diff --git a/numpy/distutils/tests/swig_ext/src/zoo.h b/numpy/distutils/tests/swig_ext/src/zoo.h deleted file mode 100644 index cb26e6cef..000000000 --- a/numpy/distutils/tests/swig_ext/src/zoo.h +++ /dev/null @@ -1,9 +0,0 @@ - -class Zoo{ - int n; - char animals[10][50]; -public: - Zoo(); - void shut_up(char *animal); - void display(); -}; diff --git a/numpy/distutils/tests/swig_ext/src/zoo.i b/numpy/distutils/tests/swig_ext/src/zoo.i deleted file mode 100644 index a029c03e8..000000000 --- a/numpy/distutils/tests/swig_ext/src/zoo.i +++ /dev/null @@ -1,10 +0,0 @@ -// -*- c++ -*- -// Example copied from http://linuxgazette.net/issue49/pramode.html - -%module example2 - -%{ -#include "zoo.h" -%} - -%include "zoo.h" diff --git a/numpy/distutils/tests/swig_ext/tests/test_example.py b/numpy/distutils/tests/swig_ext/tests/test_example.py deleted file mode 100644 index 81b82c849..000000000 --- a/numpy/distutils/tests/swig_ext/tests/test_example.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import division, absolute_import, print_function - -from numpy.testing import TestCase, run_module_suite, assert_equal -from swig_ext import example - -class TestExample(TestCase): - def test_fact(self): - assert_equal(example.fact(10), 3628800) - - def test_cvar(self): - assert_equal(example.cvar.My_variable, 3.0) - example.cvar.My_variable = 5 - assert_equal(example.cvar.My_variable, 5.0) - - -if __name__ == "__main__": - run_module_suite() diff --git a/numpy/distutils/tests/swig_ext/tests/test_example2.py b/numpy/distutils/tests/swig_ext/tests/test_example2.py deleted file mode 100644 index 381b30d6a..000000000 --- a/numpy/distutils/tests/swig_ext/tests/test_example2.py +++ /dev/null @@ -1,15 +0,0 @@ -from __future__ import division, absolute_import, print_function - -from numpy.testing import TestCase, run_module_suite -from swig_ext import example2 - -class TestExample2(TestCase): - def test_zoo(self): - z = example2.Zoo() - z.shut_up('Tiger') - z.shut_up('Lion') - z.display() - - -if __name__ == "__main__": - run_module_suite() diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index 42113676a..e3205837c 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -167,13 +167,6 @@ class NoseTester(object): want to initialize `NoseTester` objects on behalf of other code. """ - # Stuff to exclude from tests. These are from numpy.distutils - excludes = ['f2py_ext', - 'f2py_f90_ext', - 'gen_ext', - 'pyrex_ext', - 'swig_ext'] - def __init__(self, package=None, raise_warnings="release", depth=0): # Back-compat: 'None' used to mean either "release" or "develop" # depending on whether this was a release or develop version of @@ -295,9 +288,6 @@ class NoseTester(object): import_nose() # compile argv argv = self._test_argv(label, verbose, extra_argv) - # bypass tests noted for exclude - for ename in self.excludes: - argv += ['--exclude', ename] # our way of doing coverage if coverage: argv += ['--cover-package=%s' % self.package_name, '--with-coverage', |