jronayne / PyTransport

A Python Package for the calculation of inflationary correlation functions.
Other
17 stars 3 forks source link

[JOSS] Installation failure #3

Open joezuntz opened 6 years ago

joezuntz commented 6 years ago

Hi. This is an issue as part of my review for JOSS.

I cloned the repository master branch and followed the instructions in Docs/UserGuide2.pdf

I tried to run the attached file (which github made me add ".txt" to the end of to be able to attach it). I got the following result:

Joes-MacBook-Pro:PyTransport jaz$ python test1.py
running install
error: must supply either home or prefix/exec-prefix -- not both
Traceback (most recent call last):
  File "test1.py.txt", line 11, in <module>
    PyTransSetup.compileName('joe')
  File "/Users/jaz/src/PyTransport/PyTransport/PyTransSetup.py", line 115, in compileName
    shutil.rmtree(location+"/build/")
  File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 239, in rmtree
    onerror(os.listdir, path, sys.exc_info())
  File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 237, in rmtree
    names = os.listdir(path)
OSError: [Errno 2] No such file or directory: '/Users/jaz/src/PyTransport/PyTransport/PyTrans//build/'

When I made that directory and continued I got the first part of the error again:

Joes-MacBook-Pro:PyTransport jaz$ mkdir /Users/jaz/src/PyTransport/PyTransport/PyTrans//build
Joes-MacBook-Pro:PyTransport jaz$ python test1.py.txt 
running install
error: must supply either home or prefix/exec-prefix -- not both

I also noticed that doing this modified some of the version-controlled files, which is pretty surprising and non-standard behaviour. You might want to remove code that will be overwritten from version control.

Joes-MacBook-Pro:PyTransport jaz$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   PyTransport/CppTrans/potential.h
    modified:   PyTransport/PyTrans/PyTrans.cpp
    modified:   PyTransport/PyTrans/moduleSetup.py
    modified:   PyTransport/PyTransSetup.pyc

Attached file: test1.py.txt

jronayne commented 6 years ago

Thank you very much for this and the time you are taking to review the code, and apologies it has not worked for you out of the box. The reason there is an error with the build folder is that folder is created when the installation takes place but because the installation is failing for you no folder is created and hence the error. The installation error itself "error: must supply either home or prefix/exec-prefix -- not both” we have not encountered before. A similar error seems to be documented to occur using pip install with a target directory with hombrew’s python installation. Could we ask what python installation you are using? And perhaps you could try the recommended fix https://stackoverflow.com/questions/24257803/distutilsoptionerror-must-supply-either-home-or-prefix-exec-prefix-not-both answer 19 — by adding the setup.cfg file to the PyTrans/ folder . We appreciate it is not your job to fix bugs, but this would help us to address this issue — otherwise perhaps you can give us the specifics of your python installation and we will try and replicate the issue locally.

On the files that under version control, we see the issue here, but the problem is that only a part of the last three files are edited automatically during setup, to remove them from version control would mean no version control on the other parts of these files, which may well be edited during development…… We will have to think what is best.

joezuntz commented 6 years ago

Thanks - the fix you suggested worked for me. Might be worth making this happen automaticaly? The error was coming from this line in PyTransSetup.py:

subprocess.call(["python", filename1, "install", "--home=" + location],cwd=location)

Things now continue to this error:

Joes-MacBook-Pro:temo jaz$ python ../test1.py.txt 
running install
running build
running build_ext
building 'PyTransjoe' extension
creating build
creating build/temp.macosx-10.12-x86_64-2.7
creating build/temp.macosx-10.12-x86_64-2.7/Users
creating build/temp.macosx-10.12-x86_64-2.7/Users/jaz
creating build/temp.macosx-10.12-x86_64-2.7/Users/jaz/src
creating build/temp.macosx-10.12-x86_64-2.7/Users/jaz/src/PyTransport
creating build/temp.macosx-10.12-x86_64-2.7/Users/jaz/src/PyTransport/PyTransport
creating build/temp.macosx-10.12-x86_64-2.7/Users/jaz/src/PyTransport/PyTransport/PyTrans
creating build/temp.macosx-10.12-x86_64-2.7/Users/jaz/src/PyTransport/PyTransport/CppTrans
creating build/temp.macosx-10.12-x86_64-2.7/Users/jaz/src/PyTransport/PyTransport/CppTrans/stepper
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.14_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c /Users/jaz/src/PyTransport/PyTransport/PyTrans/PyTrans.cpp -o build/temp.macosx-10.12-x86_64-2.7/Users/jaz/src/PyTransport/PyTransport/PyTrans/PyTrans.o
/Users/jaz/src/PyTransport/PyTransport/PyTrans/PyTrans.cpp:20:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1

The missing header seems to be in a fairly standard location: /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h on my system. I fixed this with a stackoverflow idea to do this first: export CFLAGS="-I /usr/local/lib/python2.7/site-packages/numpy/core/include" It might be possible to do that automatically somehow?

jronayne commented 6 years ago

Glad to hear that has worked. We have added the setup.cfg file so this should no longer be an issue in the future. As you have suggested I have also added export CFLAGS="-I /usr/local/lib/python2.7/site-packages/numpy/core/include" to the PyTransSetup.py script so this is automated from now on. Thanks again for taking the time to find this fix and review the code.