Open Source Development

Power Open Source Development

Explore the open source tools and capabilities for building and deploying modern applications on IBM Power platforms including AIX, IBM i, and Linux.


#Power


#Power

 View Only
  • 1.  Python3 add binary extensions

    Posted Tue January 16, 2018 03:24 PM

    Originally posted by: ahatch


    I'm having a little trouble with the packaged Python3 available from the toolbox. It appears to be missing some config bits to enable me to build binary extensions via pip.  I'm stuck building from source until I get this figured out.

    I'm trying to install cx_Oracle via pip.  I can build Python3 from source and install cx_Oracle without issue, so I'm pretty sure its not me . . .

    I have a hard time believing nobody else is having this issue, so what am I missing?


    #AIX-Open-Source-Software
    #AIXOpenSource


  • 2.  Re: Python3 add binary extensions

    Posted Wed January 24, 2018 11:09 AM

    Originally posted by: sanket


    Could you please provide more information, steps and error output of failure.

    So that we can look into.


    #AIXOpenSource
    #AIX-Open-Source-Software


  • 3.  Re: Python3 add binary extensions

    Posted Thu January 25, 2018 09:27 PM

    Originally posted by: ahatch


    Sanket,

     

    The issue seems to be that /opt/freeware/lib/python3.5/config/  directory and its contents do not appear to be delivered with the python3 RPM.  I worked around the issue by building and installing Python3.5.4 from source and then linking the installed directory out.  But since the version of Python I built is 32bit, it builds cx_Oracle as 32 bit and it doesn't work.  I'm going to have to rebuild and install the 64bit Python so I can get the "config" directory . . . of course unless there is an easier way.  I'm not a developer so I don't pretend to know much about building from source.

     

    Here are the details:

    # oslevel -s

    7100-04-04-1717

     

    # yum list | grep python3
    python3.ppc                                3.5.2-3           @AIX_Toolbox
    python3-devel.ppc                          3.5.2-3           @AIX_Toolbox
    python3-test.ppc                           3.5.2-3           @AIX_Toolbox
    python3-tools.ppc                          3.5.2-3           @AIX_Toolbox
    python3-docs.ppc                           3.5.2-3           AIX_Toolbox
     

    # pip install cx_Oracle --upgrade
    Collecting cx_Oracle
      Using cached cx_Oracle-6.1.tar.gz
    Installing collected packages: cx-Oracle
      Running setup.py install for cx-Oracle ... error
        Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-12q9blx2/cx-Oracle/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-m657j926-record/install-record.txt --single-version-externally-managed --compile:
        running install
        running build
        running build_ext
        building 'cx_Oracle' extension
        creating build
        creating build/temp.aix-7.1-3.5
        creating build/temp.aix-7.1-3.5/src
        gcc -DNDEBUG -O2 -I/opt/freeware/include -I/opt/freeware/include/ncurses -Iodpi/include -Iodpi/src -I/opt/freeware/include/python3.5m -c src/cx_Oracle.c -o build/temp.aix-7.1-3.5/src/cx_Oracle.o -DBUILD_VERSION=6.1
        In file included from src/SessionPool.c:153:0,
                         from src/cx_Oracle.c:264:
        src/Connection.c: In function 'Connection_Init':
        src/Connection.c:778:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
             dpiCreateParams.externalHandle = (void*) externalHandle;
                                              ^
        src/Connection.c: In function 'Connection_GetHandle':
        src/Connection.c:1061:40: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
             return PyLong_FromUnsignedLongLong((unsigned long long) handle);
                                                ^
        creating build/lib.aix-7.1-3.5
        /opt/freeware/lib/python3.5/config/ld_so_aix gcc -maix32 -pthread -bI:/opt/freeware/lib/python3.5/config/python.exp -L. -L/usr/include -L/opt/freeware/include -L/usr/lib/threads -L/opt/freeware/lib -L/usr/lib -L/opt/freeware/lib -L/opt/freeware/lib -I/opt/freeware/include -I/opt/freeware/include/ncurses build/temp.aix-7.1-3.5/src/cx_Oracle.o -o build/lib.aix-7.1-3.5/cx_Oracle.so
        unable to execute '/opt/freeware/lib/python3.5/config/ld_so_aix': No such file or directory
        error: command '/opt/freeware/lib/python3.5/config/ld_so_aix' failed with exit status 1

        ----------------------------------------
    Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-12q9blx2/cx-Oracle/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-m657j926-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-12q9blx2/cx-Oracle/

     

    # ll /opt/freeware/lib/python3.5/config/
    ls: 0653-341 The file /opt/freeware/lib/python3.5/config/ does not exist.

     

    # pip install cx_Oracle --upgrade
    Collecting cx_Oracle
      Using cached cx_Oracle-6.1.tar.gz
    Installing collected packages: cx-Oracle
      Running setup.py install for cx-Oracle ... done
    Successfully installed cx-Oracle-6.1

    # python3
    Python 3.5.2 (default, Dec  1 2016, 02:07:23)
    [GCC 4.8.5] on aix6
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cx_Oracle
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError:    0509-022 Cannot load module /opt/freeware/lib64/python3.5/site-packages/cx_Oracle.so.
            0509-026 System error: Cannot run a file that does not have a valid format.
    >>>

    If there was a way to get he "config" directory included with the RPM, I think that would help a lot when building binary extensions.

    Any guidance/help is appreciated.

    Thanks.

    Alan

     

     

     


    #AIXOpenSource
    #AIX-Open-Source-Software


  • 4.  Re: Python3 add binary extensions

    Posted Thu January 25, 2018 10:19 PM

    Originally posted by: ahatch


    I was able to hack the linked "config/ld_so_aix" and force a 64bit build (I suspect there is an environmental variable I can use to override the CCARGS, but I couldn't figure it out).

    #CCARGS="$args"
    CCARGS="-maix64 -pthread -L. -L/usr/include -L/opt/freeware/include -L/usr/lib/threads -L/opt/freeware/lib -L/usr/lib -L/opt/freeware/lib -Wl,-bmaxdata:0x80000000 -L/opt/freeware/lib -Wl,-b
    maxdata:0x80000000 -D_LARGE_FILES -DSYSV -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_AIX61 -D_AIX71 -D_ALL_SOURCE -DFUNCPROTO=15 -O -I/opt/freeware/include -I/opt/freeware/include/ncurses
     -I/usr/include build/temp.aix-7.1-3.5/src/cx_Oracle.o"

    Here are the relevant bits from my environment

    export CC="gcc -maix64"
    export CXX="gcc -maix64"
    #export CC=gcc
    #export CXX=g++
    export CXXFLAGS=$CFLAGS
    export F77=g77
    export FFLAGS="-O -I/opt/freeware/include"
    export LD=ld
    export LDFLAGS="-L/opt/freeware/lib -Wl,-bmaxdata:0x80000000"
    #export LDFLAGS="-L/opt/freeware/lib"
    #export CFLAGS="-I/opt/freeware/include -I/opt/freeware/include/ncurses"
    export CFLAGS="-D_LARGE_FILES -DSYSV -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_AIX61 -D_AIX71 -D_ALL_SOURCE -DFUNCPROTO=15 -O -I/opt/freeware/include -I/opt/freeware/include/ncurses -I/usr/include"
    export LC_CTYPE=en_US.UTF-8

     

    But it would be great to be able to deliver/maintain the next 10 nodes via RPM.

    Thanks again.

    Alan


    #AIX-Open-Source-Software
    #AIXOpenSource