# Building pyqt5 against Python 3.x



## Dan MacDonald (May 23, 2017)

I have successfully (accidentally) managed to build pyqt5 from ports under HEAD against python 2 but I'm having no luck building it against python 3. In devel/py-qt5 I'm running:


```
make PYTHON_VERSION=3.4 install
```

but that command fails telling me


```
py34-qt5-core>=5.7.1 is not found
```

How do I build or install py34-qt5-core? Note that I tried with py36 before py34 and I had even less luck.

Also, is there a way to automate the building of stuff from ports AND ALL THE REQUIRED DEPS without setting up poudriere? I'd like a freebsd equivalent of packer / pacaur etc.


----------



## SirDice (May 23, 2017)

Set DEFAULT_VERSIONS in /etc/make.conf:

```
DEFAULT_VERSIONS+= python=3.5
```
See /usr/ports/Mk/bsd.default-versions.mk.



Dan MacDonald said:


> Also, is there a way to automate the building of stuff from ports AND ALL THE REQUIRED DEPS without setting up poudriere?


See ports(7):

```
config-recursive
                      Configure OPTIONS for this port and all its dependencies
                      using dialog4ports(1).
```
And

```
BATCH         If defined, only operate on a port if it can be installed
                   100% automatically.
```


----------



## Dan MacDonald (May 23, 2017)

Hi SirDice

I've defined:


```
DEFAULT_VERSIONS+= python=3.4
```

In /etc/make.conf but running `make install` in devel/py-qt5 is giving me the same error but then again I'm not sure what you intended me to do after defining the default python version. 3.5 doesn't seem to be a valid version number.


----------



## SirDice (May 23, 2017)

python can be set to 2.7, 3.3, 3.4, 3.5 and 3.6. You can also specify which Python 2 or Python 3 version you want.


```
78 	# Possible values: 2.7, 3.3, 3.4, 3.5, 3.6
79 	PYTHON_DEFAULT?=        2.7
80 	# Possible values: 2.7
81 	PYTHON2_DEFAULT?=       2.7
82 	# Possible values: 3.3, 3.4, 3.5, 3.6
83 	PYTHON3_DEFAULT?=       3.6
```

But note that ports can request specific versions.


----------



## Dan MacDonald (May 23, 2017)

Please, in complete idiots terms, tell me how I build py34-qt5-core. Assume I know nothing.

I'd guess I'm ultimately doing a `make install` within devel/qt5-core, with knobs on but maybe I have some tidying/rebuilding to do before?

Thanks


----------



## SirDice (May 23, 2017)

Well, I should have looked a little closer, you need devel/py-qt5-core. Looking at the port it already depends on Python 3 (based on standard DEFAULT_VERSIONS it will be built against 3.6). So if you need 3.4 you'll need this:

```
DEFAULT_VERSIONS+= python3=3.4
```


----------



## Dan MacDonald (May 23, 2017)

I'm still none the wiser. You say py-qt5-core depends on python 3 but I've only had success building against py27, which would seem to be the default here.

I'd be very grateful if someone could provide step-by-step instructions to building PyQt5 against any version of Python 3 under FBSD12/HEAD/TrueOS.

Thanks


----------



## SirDice (May 23, 2017)

Dan MacDonald said:


> You say py-qt5-core depends on python 3


Yes. 

The port's Makefile shows:

```
USE_PYTHON= py3kplist
```
This should indicate a dependency on Python 3.x.




Dan MacDonald said:


> FBSD12/HEAD/TrueOS.


Right.

Topics about unsupported FreeBSD versions
PC-BSD, FreeNAS, NAS4Free, and all other FreeBSD Derivatives


----------



## Dan MacDonald (May 24, 2017)

I totally re-installed my system and didn't build anything from ports until I had defined


```
DEFAULT_VERSIONS+= python=3.6
```

in /etc/make.conf but I chose badly as that isn't working:


```
===>  Staging for py36-qt5-5.7.1
===>   py36-qt5-5.7.1 depends on file: /usr/local/bin/python3.6 - found
===>   py36-qt5-5.7.1 depends on package: py36-qt5-core>=5.7.1 - not found
===>  Installing for py36-qt5-core-5.7.1
===>   py36-qt5-core-5.7.1 depends on file: /usr/local/bin/python3.6 - found
===>   py36-qt5-core-5.7.1 depends on shared library: libqscintilla2-qt5.so - found (/usr/local/lib/qt5/libqscintilla2-qt5.so)
===>   py36-qt5-core-5.7.1 depends on shared library: libQt5Core.so - found (/usr/local/lib/qt5/libQt5Core.so)
===>  Checking if py36-qt5-core already installed
===>   Registering installation for py36-qt5-core-5.7.1 as automatic
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/__pycache__/Qt.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/__pycache__/__init__.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Compiler/__pycache__/__init__.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Compiler/__pycache__/compiler.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Compiler/__pycache__/indenter.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Compiler/__pycache__/misc.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Compiler/__pycache__/proxy_metaclass.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Compiler/__pycache__/qobjectcreator.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Compiler/__pycache__/qtproxies.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Loader/__pycache__/__init__.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Loader/__pycache__/loader.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/Loader/__pycache__/qobjectcreator.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/__init__.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/driver.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/exceptions.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/icon_cache.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/objcreator.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/port_v3/__pycache__/__init__.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/port_v3/__pycache__/as_string.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/port_v3/__pycache__/ascii_upper.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/port_v3/__pycache__/proxy_base.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/port_v3/__pycache__/string_io.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/properties.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/pyuic.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/__pycache__/uiparser.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/widget-plugins/__pycache__/qaxcontainer.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/widget-plugins/__pycache__/qscintilla.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/widget-plugins/__pycache__/qtcharts.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/widget-plugins/__pycache__/qtprintsupport.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/widget-plugins/__pycache__/qtquickwidgets.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/widget-plugins/__pycache__/qtwebenginewidgets.opt-1.cpython-36.pyc:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/uic/widget-plugins/__pycache__/qtwebkit.opt-1.cpython-36.pyc:No such file or directory
*** Error code 74

Stop.
make[3]: stopped in /usr/ports/devel/py-qt5-core
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/devel/py-qt5-core
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/devel/py-qt5
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/py-qt5
```


----------



## Dan MacDonald (May 25, 2017)

I got similar errors with all the supposedly valid py 3.x versions so I've written to the FreeBSD KDE ports maintainers for their advice.


----------



## Dan MacDonald (May 27, 2017)

Here's a clue for you portsmeisters that could get me going:

It seems the port was looking for
/usr/ports/devel/py-qt5-core/work/stage/usr/local/lib/python3.6/site-packages/PyQt5/__pycache__/Qt.opt-1.cpython-36.pyc but the file is called Qt.cpython-36.opt-1.pyc and lives in that same dir. I would expect thats the case for the other 'missing' files too - the opt-1 being in the wrong part of the filename. What might've caused that? Is there an easy fix?


----------



## Dan MacDonald (May 31, 2017)

Getting closer...

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219641

Someone here might be able to answer this bit

"Through having a search, it seems FreeBSD has packages for py34-sip, py36-sip etc whilst TrueOS only has py27-sip in its repos. You'll have to forgive me as I'm new to FreeBSD and even newer to using ports but does this matter ie do I need to request they add py34-sip or py36-sip to the TrueOS repo?

I would've thought that building stuff from ports creates packages that are identical to what you get via pkg, only you have to compile them yourself which gives you more scope for tweaking build options etc. Is this not the case? Are ports builds treated differently by the OS compared to packages installed via pkg?"


----------



## Dan MacDonald (Jun 1, 2017)

Did it! 

I've finally got pyqt5 built against python 3.4, in a hacky kinda way:


```
cd /usr/ports/devel/py-qt5
make PYTHON_VERSION=python3.4 config
# Disable both dbus sub-ports and the pyqt5 demo port in the ncurses menu
make PYTHON_VERSION=python3.4 install
```

If you get the error:


```
Error: Make sure you have a working sip on your PATH or use the --sip argument
```

Then run:


```
ln -s /usr/local/bin/sip-3.4 /usr/local/bin/sip
```

Before re-running:


```
make PYTHON_VERSION=python3.4 install
```


----------



## akram65 (Jan 15, 2018)

Well, my try on make install of pyqt5 for py36 gives following error:


```
===>   py36-qt5-webkit-5.9.2 depends on shared library: libQt5WebKit.so - not found
===>  qt5-webkit-5.212.0.a2_5 needs Python 2.7 at most, but 3.6 was specified.
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/www/qt5-webkit
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/www/py-qt5-webkit
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/misc/py-qt5-demo
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/py-qt5
```

Any workaround for this?


----------



## SirDice (Jan 15, 2018)

I suggest you open a new thread. The way the Python version is chosen has changed significantly.


----------



## akram65 (Jan 15, 2018)

Sure.


----------

