简体   繁体   中英

How can I install PySide on Travis?

My tests for Quamash depend on PySide (or PyQt eventually) for Python 3.4, so I'm wondering how I can install this dependency on Travis so that it's available to the tests?

I am aware that I can install PySide from source via pip, but that is a very slow process.

Let me know if I need to provide more info.

Installing via apt-get is currently not possible. See github issue and travis docs .

Three other options.

Just use pip

Your .travis.yml will include:

install:
  - pip install PySide

As you mentioned, it will take a LONG time to build PySide from source on the travis-ci servers. However, this method is guaranteed to work.

Wait for Travis CI to update to Ubuntu 14.04

Issue . Python3.4 is included in Ubuntu 14.04. Then, your .travis.yml could look like:

install:
    - sudo apt-get install python3-pyside

Build your own wheel

You can build your own PySide wheel so Travis-CI builds using Python3.4 do not have to build PySide from source.

Following these instructions , I built a PySide wheel by:

$ git clone https://github.com/PySide/pyside-setup.git pyside-setup
$ cd pyside-setup
$ python3.4 setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4 --version=1.2.2

You can then host this wheel somewhere, and access it using travis by:

install:
  - sudo apt-get install libqt4-dev
  - pip install PySide --no-index --find-links https://<your-site>;
  # Travis CI servers use virtualenvs, so we need to finish the install by the following
  - python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install

where <your-site> is a webpage that contains a link to the wheel named PySideXXXXXXX.whl , with the correct naming convention . Use --no-index to prevent pip from finding and installing a newer PySide from pypi .

I went ahead and tried this, basic usage works!

See the source .

The wheel is hosted at the repo's gh-pages .

Note on my machine with Ubuntu 14.04, building the wheel created the file dist/PySide-1.2.2-cp34-cp34m-linux_x86_64.whl which was roughly 17 MB. When I instead included the --standalone tag in the build step, the file was ~77 MB.

Note that as of yet, only import PySide has been tested. Due to this being built under Ubuntu 14.04 and Travis-Ci servers running Ubuntu 12.04, I do not know how functional the PySide library is. If you run into problems, you may want to redo this on a machine running Ubuntu 12.04.

Update:

The following python script

import PySide
from PySide import QtGui

fails when the PySide wheel was built on Ubuntu 14.04. See the failure . However, it succeeds when PySide is built on Ubuntu 12.04, see the success .

Using my PySide wheel

In your .travis.yml file, include the following:

install:
  - sudo apt-get install libqt4-dev
  - pip install PySide --no-index --find-links https://parkin.github.io/python-wheelhouse/;
  # Travis CI servers use virtualenvs, so we need to finish the install by the following
  - python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install

A good solution is to use the caching feature of Travis to cache wheels across builds.

Adding

language: python
cache: pip

to your .travis.yml caches $HOME/.cache/pip . As such, the PySide wheel will be built once and persist across rebuilds of your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM