1

I'm trying to install the pynauty Python package. When I ran python setup.py build, I got the following error. I have installed the dependencies. How can I successfully install this Python package?

$ python setup.py build
running build
running build_py
running build_ext
building 'pynauty._pynauty' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Inauty -Isrc -I/usr/include/python2.7 -c src/pynauty.c -o build/temp.linux-x86_64-2.7/src/pynauty.o -O4
In file included from src/pynauty.c:16:0:
nauty/nauty.h:40:0: warning: "_FILE_OFFSET_BITS" redefined
 #define _FILE_OFFSET_BITS 0
 ^
In file included from /usr/include/python2.7/pyconfig.h:3:0,
                 from /usr/include/python2.7/Python.h:8,
                 from src/pynauty.c:15:
/usr/include/x86_64-linux-gnu/python2.7/pyconfig.h:1157:0: note: this is the location of the previous definition
 #define _FILE_OFFSET_BITS 64
 ^
src/pynauty.c: In function ‘_make_nygraph’:
src/pynauty.c:363:33: warning: passing argument 2 of ‘PyDict_Next’ from incompatible pointer type
     while (PyDict_Next(adjdict, &i, &key, &adjlist)) {
                                 ^
In file included from /usr/include/python2.7/Python.h:101:0,
                 from src/pynauty.c:15:
/usr/include/python2.7/dictobject.h:114:17: note: expected ‘Py_ssize_t *’ but argument is of type ‘int *’
 PyAPI_FUNC(int) PyDict_Next(
                 ^
src/pynauty.c: In function ‘init_pynauty’:
src/pynauty.c:537:15: warning: variable ‘m’ set but not used [-Wunused-but-set-variable]
     PyObject *m;
               ^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/pynauty.o nauty/nauty.o nauty/nautil.o nauty/naugraph.o -o build/lib.linux-x86_64-2.7/pynauty/_pynauty.so
/usr/bin/ld: nauty/nauty.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
nauty/nauty.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  • I see two possible cases here. 1) you really did as they suggest to build this and they have a bug in their installer or you have something different on your machine and 2) you are a human being and have made a mistake in following their instructions and thus couldn't build the software. For 1), file a bug there / ask on their dev mailing list if they have one. For sake of 2), please retract your steps and list them in the question, which link you followed, which instruction you typed, etc. – LAFK says Reinstate Monica Apr 14 '15 at 18:15
1

No, Please don't do it in this way! Author of pynauty, Peter Dobcsányi told me, that this version is inherently buggish, and won't produce correct results ( especially, in 'certify' function ).

He recently released brand new version, 0.6.0 ( https://web.cs.dal.ca/~peter/software/pynauty/pynauty-0.6.0.tar.gz ) and this version is absolutely correct and compatible with Python 2.7 and most recent Nauty!

I've tested that, and everything works fine

2
+50

The full error message tells you part of the solution: you need to compile nauty with the -fPIC flag.

  1. Download nauty, unzip it, cd into the dir
  2. CFLAGS=-fPIC ./configure
  3. make
  4. Download pynauty, unzip it, cd into the dir
  5. ln -s ../nauty* nauty
  6. However, the pynauty's setup.py file appears to be misconfigured: it doesn't include the correct nauty files and so will fail on import if built and installed at this point. Modify the extra_objects argument in setup.py (line 37):

    # from
    extra_objects = [ nauty_dir + '/' + 'nauty.so', ],
                          nauty_dir + '/' + 'nautil.o',
                          nauty_dir + '/' + 'naugraph.o'
                        ],
    # change it to
    extra_objects = [nauty_dir + '/' + 'nauty.a'],
    
  7. python setup.py build

  8. python setup.py install (if you're installing to the system, use sudo, but preferably use a virtualenv instead)

While the package is now installed and importable, the entire test suite fails. This is an issue that should be fixed by the library's maintainer; consider reporting the bug to them.

  • Where should I create link? In which dic? – aeyalcinoglu Apr 23 '15 at 20:31
  • All went nice until 7th step: I get a permission error about egg-info. – aeyalcinoglu Apr 23 '15 at 20:36
0

In addition to the answer of davidism, I figured out that the tests are broken because of a warning I got when compiling pynauty 0.5 using Python 2.7 and nauty25r9:

src/pynauty.c: In function ‘_make_nygraph’:
src/pynauty.c:363:33: warning: passing argument 2 of ‘PyDict_Next’ from incompatible pointer type
     while (PyDict_Next(adjdict, &i, &key, &adjlist)) {
                                 ^
In file included from /usr/include/python2.7/Python.h:101:0,
                 from src/pynauty.c:15:
/usr/include/python2.7/dictobject.h:114:17: note: expected ‘Py_ssize_t *’ but argument is of type ‘int *’
 PyAPI_FUNC(int) PyDict_Next(

To fix this warning, change

int i,j;

in src/pynauty.c to

Py_ssize_t i;
int j;

and recompile pynauty. The warning should disappear and the tests should pass!

-1

I'm not clear on your steps despite your edit. Assuming you:

./configure # note this command for later make nauty.o nautil.o naugraph.o ln -s ../nautyXX nauty

and ran into error you described in the opening paragraph of your question, than the problem you most likely ran into is that Python by default is configured without shared libraries. Unfortunate package you download, is searching for shared library being compiled and finds none.

Proposed solution: run ./configure --enable-shared. That way you tell Python to actually compile them as well. You might run into trouble depending on what shared libs you have there, but can't say anything but speculation without knowing more on your side.

Sources:

I recommend the Github link, it's most clarifying here.

  • ln -s ../nautyXX nauty should be replaced by ln -s ../nauty25r9 nauty in the OP configuration (I guess) which is different of his original ln -s /nauty25r9 nauty – Xavier Combelle Apr 23 '15 at 19:45
  • @davidism options change with time, but prior to posting I've actually went to Python docs and re-read them and they specifically mention it. I think since Python 2.3 it's been there. Of course, everybody's free to make their own configure script. Nevertheless, seems you nailed it already in your response. Glad it's solved and +1 for virtualenv. – LAFK says Reinstate Monica Apr 24 '15 at 20:41
  • From the initial question that's where I placed the issue, but I might've gone for a shortcut and placed one configure for both Python and pynauty install, while OP most likely installed Python and then pynauty - this made his configure pynauty one only, so the option might not been there at all. Glad you stepped in. – LAFK says Reinstate Monica Apr 24 '15 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.