Try building PySide2

This article is from December 18th in Maya-Python Advent Calendar 2016.

Introduction

As you all know, PySide has become PySide 2 in Maya 2017.

This change has caused some troubles.

I'm thinking of verifying PySide2 in order to find a solution, but Maya has adopted the alpha version of PySide2. Not yet registered on PyPI. It is also not available in the reliable Unofficial Windows Binaries for Python Extension Packages.

It's annoying from the bottom of my heart, but I'll try to build it. Maybe it will fail, but I hope it helps someone even a little.

environment

I feel like it's full of demons, but I verified the following environment. I recommend Visual Studio 2008, but I don't like it so I don't use it.

Preparation

http://wiki.qt.io/PySide2_GettingStarted

Install the necessary software for the time being. Since the PC is relatively new, there aren't many.

  1. Clone the git repository. For the time being, I chose C: \ pyside \ pyside-setup
  2. Qt is 5.6, so download Qt 5.6.2 for Windows 64-bit (VS 2015) from Qt.
  3. It seems to build with CMake, so download CMake 3.7.1.

Challenge to build

Create virtualenv

Since it is recommended by virtualenv, create it and enable it.

pushd C:\pyside
python -m virtualenv venv27
venv27\Scripts\activate.bat

git submodule --init

Since pyside-setup.git is connected to repositories such as pyside2 and shiboken2 with submodule, git submodule --init. I'm doing it with TortoiseGit because it's annoying, so I'll omit the command.

2016-12-17_13h21_19.png

I got an error in all submodules, but when I tried it again, I got no error and it succeeded.

Build

Magic

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"

Build by specifying the path

python setup.py install --build-tests --qmake="C:\Qt\5.6\msvc2015_64\bin\qmake.exe" --cmake="C:\Program Files\CMake\bin\cmake.exe"

error

[ 10%] Building CXX object ApiExtractor/tests/CMakeFiles/testdtorinformation.dir/testdtorinformation_automoc.cpp.obj
testdtorinformation_automoc.cpp
[ 10%] Linking CXX executable testdtorinformation.exe
Qt5Core.lib(Qt5Core.dll) : fatal error LNK1112:Module computer type'x64'Is the type of target computer'X86'Is in conflict with.

LINK failed. with 1112
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' :Return code'0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' :Return code'0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' :Return code'0x2'
Stop.
error: Error compiling shiboken2

Early. Isn't it built with 64bit?

It seems that the link of the test program gives an error, so let's not create a test.

python setup.py install --qmake="C:\Qt\5.6\msvc2015_64\bin\qmake.exe" --cmake="C:\Program Files\CMake\bin\cmake.exe"

It's advanced a lot (although it's siboken2), but it's still an error

[ 80%] Building CXX object libshiboken/CMakeFiles/libshiboken.dir/shibokenbuffer.cpp.obj
shibokenbuffer.cpp
[ 81%] Linking CXX shared library shiboken2.dll
python27.lib(python27.dll) : fatal error LNK1112:Module computer type'x64'Is the type of target computer'X86'Is in conflict with.

LINK failed. with 1112
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' :Return code'0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' :Return code'0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' :Return code'0x2'
Stop.
error: Error compiling shiboken2

Let's investigate seriously. Where do you specify X64?

After all, I don't understand even if I read the Makefile.

In CMake, you can find some articles that make it the command prompt attached to Visual Studio 2015.

"Magic" was sweet.

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

There was also an option to specify wheel creation, and it seems that the git command will be executed, so change the command option to disable it and execute the build.

python setup.py bdist_wheel --ignore-git --qmake="C:\Qt\5.6\msvc2015_64\bin\qmake.exe" --cmake="C:\Program Files\CMake\bin\cmake.exe"

There was also an option to specify OpenSSL in setup.py, so if you look closely at the log, OpenSSL is disabled. Acha, Maika

Qt docs: C:/Qt/Docs/Qt-5.6
Qt plugins: C:/Qt/5.6/msvc2015_64/plugins
---
OpenSSL libs: None
==============================
Building module shiboken2...

30 minutes later ...

I went through the build. There are some strange things ...

running install_egg_info
Copying pyside_package\PySide2.egg-info to build\bdist.win-amd64\wheel\.\PySide2-2.0.0.dev0-py2.7.egg-info
running install_scripts
*** Install completed
C:\pyside\venv27\lib\site-packages\wheel\pep425tags.py:77: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
C:\pyside\venv27\lib\site-packages\wheel\pep425tags.py:81: RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
  warn=(impl == 'cp')):
C:\pyside\venv27\lib\site-packages\wheel\pep425tags.py:87: RuntimeWarning: Config variable 'Py_UNICODE_SIZE' is unset, Python ABI tag may be incorrect
  sys.version_info < (3, 3))) \
creating build\bdist.win-amd64\wheel\PySide2-2.0.0.dev0.dist-info\WHEEL

(venv27) C:\pyside\pyside-setup>

Installation

The wheel output destination is dist \ PySide2-2.0.0.dev0-cp27-cp27m-win_amd64.whl. If you pip install in the current environment, it is difficult to understand the cause when a problem occurs, so create a new virtualenv and install it.

(venv27) C:\pyside\pyside-setup>deactivate
C:\pyside\pyside-setup>cd ..
C:\pyside>
C:\pyside>python -m virtualenv venv_pyside
C:\pyside>venv_pyside\Scripts\activate.bat
(venv_pyside) C:\pyside>python -m pip install pyside-setup\dist\PySide2-2.0.0.dev0-cp27-cp27m-win_amd64.whl
Processing c:\pyside\pyside-setup\dist\pyside2-2.0.0.dev0-cp27-cp27m-win_amd64.whl
Installing collected packages: PySide2
Successfully installed PySide2-2.0.0.dev0
(venv_pyside) C:\pyside>python -m pip freeze
PySide2==2.0.0.dev0

Let's check if the sample works.

(venv_pyside) C:\pyside>python pyside-setup\sources\pyside2-examples\examples\dialogs\standarddialogs.py

It worked.

2016-12-17_15h30_29.png

The desired resource compiler! For the time being, check only the atmosphere that seems to move, and check the operation again this time. Huh.

(venv_pyside) C:\pyside>C:\pyside\venv_pyside\Lib\site-packages\PySide2\pyside2-rcc.exe
PySide2 resource compiler
Usage: C:\pyside\venv_pyside\Lib\site-packages\PySide2\pyside2-rcc.exe  [options] <inputs>

Options:
    -o file           Write output to file rather than stdout
    -py2              Generate code for any Python v2.x version
    -py3              Generate code for any Python v3.x version (default)
    -name name        Create an external initialization function with name
    -threshold level  Threshold to consider compressing files
    -compress level   Compress input files by level
    -root path        Prefix resource access path with root path
    -no-compress      Disable all compression
    -version          Display version
    -help             Display this information

Summary

Surprisingly, the build went smoothly and finished in a very short time.

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

python setup.py bdist_wheel --ignore-git --qmake="C:\Qt\5.6\msvc2015_64\bin\qmake.exe" --cmake="C:\Program Files\CMake\bin\cmake.exe"

python -m pip install dist\PySide2-2.0.0.dev0-cp27-cp27m-win_amd64.whl

I forgot to write a revision of the source.

> git rev-parse HEAD
6026e8b4f22d630e4e61424e153a605c060c22bb
> git submodule status
+eef6e46bf205e76616ae3fbfca92c917df22b6c4 sources/pyside2 (1.2.2-399-geef6e46)
+4ca11515b6c5376269cb91a4975e8c5b71a2cdb4 sources/pyside2-examples (heads/dev)
 7fe32567c75b6b9985b9efbecf74477c9e829fb2 sources/pyside2-tools (heads/dev)
+8611bda3b346762e0589402f130b73f20dd75914 sources/shiboken2 (1.2.2-168-g8611bda)
+ed7b7ceddc2c0ec6115d58a0611441d972ea1f97 wiki (heads/master)

OpenSSL is also invalid and I have not confirmed the operation at all, but I will share it for the time being. Download here

reference

https://fredrikaverpil.github.io/2016/08/17/compiling-pyside2/

Recommended Posts

Try building PySide2
Try building JupyterHub with Docker
Try python
try pysdl2
Try building an environment for MayaPython with VisualStudioCode