Ethan Bradford
Ethan Bradford

Reputation: 780

Using Python's distutils.core, compiler links in Python 2.7 instead of Python 3

I've got a package with swig wrapping C for Python that I'm trying to upgrade to Python 3. I'm building it under Linux (CentOS) (provided in a Docker environment).

My problem is that the compile and link options assume I'm using Python 2.7. That is, the compile includes

-I/usr/include/python2.7

and the link includes

-lpython2.7

I got the compilation to work by including a compile option to find the Python 3 include directory:

CC="gcc -I/usr/include/python3.6m" python setup.py build_ext

but the link is failing due to not finding the python2.7 library:

/usr/bin/ld: cannot find -lpython2.7 collect2: error: ld returned 1 exit status

How do I tell distutils I'm a Python 3 shop now? "python" already gives "python3".

Upvotes: 0

Views: 174

Answers (1)

Ethan Bradford
Ethan Bradford

Reputation: 780

As Jens pointed out, though I thought I was calling setup.py with Python 3, I was actually using Python 2. Fixing that to Python 3 solved my problem.

Upvotes: 1

Related Questions