Skip to content
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

Build issue on Windows #16

Open
deto opened this issue May 11, 2016 · 6 comments
Open

Build issue on Windows #16

deto opened this issue May 11, 2016 · 6 comments

Comments

@deto
Copy link

deto commented May 11, 2016

I'm getting an error trying to install this on Windows. At first I tried this using conda, and after it failed there, I tried using just a barebones python2.7 install.

It seems that the issue stems from the fact that the Visual C++ for Python compiler that Microsoft released does not include an lgamma in its math.h

This appears to be the only issue. If I just replace the call to lgamma (in cfisher.c) with '0', then the package builds just fine.

See output from building a wheel below.

C:\Users\David\fishers_exact_test>C:\Python27\Scripts\pip.exe wheel --wheel-dir=wheel .
Processing c:\users\david\fishers_exact_test
Building wheels for collected packages: fisher
  Running setup.py bdist_wheel for fisher ... error
  Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\david\\appdata\\local\\temp\\pip-cljy6z-build\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d c:\users\david\appdata\local\temp\tmpih00pjpip-wheel-:
  running bdist_wheel
  running build
  running build_py
  running build_ext
  building 'fisher.cfisher' extension
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  creating build\temp.win-amd64-2.7\Release\src
  C:\Users\David\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include -Ic:\python27\PC /Tcsrc/cfisher.c /Fobuild\temp.win-amd64-2.7\Release\src/cfisher.obj -O3
  cl : Command line warning D9002 : ignoring unknown option '-O3'
  cfisher.c
  c:\python27\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
  src/cfisher.c(2106) : warning C4013: 'lgamma' undefined; assuming extern returning int
  src/cfisher.c(3442) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
  C:\Users\David\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\python27\libs /LIBPATH:c:\python27\PCbuild\amd64 /LIBPATH:c:\python27\PC\VS9.0\amd64 /EXPORT:initcfisher build\temp.win-amd64-2.7\Release\src/cfisher.obj /OUT:build\lib.win-amd64-2.7\fisher\cfisher.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\src\cfisher.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\src\cfisher.pyd.manifest
  cfisher.obj : warning LNK4197: export 'initcfisher' specified multiple times; using first specification
     Creating library build\temp.win-amd64-2.7\Release\src\cfisher.lib and object build\temp.win-amd64-2.7\Release\src\cfisher.exp
  cfisher.obj : error LNK2019: unresolved external symbol lgamma referenced in function __pyx_f_7cfisher_lnfactorial
  build\lib.win-amd64-2.7\fisher\cfisher.pyd : fatal error LNK1120: 1 unresolved externals
  error: command 'C:\\Users\\David\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1120

  ----------------------------------------
  Failed building wheel for fisher
  Running setup.py clean for fisher
Failed to build fisher
ERROR: Failed to build one or more wheels
@brentp
Copy link
Owner

brentp commented May 11, 2016

maybe we need:

extra_compile_args = ['-O3', '-std=c99'] 

in setup.py (line 10)

can you try that and let me know if it works. I don't have access to a windows machine for testing.

@deto
Copy link
Author

deto commented May 11, 2016

Didn't help. The real issue seems to be that there just isn't any lgamma
function in math.h for the Windows C compiler. To verify, I opened the
file myself on my system and yep, definitely no lgamma.

See here for a compatibility table: http://www.johndcook.com/blog/math_h/

It seems to be the only function that's causing an issue, though. It all
builds if I just remove lgamma (though of course, it's non-functional then).

It looks like there used to be an "lngamma" function, defined in the
fischer source, that took care of this. I imagine the best solution would
be to sense if lgamma exists and if not, use a fallback, though I don't
know if there is an easy way to set that up in Cython.

On Wed, May 11, 2016 at 12:54 PM, Brent Pedersen - Bioinformatics <
[email protected]> wrote:

maybe we need:

extra_compile_args = ['-O3', '-std=c99']

in setup.py (line 10)

can you try that and let me know if it works. I don't have access to a
windows machine for testing.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#16 (comment)

@brentp
Copy link
Owner

brentp commented May 12, 2016

this is from 398c8ca by @superbobry . can you have a look?

@superbobry
Copy link
Contributor

superbobry commented May 12, 2016

I thought npy_math.h has lgamma but it doesn't, so the best way would be to simply resurrect the hand-rolled version.

@deto
Copy link
Author

deto commented May 12, 2016

Yes, looks like scipy has it - http://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gammaln.html#scipy.special.gammaln - though not sure how hard it would be to borrow the implementation. Or if it really is worth the effort - performance-wise.

@gursimar
Copy link

gursimar commented Oct 7, 2016

Guys, any luck getting this work on windows?

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

No branches or pull requests

4 participants