Can't compile with MSVC (and therefore install with pip) due to reusing of built-in min/max function name
Dear experts,
We rely on ligo-segments
as a dependency of GWpy
, which itself is a dependency for our package. We use that outside of LIGO computing environment which complicates things somewhat. Specifically, we found that one can't do pip install ligo-segments
on windows in anaconda environment where MSVC is the default compiler (typical case), which leads to users being unable to install our package with pip
as well1.
The issue itself is with following lines: https://git.ligo.org/lscsoft/ligo-segments/-/blob/master/src/segmentlist.c#L199, https://git.ligo.org/lscsoft/ligo-segments/-/blob/master/src/segmentlist.c#L218
For which compiler says:
src/segmentlist.c(199): error C2059: syntax error: '<parameter-list>'
src/segmentlist.c(218): error C2059: syntax error: '<parameter-list>'
The message is a bit cryptic, but I think the problem is with function names on these lines, min
and max
- these keywords have a special meaning, or at least MSVC assumes so here. I was able to rectify the issue locally renaming them to minimum
and maximum
and correspondingly changing the calls on lines https://git.ligo.org/lscsoft/ligo-segments/-/blob/master/src/segmentlist.c#L343 and https://git.ligo.org/lscsoft/ligo-segments/-/blob/master/src/segmentlist.c#L350. I did not do thorough testing, but if this is the only place where these functions are used then the change should be rather straightforward and not affect any other usage/environments? In that case I'm happy to implement the fix myself and submit a merge request.
-
Yes,
GWpy
can be installed withconda
(and will contain already compiled binaries ofligo-segments
), but not our package, and there are more problems for us when it comes to development dependencies which we manage withpoetry
- it only supportspip
. Long story short would be great to be able to do everything withpip
, especially if the fix is as easy as described here.↩