8000 BUG: Fixes for building on Cygwin. by DWesl · Pull Request #16246 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fixes for building on Cygwin. #16246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
46409ed
BLD: Move the configuration defines in Python.h earlier.
DWesl May 14, 2020
058cfa1
DEV: Try to rebase f2py-created modules for fewer fork() failures in …
DWesl May 14, 2020
5c9f8a0
TST: Mark the tests that seem to fail due to different floating-point…
DWesl May 14, 2020
973b14b
TST: Try to mark the tests still suseptible to fork() failures on cyg…
DWesl May 14, 2020
acea157
DEV: Revert executable renames for F77/G77 compiler.
DWesl May 18, 2020
34184fd
BLD: Add functions that fail tests on Cygwin to npy_config.h.
DWesl May 18, 2020
9c07574
TST: Describe what I know about the FPE test failure.
DWesl May 18, 2020
df5b0c6
STY: A few largely cosmetic changes.
DWesl May 18, 2020
8b11932
DEV: Stop trying to rebase f2py modules.
DWesl May 18, 2020
fc56c79
Remove xfails from tests that now pass.
DWesl May 19, 2020
10dae6e
Use parametrize for the dtypes in the abs tests.
DWesl May 19, 2020
debf846
Remove xfail mark from an assert function.
DWesl May 20, 2020
b530f99
Remove references to np.complex256
DWesl May 25, 2020
c11ee6f
Remove reference to np.complex256 in the other test
DWesl May 25, 2020
1a2292f
Don't add `gfortran` to the list of GNU77 compilers
DWesl May 29, 2020
20df822
Include only 'gfortran' in gnu fcompiler, not absolute version
DWesl Jun 6, 2020
52b9ed5
Merge branch 'master' into cygwin-fixes
DWesl Jul 9, 2020
6a16452
TST: Use usual names for the dtypes in xfail mark
DWesl Jul 9, 2020
92eaff3
BLD: Remind GCC that .seh_savexmm fails for xmm16-31.
DWesl Jun 17, 2020
d9c21bb
BLD: Fix code checking for old GCC on cygwin.
DWesl Jun 19, 2020
eca1e27
TST: Only mark fork()-using tests xfail on 32-bit cygwin.
DWesl Jun 19, 2020
6ffbcb2
BLD: Fix flags added to compiler line for old GCC on MS.
DWesl Jun 19, 2020
5adbca1
TST: parametrize test_npymath_complex.
DWesl Jul 9, 2020
51fbbb8
TST: Clarify the xfail messages for branch cuts.
DWesl Aug 29, 2020
f47f315
BLD: Remove probably-unnecessary include.
DWesl Aug 29, 2020
5cb8a0f
TST: Try to keep testing code from changing tempfile name.
DWesl Aug 23, 2020
ced41b5
BLD: Mark modfl as problematic on cygwin.
DWesl Aug 29, 2020
d706499
Undef HAVE_MODFL only on 64-bit cygwin
DWesl Sep 1, 2020
160fd73
Revert "BLD: Fix flags added to compiler line for old GCC on MS."
DWesl Oct 27, 2020
cc9e8df
Revert "BLD: Fix code checking for old GCC on cygwin."
DWesl Oct 27, 2020
e18c4b6
Revert "BLD: Remind GCC that .seh_savexmm fails for xmm16-31."
DWesl Oct 27, 2020
4abffbd
Merge branch 'master' into cygwin-fixes
charris Dec 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions numpy/core/include/numpy/npy_common.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#ifndef _NPY_COMMON_H_
#define _NPY_COMMON_H_

/* need Python.h for npy_intp, npy_uintp */
#include <Python.h>

/* numpconfig.h is auto-generated */
#include "numpyconfig.h"
#ifdef HAVE_NPY_CONFIG_H
#include <npy_config.h>
#endif

/* need Python.h for npy_intp, npy_uintp */
#include <Python.h>

/*
* using static inline modifiers when defining npy_math functions
* allows the compiler to make optimizations when possible
Expand Down
49 changes: 49 additions & 0 deletions numpy/core/src/common/npy_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,55 @@
#endif
#endif /* defined(_MSC_VER) && defined(__INTEL_COMPILER) */

/* Disable functions that give undesired floating-point outputs on
Cygwin. */
#ifdef __CYGWIN__

#undef HAVE_CABS
#undef HAVE_CABSF
#undef HAVE_CABSL

/* These work for me in C++, even for the failing test case (2 ** 29),
but the tests fail. No idea if the functions I'm getting are used
or not. */
#undef HAVE_LOG2
#undef HAVE_LOG2F
#undef HAVE_LOG2L

/* Complex square root does not use sign of zero to find branch
cuts. */
#undef HAVE_CSQRT
#undef HAVE_CSQRTF
#undef HAVE_CSQRTL

/* C++ Real asinh works fine, complex asinh says asinh(1e-20+0j) =
0 */
#undef HAVE_CASINH
#undef HAVE_CASINHF
#undef HAVE_CASINHL

/* _check_branch_cut(np.arcsin, ...) fails */
#undef HAVE_CASIN
#undef HAVE_CASINF
#undef HAVE_CASINL

/* Branch cuts for arccosine also fail */
#undef HAVE_CACOS
#undef HAVE_CACOSF
#undef HAVE_CACOSL

/* Branch cuts for arctan fail as well */
#undef HAVE_CATAN
#undef HAVE_CATANF
#undef HAVE_CATANL

/* check_loss_of_precision fails in arctanh */
#undef HAVE_CATANH
#undef HAVE_CATANHF
#undef HAVE_CATANHL

#endif

/* powl gives zero division warning on OS X, see gh-8307 */
#if defined(HAVE_POWL) && defined(NPY_OS_DARWIN)
#undef HAVE_POWL
Expand Down
3 changes: 3 additions & 0 deletions numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -8262,6 +8262,9 @@ class MyAlwaysEqualNew(MyAlwaysEqual):
assert_equal(array != my_always_equal, 'ne')


@pytest.mark.xfail(sys.platform == 'cygwin',
reason='abs(inf+nanj) short-circuits to inf',
strict=True)
def test_npymath_complex():
# Smoketest npymath functions
from numpy.core._multiarray_tests import (
Expand Down
6 changes: 6 additions & 0 deletions numpy/core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,12 @@ def assert_op_raises_fpe(self, fpeerr, flop, sc1, sc2):
self.assert_raises_fpe(fpeerr, flop, sc1, sc2[()])
self.assert_raises_fpe(fpeerr, flop, sc1[()], sc2[()])

@pytest.mark.xfail(
sys.platform == "cygwin",
reason="complex256(2 ** (2 ** nexp_256)) is inf+infj without OverflowError",
raises=AssertionError,
strict=True,
)
def test_floating_exceptions(self):
# Test basic arithmetic function errors
with np.errstate(all='raise'):
Expand Down
87 changes: 61 additions & 26 deletions numpy/core/tests/test_scalarmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,32 +646,67 @@ def test_result(self):


class TestAbs:
def _test_abs_func(self, absfunc):
for tp in floating_types + complex_floating_types:
x = tp(-1.5)
assert_equal(absfunc(x), 1.5)
x = tp(0.0)
res = absfunc(x)
# assert_equal() checks zero signedness
assert_equal(res, 0.0)
x = tp(-0.0)
res = absfunc(x)
assert_equal(res, 0.0)

x = tp(np.finfo(tp).max)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).tiny)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).min)
assert_equal(absfunc(x), -x.real)

def test_builtin_abs(self):
self._test_abs_func(abs)

def test_numpy_abs(self):
self._test_abs_func(np.abs)
def _test_abs_func(self, absfunc, tp):
x = tp(-1.5)
assert_equal(absfunc(x), 1.5)
x = tp(0.0)
res = absfunc(x)
# assert_equal() checks zero signedness
assert_equal(res, 0.0)
x = tp(-0.0)
res = absfunc(x)
assert_equal(res, 0.0)

x = tp(np.finfo(tp).max)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).tiny)
assert_equal(absfunc(x), x.real)

x = tp(np.finfo(tp).min)
assert_equal(absfunc(x), -x.real)

@pytest.mark.parametrize(
"dtype",
[
pytest.param(
dtype,
marks=(
pytest.mark.xfail(
sys.platform == 'cygwin',
reason='abs(np.complex256.max) overflows',
raises=AssertionError,
strict=True,
)
if sys.platform == 'cygwin' and dtype == np.complex256 else ()
)
)
for dtype in floating_types + complex_floating_types
],
)
def test_builtin_abs(self, dtype):
self._test_abs_func(abs, dtype)

@pytest.mark.parametrize(
"dtype",
[
pytest.param(
dtype,
marks=(
pytest.mark.xfail(
sys.platform == 'cygwin',
reason='abs(np.complex256.max) overflows',
raises=RuntimeWarning,
strict=True,
)
if sys.platform == 'cygwin' and dtype == np.complex256 else ()
)
)
for dtype in floating_types + complex_floating_types
],
)
def test_numpy_abs(self, dtype):
self._test_abs_func(np.abs, dtype)


class TestBitShifts:
Expand Down
6 changes: 6 additions & 0 deletions numpy/core/tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,9 @@ def test_precisions_consistent(self):
assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s' % f)
assert_almost_equal(fcl, fcd, decimal=15, err_msg='fch-fcl %s' % f)

@pytest.mark.xfail(sys.platform == 'cygwin',
reason='0.7071j != 0.7071j, apparently',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reason='0.7071j != 0.7071j, apparently',
reason='Cygwin does not use the sign of zero for branch cuts along an axis',

strict=True)
def test_branch_cuts(self):
# check branch cuts and continuity on them
_check_branch_cut(np.log, -0.5, 1j, 1, -1, True)
Expand All @@ -2810,6 +2813,9 @@ def test_branch_cuts(self):
_check_branch_cut(np.arccosh, [0-2j, 2j, 2], [1, 1, 1j], 1, 1)
_check_branch_cut(np.arctanh, [0-2j, 2j, 0], [1, 1, 1j], 1, 1)

@pytest.mark.xfail(sys.platform == 'cygwin',
reason='square root faces small loss of precision',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reason='square root faces small loss of precision',
reason='Cygwin does not use the sign of zero for branch cuts along an axis.',

strict=True)
def test_branch_cuts_complex64(self):
# check branch cuts and continuity on them
_check_branch_cut(np.log, -0.5, 1j, 1, -1, True, np.complex64)
Expand Down
2 changes: 1 addition & 1 deletion numpy/distutils/fcompiler/gnu.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def get_flags_arch(self):
return []

def runtime_library_dir_option(self, dir):
if sys.platform == 'win32':
if sys.platform == 'win32' or sys.platform == 'cygwin':
# Linux/Solaris/Unix support RPATH, Windows does not
raise NotImplementedError

Expand Down
6 changes: 6 additions & 0 deletions numpy/f2py/tests/test_compile_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def setup_module():
"extra_args", [['--noopt', '--debug'], '--noopt --debug', '']
)
@pytest.mark.leaks_references(reason="Imported module seems never deleted.")
@pytest.mark.xfail(sys.platform == 'cygwin', reason="Random fork failures",
raises=BlockingIOError)
def test_f2py_init_compile(extra_args):
# flush through the f2py __init__ compile() function code path as a
# crude test for input handling following migration from
Expand Down Expand Up @@ -83,6 +85,8 @@ def test_f2py_init_compile(extra_args):
del sys.modules[modname]


@pytest.mark.xfail(sys.platform == 'cygwin', reason="Random fork failures",
raises=BlockingIOError)
def test_f2py_init_compile_failure():
# verify an appropriate integer status value returned by
# f2py.compile() when invalid Fortran is provided
Expand Down Expand Up @@ -111,6 +115,8 @@ def test_f2py_init_compile_bad_cmd():
@pytest.mark.parametrize('fsource',
['program test_f2py\nend program test_f2py',
b'program test_f2py\nend program test_f2py',])
@pytest.mark.xfail(sys.platform == 'cygwin', reason="Random fork failures",
raises=BlockingIOError)
def test_compile_from_strings(tmpdir, fsource):
# Make sure we can compile str and bytes gh-12796
cwd = os.getcwd()
Expand Down
6 changes: 6 additions & 0 deletions numpy/f2py/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ class F2PyTest:
module = None
module_name = None

# Pytest seems to ignore this, but I'm not sure where else to put
# it, besides trying to make a metaclass that decorates every
# method of a subclass of F2PyTest
@pytest.mark.xfail(sys.platform == 'cygwin',
reason='Fork() randomly fails on cygwin',
raises=BlockingIOError)
def setup(self):
if sys.platform == 'win32':
pytest.skip('Fails with MinGW64 Gfortran (Issue #9673)')
Expand Down
3 changes: 3 additions & 0 deletions numpy/linalg/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,9 @@ def test_xerbla_override():


@pytest.mark.slow
@pytest.mark.xfail(sys.platform == 'cygwin',
reason='Fork() fails randomly on cygwin',
raises=BlockingIOError)
def test_sdot_bug_8577():
# Regression test that loading certain other libraries does not
# result to wrong results in float32 linear algebra.
Expand Down
3 changes: 2 additions & 1 deletion numpy/random/src/distributions/random_hypergeometric.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Python.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in this file should require Python.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the declarations depend on types guarded by visibility macros set up in Python.h.
That problem seems to have resolved itself in the last six months or so, so removing this should be fine. I'll look into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "Python.h"

NumPy compiles without this change on latest Cygwin.

#include <stdint.h>
#include "numpy/random/distributions.h"
#include "logfactorial.h"
#include <stdint.h>

/*
* Generate a sample from the hypergeometric distribution.
Expand Down
3 changes: 3 additions & 0 deletions numpy/random/tests/test_extending.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

@pytest.mark.skipif(cython is None, reason="requires cython")
@pytest.mark.slow
@pytest.mark.xfail(sys.platform == "cygwin",
reason="Random fork() failures",
raises=BlockingIOError)
def test_cython(tmp_path):
srcdir = os.path.join(os.path.dirname(__file__), '..')
shutil.copytree(srcdir, tmp_path / 'random')
Expand Down
2 changes: 2 additions & 0 deletions numpy/tests/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def test_numpy_namespace():


@pytest.mark.parametrize('name', ['testing', 'Tester'])
@pytest.mark.xfail(sys.platform == 'cygwin', reason="Random fork failures",
raises=BlockingIOError)
def test_import_lazy_import(name):
"""Make sure we can actually use the modules we lazy load.

Expand Down
2 changes: 2 additions & 0 deletions numpy/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def test_f2py(f2py_cmd):
assert_equal(stdout.strip(), b'2')


@pytest.mark.xfail(sys.platform == 'cygwin', reason="Random fork failures",
raises=BlockingIOError)
def test_pep338():
stdout = subprocess.check_output([sys.executable, '-mnumpy.f2py', '-v'])
assert_equal(stdout.strip(), b'2')
0