10000 f2py test fail in pip installed numpy-1.10.1 in virtualenv · Issue #6718 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

f2py test fail in pip installed numpy-1.10.1 in virtualenv #6718

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
joernhees opened this issue Nov 25, 2015 · 31 comments
Closed

f2py test fail in pip installed numpy-1.10.1 in virtualenv #6718

joernhees opened this issue Nov 25, 2015 · 31 comments

Comments

@joernhees
Copy link
Contributor

running python -c 'import numpy ; numpy.test();' i get the following error about test_f2py:

$ python -c 'import numpy ; numpy.test();'
Running unit tests for numpy
NumPy version 1.10.1
NumPy relaxed strides checking option: True
NumPy is installed in /usr/local/lib/python2.7/site-packages/numpy
Python version 2.7.10 (default, Jul 13 2015, 12:05:58) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]
nose version 1.3.7
......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................K................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................K...SK.S.......S...................................................................................clang: warning: -Wl,-rpath=/var/folders/95/hl31m68d6ks1d8txd27wxq000000gn/T/tmpGRMpd5/libbar.so: 'linker' input unused
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S......................................................................................................................S.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................E
======================================================================
ERROR: test_scripts.test_f2py
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/local/lib/python2.7/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/numpy/tests/test_scripts.py", line 68, in test_f2py
    code, stdout, stderr = run_command([f2py_cmd, '-v'])
  File "/usr/local/lib/python2.7/site-packages/numpy/tests/test_scripts.py", line 48, in run_command
    proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

----------------------------------------------------------------------
Ran 5919 tests in 35.478s

FAILED (KNOWNFAIL=3, SKIP=7, errors=1)
@charris
Copy link
Member
charris commented Nov 25, 2015

Ah, OS X. IIRC, pip is not recommended for the mac, homebrew or one of the other third party package managers is preferred.

@joernhees
Copy link
Contributor Author

hmmm, well pip is much better supported inside virtualenv and usually more up to date than 3rd party managers... previous versions worked like a charm if you installed non-python dependencies with brew... http://joernhees.de/blog/2014/02/25/scientific-python-on-mac-os-x-10-9-with-homebrew/

as all other tests pass like a charm, i actually suspect this to be a test issue rather than a real one: https://github.com/numpy/numpy/blob/master/numpy/tests/test_scripts.py#L67

@pv
Copy link
Member
pv commented Nov 25, 2015

The assumption in the test that f2pyX.Y (or a correct version of it) is in the PATH is often not true on Linux either. The test seems to be testing something that's not guaranteed in general.

@joernhees
Copy link
Contributor Author

i inserted a print statement after the line linked above:

        f2py_cmd = 'f2py' + basename(sys.executable)[6:]
        print f2py_cmd
        code, stdout, stderr = run_command([f2py_cmd, '-v'])

prints f2py2.7 just before the test fails... the file installed by pip is in /usr/local/bin/f2py, so it's no wonder that trying to call f2py2.7 fails, as it should just be f2py.

@charris
Copy link
Member
charris commented Nov 25, 2015

Hmm, OK.

@joernhees
Copy link
Contributor Author

i went ahead to test this in a virtualenv on a Ubuntu 14.04 server i have... didn't break, but observe this:

(np)hees@server:~/tmp$ f2py
f2py         f2py2.7      f2py2.7-dbg  f2py3        f2py3.4      f2py3.4-dbg  f2py3-dbg    f2py-dbg
(np)hees@server:~/tmp$ which f2py
/home/hees/tmp/np/bin/f2py
(np)hees@server:~/tmp$ which f2py2.7
/usr/bin/f2py2.7

it seems as if the system-wide installed python-numpy debian package provides a f2py2.7, which seems to be called by the test... if that isn't installed the test will fail, as you can try yourself with a fresh docker debian container:

# start container
docker run --rm -it debian
# inside container:
apt-get update && apt-get install python python-pip python-dev python-virtualenv
virtualenv venv
. venv/bin/activate
pip install numpy nose
python -c 'import numpy ; numpy.test();'

so it's definitely not only a mac issue (will change title), but rather a pip install issue? i think the idea to deduce the f2py name from sys.executable is just not really portable

@joernhees joernhees changed the title f2py test fail in pip installed numpy-1.10.1 on Mac OS X 10.10.5 f2py test fail in pip installed numpy-1.10.1 in virtualenv Nov 25, 2015
@charris
Copy link
Member
charris commented Nov 25, 2015

I've got both f2py and f2py2.7, they are just short scripts that import from numpy.

!/usr/bin/python
# See http://cens.ioc.ee/projects/f2py2e/
import os
import sys
for mode in ["g3-numpy", "2e-numeric", "2e-numarray", "2e-numpy"]:
    try:
        i = sys.argv.index("--" + mode)
        del sys.argv[i]
        break
    except ValueError:
        pass
os.environ["NO_SCIPY_IMPORT"] = "f2py"
if mode == "g3-numpy":
    sys.stderr.write("G3 f2py support is not implemented, yet.\\n")
    sys.exit(1)
elif mode == "2e-numeric":
    from f2py2e import main
elif mode == "2e-numarray":
    sys.argv.append("-DNUMARRAY")
    from f2py2e import main
elif mode == "2e-numpy":
    from numpy.f2py import main
else:
    sys.stderr.write("Unknown mode: " + repr(mode) + "\\n")
    sys.exit(1)
main()

The tests should probably skip all that and go directly to numpy.f2py.

@charris
Copy link
Member
charris commented Nov 25, 2015

For instance

python -c'from numpy.f2py import main; main()' -v

seems to do what is intended at the point of failure.

@joernhees
Copy link
Contributor Author

i think the failing test actually intends to somehow make sure that the f2py script is callable on the command line...

the problem is that it does weird failing magic to determine the different names f2py was installed as... and it assumes that the installing sys.executable name is the same as the one running the tests...

until now in my tests i didn't encounter a single environment setup where no f2py was present but only a f2py2.7...

so maybe to cover the intention of the test better it would be easiest to just trying to call f2py on all *nix systems and rely on the PATH to give us the right script?

@joernhees
Copy link
Contributor Author

so a simple change of https://github.com/numpy/numpy/blob/master/numpy/tests/test_scripts.py#L67

        f2py_cmd = 'f2py' + basename(sys.executable)[6:]

to

        f2py_cmd = 'f2py'

@pv
Copy link
Member
pv commented Nov 25, 2015

It's not guaranteed that any f2py is available on PATH: pip install --user installs scripts to ~/.local/bin which is not necessarily on path.

@joernhees
Copy link
Contributor Author

hmm, didn't think about that :-/ but wouldn't the current version with Popen(cmd,...) fail in that case as well?

@pv
Copy link
Member
pv commented Nov 25, 2015

Yes, any test that assumes the f2py script is available on PATH fails in this case. I don't think there's a reliable way to locate where the script got installed, except maybe somehow via pip's install record file.

@matthew-brett
Copy link
Contributor

Chuck - pip is the standard way to install on the Mac, I think.

I'm guessing it's me who put in the test, to test for the problem we had previously where the executable was not correctly installed : #5817

It would be a shame not to test that bug, but of @pv is right, there's no guarantee the install put the script onto the users path. On the other hand, the case of instal --user without the user binary install directory on the path is the only common one I can think of.

@njsmith
Copy link
Member
njsmith commented Nov 25, 2015

I guess one could argue that it's fair to raise a test failure when the
user install directory isn't on the path, to warn people that their setup
is broken and they should add the user install directory to their path :-).
On Nov 25, 2015 8:28 AM, "Matthew Brett" notifications@github.com wrote:

Chuck - pip is the standard way to install on the Mac, I think.

I'm guessing it's me who put in the test, to test for the problem we had
previously where the executable was not correctly installed : #5817
#5817

It would be a shame not to test that bug, but of @pv
https://github.com/pv is right, there's no guarantee the install put
the script onto the users path. On the other hand, the case of instal
--user without the user binary install directory on the path is the only
common one I can think of.


Reply to this email directly or view it on GitHub
#6718 (comment).

@joernhees
Copy link
Contributor Author

i'd be happy if it raises an error if f2py is missing, as long as a missing f2py2.7 isn't a problem ;)

@andrewgrapentin
Copy link

Putting this here for the experts to consider.

Fedora 23 VM
.bash_profile includes:

PATH=$HOME/local/Python35/bin:$PATH
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
#Load variables for Intel Parallel Studio 
source /opt/intel/compilers_and_libraries/linux/bin/compilervars.sh intel64

Python 3.5.1rc1 install:

./configure --prefix=$HOME/local/Python35 --enable-loadable-sqlite-extensions CFLAGS=-fPIC
make
make install
ln -s /home/andrew/local/Python35/bin/python3 /home/andrew/local/Python35/bin/python
ln -s /home/andrew/local/Python35/bin/pip3 /home/andrew/local/Python35/bin/pip

Numpy 1.10.2rc1 install -- with edits for intel mkl to site.cfg, intelccompiler.py and intel.py. installed from source dir using:

pip install --global-option=config --global-option="--compiler=intelem" --global-option=build_clib --global-option="--compiler=intelem" --global-option=build_ext --global-option="--compiler=intelem" -v .

Now the relevant (i think) part

[andrew@localhost ~]$ python -c 'import numpy; numpy.test("full");'
Running unit tests for numpy
NumPy version 1.10.2rc1
NumPy relaxed strides checking option: True
NumPy is installed in /home/andrew/local/Python35/lib/python3.5/site-packages/numpy
Python version 3.5.1rc1 (default, Dec  2 2015, 14:58:12) [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)]
nose version 1.3.7

Known fails and warnings removed

======================================================================
ERROR: test_scripts.test_f2py
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/andrew/local/Python35/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/andrew/local/Python35/lib/python3.5/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "/home/andrew/local/Python35/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 68, in test_f2py
    code, stdout, stderr = run_command([f2py_cmd, '-v'])
  File "/home/andrew/local/Python35/lib/python3.5/site-packages/numpy/tests/test_scripts.py", line 48, in run_command
    proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
  File "/home/andrew/local/Python35/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/home/andrew/local/Python35/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'f2py'

----------------------------------------------------------------------
Ran 6155 tests in 144.203s

FAILED (KNOWNFAIL=4, SKIP=4, errors=1)

no f2py in path, only f2py3.5 in Python35/bin, result of some test I don't understand thrown in

[andrew@localhost ~]$ which f2py
/usr/bin/which: no f2py in (/opt/intel/compilers_and_libraries_2016.1.150/linux/bin/intel64:/opt/intel/compilers_and_libraries_2016.1.150/linux/mpi/intel64/bin:/opt/intel/debugger_2016/gdb/intel64_mic/bin:/home/andrew/local/Python35/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/andrew/.local/bin:/home/andrew/bin)
[andrew@localhost ~]$ ls local/Python35/bin/
2to3              f2py3.5  nosetests      pip3    pydoc3.5  python3.5         python3.5m-config  pyvenv-3.5
2to3-3.5          idle3    nosetests-3.5  pip3.5  python    python3.5-config  python3-config
easy_install-3.5  idle3.5  pip            pydoc3  python3   python3.5m        pyvenv
[andrew@localhost ~]$ python -c'from numpy.f2py import main; main()' -v
2

Can i just create a symlink for f2py that points to f2py3.5 ?

@andrewgrapentin
Copy link

Hopefully this does not break something else.

cd ~/local/Python35/bin
ln -s f2py3.5 f2py
[andrew@localhost bin]$ python -c 'import numpy; numpy.test();'
Running unit tests for numpy
NumPy version 1.10.2rc1
NumPy relaxed strides checking option: True
NumPy is installed in /home/andrew/local/Python35/lib/python3.5/site-packages/numpy
Python version 3.5.1rc1 (default, Dec  2 2015, 14:58:12) [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)]
nose version 1.3.7
..............................S.....................................................
----------------------------------------------------------------------
Ran 5972 tests in 35.126s

OK (KNOWNFAIL=4, SKIP=4)

@charris charris closed this as completed in e3243e2 Dec 5, 2015
charris added a commit that referenced this issue Dec 5, 2015
TST: only test f2py, not f2py2.7 etc, fixes #6718
charris pushed a commit to charris/numpy that referenced this issue Dec 5, 2015
@charris charris mentioned this issue Dec 5, 2015
colbych added a commit to colbych/numpy that referenced this issue Dec 6, 2015
* 'master' of git://github.com/numpy/numpy: (24 commits)
  BENCH: allow benchmark suite to run on Python 3
  TST: test f2py, fallback on f2py2.7 etc., fixes numpy#6718
  BUG: link cblas library if cblas is detected
  BUG/TST: Fix for numpy#6724, make numpy.ma.mvoid consistent with numpy.void
  BUG/TST: Fix numpy#6760 by correctly describing mask on nested subdtypes
  BUG: resizing empty array with complex dtype failed
  DOC: Add changelog for numpy#6734 and numpy#6748.
  Use integer division to avoid casting to int.
  Allow to change the maximum width with a class variable.
  Add some tests for mask creation with mask=True or False.
  Test that the mask dtype if MaskType before using np.zeros/ones
  BUG/TST: Fix for numpy#6729
  ENH: Avoid memory peak and useless computations when printing a MaskedArray.
  ENH: Avoid memory peak when creating a MaskedArray with mask=True/False (numpy#6732).
  BUG: Readd fallback CBLAS detection on linux.
  TST: Fix travis-ci test for numpy wheels.
  MAINT: Localize variables only used with relaxed stride checking.
  BUG: Fix for numpy#6719
  MAINT: enable Werror=vla in travis
  BUG: Include relevant files from numpy/linalg/lapack_lite in sdist.
  ...
@jwhowarth
Copy link

This problem still exists with numpy 1.10.2rc2 on x86_64-apple-darwin15 and should be re-opened.

@charris charris reopened this Dec 12, 2015
@charris
Copy link
Member
charris commented Dec 12, 2015

I think I will just disable/remove the test. It seems to depend to much on factors out of our control. @matthew-brett @njsmith Thoughts?

@charris
Copy link
Member
charris commented Dec 12, 2015

Maybe just raise a warning?

@matthew-brett
Copy link
Contributor

I worry that we can easily get this wrong again in the future.

How about checking that, if f2py or f2py<pyver> are on the path, they run correctly, and otherwise raising a warning?

@njsmith
Copy link
Member
njsmith commented Dec 12, 2015

Maybe we could make the test only run on our well-controlled CI infrastructure, and skip it when running on arbitrary end user systems?

@charris
Copy link
Member
charris commented Dec 14, 2015

If this test fails it doesn't hurt anything, right? On the other hand, it seems that it doesn't always help either. The current error message is "wasn't able to find f2py or %s on commandline". Would it be resonable to leave as an error, but change the message to something like "Warning: neither %s nor %s found in path". Here I wonder if it is safe to keep the search for bare "f2py"?

@njsmith
Copy link
Member
njsmith commented Dec 14, 2015

IIUC the point of the test is to alert us in case we break the script entry point (again) -- Matthew correct me if I'm wrong.

Assuming that's correct, then a warning doesn't seem fit-for-purpose to me, because we generally only look at travis-ci test output when some test actually fails. If it's just a warning we'll likely miss it.

OTOH it sounds like there may be no way to make the test fully reliable on random end user machines, which causes user distress and confusion (as we've seen), so maybe a warning makes sense here... or possibly no message at all? No idea if users care about seeing this or whether it would just cause more confusion.

@jwhowarth
Copy link

Still present in released 1.10.2. Any suggestions on how to convert this test from an error to a warning?

======================================================================
ERROR: test_scripts.test_f2py
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/sw/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/sw/src/fink.build/root-numpy-py27-1.10.2-1/sw/lib/python2.7/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "/sw/src/fink.build/root-numpy-py27-1.10.2-1/sw/lib/python2.7/site-packages/numpy/tests/test_scripts.py", line 79, in test_f2py
    except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined

----------------------------------------------------------------------
Ran 5931 tests in 41.548s

@charris
Copy link
Member
charris commented Dec 14, 2015

Hmm, FileNotFoundError is a Python3 only thing. I think I'm going to really regret leaving this test in for 1.10.2...

@rgommers
Copy link
Member

gh-6916 should have fixed the test_f2py issue. Do we need to keep this open (the test can still fail)?

@charris
Copy link
Member
charris commented Jan 16, 2016

Might as well close. It is possible that the test could still fail, but if that happens we can deal with it then.

@texastony
Copy link

I have built numpy from source on several platforms (AMD64 and Intel64) against BLAS and Intel MKL. In most occasions, I build for python3.6. I have never had the f2py build or test pass successfully with out manually editing the code. In particular, in the file:
numpy/f2py/__version__.py, major is hard coded to be 2. Which is confusing. As f2py's setup.py file calls os.path.basename(sys.executable)[6:] to determine the version name again. Actually, without being adjusted manually, I never build f2py as it's setup gets multiple values for version: the value hard coded and the value returned from sys.executable and the one returned from version.py.

Frankly, it's all a little nuts, and could be fixed right quick.

I can make a pull request that would change numpy/f2py__version__.py , numpy/tests/test_scripts.py ( which is likewise hard coded to check that f2py<> -v returns 2), and numpy/f2py/setup.py so that it constantly only has one version value which would be equivalent to sys.version_info.major + '_' + np.__version__. (Though clearly not that way, but instead using the svn version method).

Looking at insights, it would appear that Pearu Peterson is no longer active on f2py, but would @charris mind? Does that sound reasonable?

@charris
Copy link
Member
charris commented Oct 17, 2018

PRs are always welcome. f2py used to be a separate package and there are still lots of odd bits scattered about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants
0