2

I was trying to install PyGreSQL under Mac OS X(10.11.3), but the same clang error occurs when installing from pip and source.

$ python3 setup.py install
running install
running bdist_egg
running egg_info
writing PyGreSQL.egg-info/PKG-INFO
writing top-level names to PyGreSQL.egg-info/top_level.txt
writing dependency_links to PyGreSQL.egg-info/dependency_links.txt
reading manifest file 'PyGreSQL.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'PyGreSQL.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-intel/egg
running install_lib
running build_py
running build_ext
building '_pg' extension
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -DPYGRESQL_VERSION=5.0 -DDIRECT_ACCESS -DLARGE_OBJECTS -DDEFAULT_VARS -DESCAPING_FUNCS -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/PostgreSQL/9.5/include -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c pgmodule.c -o build/temp.macosx-10.6-intel-3.5/pgmodule.o -O2 -funsigned-char -Wall -Werror
pgmodule.c:3684:3: error: code will never be executed [-Werror,-Wunreachable-code]
                long    num_rows;
                ^~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

clang error occurs when installing PyGreSQL

I already had PyGreSQL, Xcode and Xcode tools installed in my machine, and I also added the bin directory of PostgreSQL to $PATH.

Jacob Yin
  • 21
  • 3

1 Answers1

2

I was able to compile the module by editing the modules's setup.py

Find the line

extra_compile_args = ....

It's a list of extra compile arguments to pass to clang. One of the extra arguments will be -Werror, which means "treat all warnings as ERRORS". And as you know an error will abort compilation.

Remove that line, and run python3 setup.py build again and you'll see the same line appears, but this time as a warning, and everything goes okay!

mtb
  • 1,350
  • 16
  • 32
Cadu
  • 179
  • 5
  • 1
    That should solve the problem. It will be fixed in PyGreSQL versions higher than 5.0.3 (see https://github.com/Cito/pygresql/issues/4). – Cito Jul 08 '17 at 10:28
  • @Cito It's not: `-Werror` is still there and people [stumble](https://stackoverflow.com/q/53750450/7976758) over it. :-( – phd Dec 12 '18 at 22:21
  • 1
    @Phd Thanks for the notification. The actual issue under MacOS has in fact been [solved](https://github.com/Cito/pygresql/issues/4). The -Werror flag has not been removed on purpose - we want errors to show up so we can investigate and fix the root cause. In this case it looks like a different error on CentOS which we will need to investigate. I now subscribed to the pygresql tag in case people report only here instead of using our mailing list or bug tracker. – Cito Dec 13 '18 at 11:53