1. Anthony Tuininga
  2. cx_Freeze
  3. Issues
Issue #32 resolved

Can't compile cx_Freeze in Ubuntu 13.04

Thomas Kluyver
created an issue

Ubuntu and Debian now set Py_ENABLE_SHARED to 1 and don't link extensions against the Python shared library (bug report, patch).

This causes a problem when compiling the bases for cx_Freeze. You see a whole load of warnings like this:

/home/thomas/Code/cx_freeze/source/bases/Console.c:36: undefined reference to `PyErr_Print'

I can get it to work by modifying this line to if True: so that it always links against libpython. I'm not sure if that's right, though - cx_Freeze.util can be compiled without explicitly linking to python, but maybe the rules are different for executables.

Comments (28)

  1. frol

    Do everybody install cx_Freeze on Linux with this workaround? The commit that added this "if" statement 72f6006 claimed that it will help to link Console with shared library of python, but in practice if you don't use this "if", it does link against shared library anyway, at least on Ubuntu:

    $ ldd build/lib.linux-x86_64-2.7/cx_Freeze/bases/Console 
            linux-vdso.so.1 =>  (0x00007fffe1da8000)
            libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007f23893d2000)
            ...
    
  2. Thomas Kluyver reporter

    As far as I know, yes, everyone on Debian based Linux distros needs a workaround like this to install cx_Freeze.

    The issue is that Debian sets that config value 'incorrectly', for some kind of packaging reasons I don't understand, and then patches distutils to make it do the right thing anyway. Of course, that patch doesn't apply to cx_Freeze. I'm not sure how we can tell if the Python we're building with is a Debian-packaged version of Python.

    Also, current master doesn't work against Debian packaged Python at all, even if you get it to install. I've emailed Anthony about this.

  3. frol

    Which config value does Debian set wrong? Python seems to be built with --enable-shared and I have /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 and other symlinks to it. Python reports Py_ENABLE_SHARED=1:

    >>> distutils.sysconfig.get_config_var('Py_ENABLE_SHARED')
    1
    

    The same output I get on my Arch Linux. However, it seems like something is definitely patched somewhere because on my Arch Linux it links Console like this:

    gcc -pthread build/temp.linux-armv7l-2.7/source/bases/Console.o -L/usr/lib -lpython2.7 -o build/lib.linux-armv7l-2.7/cx_Freeze/bases/Console -s
    

    , but on Ubuntu the command lacks "-L/usr/lib -lpython2.7".

  4. frol

    It is very odd, because their check is

    if (sysconfig.get_config_var("Py_ENABLE_SHARED")):
    

    , but it is opposite statement in cx_Freeze:

    if not vars.get("Py_ENABLE_SHARED", 0):
    
  5. Thomas Kluyver reporter

    That doesn't seem odd to me. Distutils has some code that should only run if you're using the shared libpython.so, and Debian patches it to never run. cx_Freeze has some code that should only run if you're not using the shared libpython.so, and the workaround is to patch it to always run.

  6. Tim Süberkrüb

    This steps worked for me (Ubuntu 14.04, Ubuntu 14.10, 64 bit):

    For python 3.3 and 3.4:

    sudo apt-get install python3-dev
    
    sudo apt-get install libssl-dev
    

    Open setup.py and change the line

    if not vars.get("Py_ENABLE_SHARED", 0):
    

    to

    If True:
    
    python3 setup.py build
    sudo python3 setup.py install
    

    For python 2.7:

    sudo apt-get install python-dev
    
    sudo apt-get install libssl-dev
    

    Open setup.py and change the line

    if not vars.get("Py_ENABLE_SHARED", 0):
    

    to

    If True:
    
    python setup.py build
    sudo python setup.py install
    

    I hope this will be helpful.

  7. Mike C

    What is the name and location that of the file that needs to be modified? I'm using Ubuntu 15.04 and Python 2.7 and getting the same errors as described above.

  8. Mike C

    Thanks Thomas. I have installed cx_Freeze, created a setup.py with the code from the above link, changed the highlighted line as described above. I assume that I'm supposed to run this file ( python setup.py build). When I run the file I get the following: error: package directory 'cx_Freeze' does not exist. I feel like I am missing something very simple here. Can someone please shed some light.

  9. Anthony Tuininga repo owner

    I am aware of the long delay -- very aware! My day job no longer gives me the ability to work on this so it has been delayed far longer than I had hoped. It is still in progress -- just very slowly. :-(

  10. Log in to comment