Python version on OSX

edited December 2015 in KLayout Support

Hello,

It appears that the OSX version of KLayout uses the default system Python installation. I am trying to change it to a separate copy in which I am adding missing modules. Is there a way to point it to another installation? Or is this entered during the compile process?

I have python installed:

  • brew install python

  • anaconda

Also, there is the question of version 2 vs 3.

Comments

  • edited December 2015

    Hello,

    The recent binary packages of "0.24.3" and "0.24.4" for OSX were built with the script below.

    The reason I used the default system Ruby/Python installation* is the issue:

    http://klayout.de/forum/comments.php?DiscussionID=711&page=1
    

    Now that I have installed "El Capitan" on a virtual machine without any software development

    environment including Xcode, I can confirm that a binary can start in such a real end-user environment.

    (* please note that Qt4 is from Mac Ports)

    #!/bin/bash
    
    BUILD="release"
    
    if [ $# -eq 1 ]; then
        if [ $1 = "release" ]; then
            BUILD="$1"
        elif [ $1 = "debug" ]; then
            BUILD="$1"
        else
            echo "Usage:  $0 [<release|debug>]"
            exit 1
        fi
    fi
    
    ./build.sh -option -j4 \
            -with-qtbinding \
            -platform mac-yosemite-gcc-$BUILD  \
            -qtbin    /opt/local/libexec/qt4/bin \
            -qtinc    /opt/local/libexec/qt4/include \
            -qtlib    /opt/local/libexec/qt4/lib \
            -ruby     /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby \
            -python   /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python \
            -rbinc    /System/Library/Frameworks/Ruby.framework/Headers \
            -rblib    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.dylib \
            -pyinc    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 \
            -pylib    /System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib 2>&1 \
            | tee     gcc-$BUILD-building-klayout.log
    

    Another script below is for using different version of Ruby/Python from Mac Ports.

    #!/bin/bash
    
    export PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4
    BUILD="release"
    
    if [ $# -eq 1 ]; then
        if [ $1 = "release" ]; then
            BUILD="$1"
        elif [ $1 = "debug" ]; then
            BUILD="$1"
        else
            echo "Usage:  $0 [<release|debug>]"
            echo "PYTHONPATH="$PYTHONPATH
            exit 1
        fi
    fi
    
    ./build.sh -option -j4 \
            -with-qtbinding \
            -platform mac-yosemite-gcc-$BUILD  \
            -qtbin    /opt/local/libexec/qt4/bin \
            -qtinc    /opt/local/libexec/qt4/include \
            -qtlib    /opt/local/libexec/qt4/lib \
            -ruby     /opt/local/bin/ruby2.1 \
            -python   /opt/local/bin/python3.4 \
            -rbinc    /opt/local/include/ruby-2.1.0 \
            -rblib    /opt/local/lib/libruby.2.1.0.dylib \
            -pyinc    /opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m \
            -pylib    /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib 2>&1 \
            | tee     gcc-$BUILD-building-klayout.log
    

    Since you are working in you own software development environment, I think it's worth trying to
    build the latest KLayout from the source code.

    Kazzz

  • edited November -1

    Hello,

    For testing purpose, I have built "0.24.4" with the second script above.

    That is, both Ruby and Python are taken from the latest Mac Ports installation.

    A binary package was also made. One difference is that this binary package

    contains not only Qt4 frameworks but also Python frameworks and Ruby's dylib.

    More precisely, the dependency of klayout of this build is:

    $ otool -L klayout
    klayout:
        @executable_path/../Frameworks/libruby.2.1.0.dylib (compatibility version 2.1.0, current version 2.1.0)
        @executable_path/../Frameworks/Python.framework/Versions/3.4/Python (compatibility version 3.4.0, current version     3.4.0)
        @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version     4.8.7)
        @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version     4.8.7)
        @executable_path/../Frameworks/QtXml.framework/Versions/4/QtXml (compatibility version 4.8.0, current version     4.8.7)
        @executable_path/../Frameworks/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current     version 4.8.7)
        @executable_path/../Frameworks/QtSql.framework/Versions/4/QtSql (compatibility version 4.8.0, current version     4.8.7)
        @executable_path/../Frameworks/QtDesigner.framework/Versions/4/QtDesigner (compatibility version 4.8.0, current     version 4.8.7)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0,     current version 1153.18.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
        /usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 125.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
    

    As expected, "klayout.app" normally starts on Yosemite where the binary/package was made.

    On El Capitan, however, it does not start showing the message below:

    Kazunaris-Mac:MacOS Kazzz$ ./klayout -e
    <internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
        from <internal:gem_prelude>:1:in `<compiled>'
    Could not find platform independent libraries <prefix>
    Could not find platform dependent libraries <exec_prefix>
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
    Fatal Python error: Py_Initialize: unable to load the file system codec
    ImportError: No module named 'encodings'
    Abort trap: 6
    

    This implies that more (may not all) components of Ruby and Python have to be

    packed into the binary packages on trial and error basis, which looks a tough job.

    Kazzz

  • edited November -1

    Hi Kazzz,

    thanks very much for providing the new binary package. I have uploaded the package to the server.

    The message you received is familiar to me. I got it myself on Windows and Linux when $PYTHONPATH is set to an invalid location, which was inevitable on some installations. Hence I changed the name of the variable to $KLAYOUT_PYTHONPATH, so there is no clash with other programs installed on the system. Maybe you need to set this variable to the same value than $PYTHONPATH (if it's set).

    But of course you may be right as well - the package might not be complete as the Ruby message indicates.

    Thanks again and best regards,

    Matthias

  • edited November -1

    Thanks Kazzz.

    It would be nice if KLayout could be configured to use the built-in Ruby/Python (for end-users), and the same binary could be configured with an environment variable to use a separately installed Python.

    Anyway, I am trying to avoid making big changes to the installation procedure / requirements, so that my end-users don't need to do anything complicated.

    regards

    Lukas

Sign In or Register to comment.