New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from 4.0.2 pip install from sources does not work properly anymore - probably waf (2.0.7, 2.0.8) issue #904

Closed
bitranox opened this Issue Jun 28, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@bitranox
Copy link

bitranox commented Jun 28, 2018

Operating system: Linux 18.04 (Ubuntu + Mate)
wxPython version: 4.0.1 worked, from 4.0.2 / 4.0.3 not working anymore
Stock or custom build: custom build
Python version: 3.6.5
** WAF Version ** 2.0.7 and also tried 2.0.8 - same effect !
Stock or custom build: custom build

Description of the problem:
pip install from sources does not work from versions 4.0.2 and up - until then my installation was ok, and wxpython was updated through a pip requirement file.
Suddenly, from version 4.0.2, it stopped to work, so I used the precompiled version without problems.
But I decided to look into it, what can be the reason.

My Configuration :
/opt/Python-3.6.5 # location of my compiled alternate Python Version
/opt/python3 # a link to the directory above
/rotek/install/Phoenix # location of the git download.

ISSUE #1 - you need to compile python with option -enable-shared, otherwise Phoenix will not compile

Error:
['/usr/bin/g++', '-shared', '-Xlinker', '-export-dynamic', 'test.cpp.1.o', '-o/rotek/install/Phoenix/build/waf/3.6/gtk3/.conf_check_41594648ed5f27e179d88d65cb416c86/testbuild/testprog.cpython-36m-x86_64-linux-gnu.so', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-L/opt/Python-3.6.5/lib/python3.6/config-3.6m-x86_64-linux-gnu', '-L/opt/Python-3.6.5/lib', '-lpython3.6m', '-lpthread', '-ldl', '-lutil', '-lm', '-lpython3.6m', '-lpthread', '-ldl', '-lutil', '-lm']
err: /usr/bin/x86_64-linux-gnu-ld: /opt/Python-3.6.5/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.a(pylifecycle.o): relocation R_X86_64_PC32 against symbol `_PyThreadState_Current' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Solution Compile Python with option -enable-shared:

#!/bin/bash
# compiling Python and install it on /opt/Python-3.x.x
# creating a symlink /opt/python3
#
version=Python-3.6.5
cd /rotek/install/$version    # assuming that Python 3.6.5 sources lives there
sudo make clean 
sudo ./configure --enable-optimizations --with-lto --enable-shared --prefix /opt/$version
sudo make install
sudo rm -f /opt/python3
sudo ln -s /opt/$version /opt/python3
echo "finished compiling $version, press ENTER to continue ... "
read anykey

But after that step, Phoenix still does not compile - it looks like WAF references to
/usr/lib/python3.6/site-packages instead of /opt/Python-3.6.5/lib/python3.6/site-packages

# EXAMPLE1 - NOT WORKING
cd /opt/python3/bin
sudo -H ./pip3 install wxpython    # not working, can not buil python extensions

# EXAMPLE2 
cd /rotek/install/Phoenix
# this actually works - compiling wx only
sudo /opt/python3/bin/python3 ./build.py dox etg --nodoc sip build_wx --python=/opt/Python-3.6.5/bin/python3.6
# next step is failing - can not build python extension
sudo /opt/python3/bin/python3 ./build.py dox etg --nodoc sip build_py --python=/opt/Python-3.6.5/bin/python3.6
# passing parameters PYTHONDIR, PYTHONARCHDIR to WAF - now it can compile !
sudo /opt/python3/bin/python3 ./build.py dox etg --nodoc sip build_py --python=/opt/Python-3.6.5/bin/python3.6 --extra_waf="PYTHONDIR=/opt/Python-3.6.5/lib/python3.6/site-packages PYTHONARCHDIR=/opt/Python-3.6.5/lib/python3.6/site-packages"

after finding out that WAF somehow messing it up, I read the code of the WAF script (I tried even WAF 2.0.8) - and found that You can pass those settings also via the environment :

# EXAMPLE3 - WORKING
set PYTHONDIR=/opt/Python-3.6.5/lib/python3.6/site-packages
set PYTHONARCHDIR=/opt/Python-3.6.5/lib/python3.6/site-packages
cd /opt/python3/bin
sudo -H ./pip3 install wxpython

QUESTION : did I do something wrong ? I assume no - it worked until Phoenix 4.0.1, it is probably a side effect when switching to new WAF Version ?

REMEDY : maybe pass PYTHONDIR, PYTHONARCHDIR to WAF automagically ?
I dont know enough about the installation script to make a patch on my own, without messing up something else like pyenv, etc. - in the meantime I set my environment variables in my update script.

It would be nice if someone can take care of it and let m know

yours sincerely

Robert, Vienna

@RobinD42

This comment has been minimized.

Copy link
Member

RobinD42 commented Jun 28, 2018

When you have a minute please try rebuilding with this change to wscript: Change line 317 to if not isWindows: so it will also clear the LIB_PYEXT and LIBPATH_PYEXT variables for linux builds too.

https://github.com/wxWidgets/Phoenix/blob/wxPython-4.0.3/wscript#L317

@bitranox

This comment has been minimized.

Copy link

bitranox commented Jun 28, 2018

Robin,
Boom, You nailed it -
Change line 317 to "if not isWindows:" did the trick.
thank You !
Robert

@bitranox

This comment has been minimized.

Copy link

bitranox commented Jun 28, 2018

BTW - You can upgrade safely to WAF 2.0.8 - I tried, it works ...
yours sincerely
Robert

@bitranox

This comment has been minimized.

Copy link

bitranox commented Jun 28, 2018

You might also update the installation documentation - You need to compile python with option --enable-shared - it took me quiet some time ...
yours sincerely, and thanks again !
Robert

@RobinD42

This comment has been minimized.

Copy link
Member

RobinD42 commented Jul 4, 2018

Fixed by #912

@RobinD42 RobinD42 closed this Jul 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment