简体   繁体   English

如何在Mac OS X上安装PySide v0.3.1?

[英]How to install PySide v0.3.1 on Mac OS X?

I'm trying to install PySide v0.3.1 in Mac OS X, for Qt development in python. 我正在尝试在Mac OS X中安装PySide v0.3.1,以便在python中进行Qt开发。

As a pre-requisite, I have installed CMake and the Qt SDK . 作为前提条件,我已经安装了CMakeQt SDK

I have gone through the documentation and come up with the following installation script: 我浏览了文档并提出了以下安装脚本:

export PYSIDE_BASE_DIR="<my_dir>"

export APIEXTRACTOR_DIR="$PYSIDE_BASE_DIR/apiextractor-0.5.1"
export GENERATORRUNNER_DIR="$PYSIDE_BASE_DIR/generatorrunner-0.4.2"
export SHIBOKEN_DIR="$PYSIDE_BASE_DIR/shiboken-0.3.1"
export PYSIDE_DIR="$PYSIDE_BASE_DIR/pyside-qt4.6+0.3.1"
export PYSIDE_TOOLS_DIR="$PYSIDE_BASE_DIR/pyside-tools-0.1.3"

pushd .

cd $APIEXTRACTOR_DIR
cmake . 

cd $GENERATORRUNNER_DIR
cmake -DApiExtractor_DIR=$APIEXTRACTOR_DIR .

cd $SHIBOKEN_DIR
cmake -DApiExtractor_DIR=$APIEXTRACTOR_DIR -DGeneratorRunner_DIR=$GENERATORRUNNER_DIR .

cd $PYSIDE_DIR
cmake -DShiboken_DIR=$SHIBOKEN_DIR/libshiboken -DGENERATOR=$GENERATORRUNNER_DIR .

cd $PYSIDE_TOOLS_DIR
cmake .

popd

Now, I don't know if this installation script is ok, but apparently everything works fine. 现在,我不知道此安装脚本是否正常,但显然一切正常。 Each component (apiextractor, generatorrunner, shiboken, pyside-qt and pyside-tools) gets compiled into its own directory. 每个组件(apiextractor,generatorrunner,shiboken,pyside-qt和pyside-tools)都被编译到其自己的目录中。

The problem is that I don't quite understand how PySide gets into the system's python environment. 问题是我不太了解PySide如何进入系统的python环境。 In fact, when I start a python shell, I cannot import PySide: 实际上,当我启动python shell时,无法导入PySide:

>>> import PySide
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PySide

Note: I am aware of the Installing PySide - OSX question, but that question is not relevant anymore, because it is about a specific a dependency on the Boost libraries, but with version 0.3.0 PySide moved from a Boost based source code to a CPython one. 注意:我知道安装PySide-OSX问题,但是这个问题不再相关,因为它与Boost库的特定依赖关系有关,但是PySide版本0.3.0已从基于Boost的源代码移至CPython之一。

I don't have any MacOS experience but assuming it's similar to any *nix, let's go: 我没有任何MacOS经验,但是假设它与任何* nix类似,那就开始吧:

About the script: Isn't it missing some "make, make install" commands? 关于脚本:它是否缺少一些“ make,make install”命令? The version you posted just run cmake to configure the build. 您发布的版本只需运行cmake即可配置构建。 Also for testing, I set -DCMAKE_INSTALL_PREFIX= for all modules. 同样为了测试,我为所有模块设置了-DCMAKE_INSTALL_PREFIX =。 That way everything is installed in the same place and CMake takes care of finding them for me, as long as I used the same install prefix for each one. 这样,只要我为每个安装了相同的安装前缀,所有内容都将安装在同一位置,CMake会为我找到它们。 The directory layout in your script is quite complicated and mixes build and source directories. 脚本中的目录布局非常复杂,混合了构建目录和源目录。

About finding PySide: once everything is properly compiled and installed, the directory where the "PySide" directory was installed must be available in the PYTHONPATH variable. 关于查找PySide:正确编译并安装所有内容后,PYTHONPATH变量中必须提供“ PySide”目录的安装目录。 In the example below, 在下面的示例中,

Here's a simple version of a build script(works on Ubuntu): 这是构建脚本的简单版本(可在Ubuntu上使用):

#!/bin/bash

BUILD_ROOT=/tmp/pyside-build
INSTALL_PREFIX=/tmp/sandbox

function build_module {
    cd $BUILD_ROOT
    echo Cloning project $1 from url $2
    git clone --depth 1 $2 $BUILD_ROOT/$1

    BUILD_DIR=$BUILD_ROOT/$1/build
    mkdir -p $BUILD_DIR
    cd $BUILD_DIR

    echo Configuring $1 build.
    cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ..

    echo Configured $1. Starting build.
    make LD_LIBRARY_PATH=$INSTALL_PREFIX/lib

    echo Built $1. Installing.
    make install
    echo Successfully built and installed $1
}

rm -rf $BUILD_ROOT
mkdir -p $BUILD_ROOT
build_module apiextractor git://gitorious.org/pyside/apiextractor.git
build_module generatorrunner git://gitorious.org/pyside/generatorrunner.git
build_module shiboken git://gitorious.org/pyside/shiboken.git
build_module pyside-shiboken git://gitorious.org/pyside/pyside-shiboken.git

Run it and wait a while (Qt is quite big). 运行它并等待一会儿(Qt很大)。 :) :)

This script will download all packages into /tmp/pyside-build, build each one in its own "build" directory and install everything into /tmp/sandbox. 该脚本会将所有软件包下载到/ tmp / pyside-build中,在各自的“ build”目录中构建每个软件包,然后将所有内容安装到/ tmp / sandbox中。 Then, I just had to set PYTHONPATH to /tmp/sandbox/lib/python2.6/site-packages and PySide worked fine. 然后,我只需要将PYTHONPATH设置为/tmp/sandbox/lib/python2.6/site-packages,PySide可以正常工作。

In answer to the original post... 在回答原始帖子时...

What your script would have done is generate the necessary build files to build the pyside bindings, but it wouldn't have done the build itself. 您的脚本将执行的操作是生成必要的构建文件以构建pyside绑定,但它本身并没有完成。 To do the build itself you'd need to execute a 'make', then a 'make install' in each of the build directories. 要进行构建本身,您需要在每个构建目录中执行“ make”,然后执行“ make install”。


I've gotten most of the way through getting pyside 0.3.1 up and running on the Mac (SnowLeopard 10.6.3), but am hung up on the final compile step. 在安装pyside 0.3.1并在Mac(SnowLeopard 10.6.3)上运行的过程中,我已经完成了大部分工作,但是却挂在最后的编译步骤上。 My script is a bit less straightforward than yours, but in essence similar. 我的脚本比您的脚本简单一些,但本质上相似。

I have run into and worked around a number of problems to get to the final compile, and am hoping that I can help some folks along with the solutions/workarounds I've devised. 我遇到并解决了许多问题,以进行最终编译,并希望我可以为一些人提供我设计的解决方案/变通办法。 Also, maybe collectively we can figure out how to get through the final step. 另外,也许我们可以共同弄清楚如何完成最后一步。

I'm going to include the build script that I'm using, and the log of the changes I had to make in the distro to get it running. 我将包括我正在使用的构建脚本,以及为了使其运行而必须在发行版中进行的更改的日志。 But first, the step that I'm stuck on... mainly, I don't understand the error message, and the requested file doesn't seem to exist... 但是首先,我坚持的步骤...主要是,我不理解错误消息,并且所请求的文件似乎不存在...

I hope this will help move support for the mac along... 我希望这将有助于推动对Mac的支持...

I can't post this directly on stack overflow since its too long, so here is the link to the post on the mailing list over at pyside. 我不能将其直接发布到堆栈溢出中,因为它太长了,所以这里是pyside上邮件列表中该帖子的链接。

http://lists.openbossa.org/pipermail/pyside/2010-June/000812.html http://lists.openbossa.org/pipermail/pyside/2010-June/000812.html

While it's a been couple months since this question originally was asked I ran across the official PySide build script repo at: 自最初提出此问题以来已经过去了几个月,但我遇到了以下官方PySide构建脚本存储库:

http://qt.gitorious.org/pyside/buildscripts http://qt.gitorious.org/pyside/buildscripts

The README covers the build process: 自述文件涵盖了构建过程:

http://qt.gitorious.org/pyside/buildscripts/blobs/master/README http://qt.gitorious.org/pyside/buildscripts/blobs/master/README

It seems to be fairly automatic with my only caveat so far being that it pulls down libxslt via brew - I can't say authoritatively if libxslt shipped with Snow Leopard or not - but it's definitely in Lion by default. 到目前为止,这似乎是相当自动的,但我唯一需要注意的是,它会通过brew下拉libxslt-我不能说libxslt是否随Snow Leopard一起提供了权威性-但默认情况下它肯定在Lion中。

Seemingly the only manual install step is putting cmake on your system. 似乎唯一的手动安装步骤是将cmake放在系统上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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