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

发布于 2024-09-02 12:53:23 字数 1737 浏览 4 评论 0 原文

我正在尝试在 Mac OS X 中安装 PySide v0.3.1,以便在 python 中进行 Qt 开发。

作为先决条件,我已经安装了 CMakeQt SDK

我已经浏览了 文档 并提出了以下内容安装脚本:

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

现在,我不知道这个安装脚本是否正常,但显然一切正常。每个组件(apiextractor、generatorrunner、shiboken、pyside-qt 和 pyside-tools)都被编译到自己的目录中。

问题是我不太明白PySide是如何进入系统的python环境的。事实上,当我启动 python shell 时,我无法导入 PySide:

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

注意:我知道 安装 PySide - OSX 问题,但该问题不再相关,因为它是关于 Boost 库的特定依赖关系,但版本 0.3.0 PySide 从基于 Boost 的源代码移至 CPython 源代码。

I'm trying to install PySide v0.3.1 in Mac OS X, for Qt development in python.

As a pre-requisite, I have installed CMake and the Qt 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.

The problem is that I don't quite understand how PySide gets into the system's python environment. In fact, when I start a python shell, I cannot import 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

遥远的她 2024-09-09 12:53:23

我没有任何 MacOS 经验,但假设它与任何 *nix 类似,让我们开始:

关于脚本:它是否缺少一些“make、make install”命令?您发布的版本只需运行 cmake 来配置构建。另外,为了进行测试,我为所有模块设置了 -DCMAKE_INSTALL_PREFIX= 。这样,所有内容都安装在同一个位置,只要我为每个内容使用相同的安装前缀,CMake 就会帮我找到它们。脚本中的目录布局非常复杂,并且混合了构建目录和源目录。

关于查找 PySide:正确编译和安装所有内容后,安装“PySide”目录的目录必须在 PYTHONPATH 变量中可用。在下面的示例中,

这是一个简单版本的构建脚本(适用于 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

运行它并等待一段时间(Qt 相当大)。 :)

此脚本会将所有包下载到 /tmp/pyside-build 中,在其自己的“build”目录中构建每个包,并将所有内容安装到 /tmp/sandbox 中。然后,我只需将 PYTHONPATH 设置为 /tmp/sandbox/lib/python2.6/site-packages ,PySide 就可以正常工作。

I don't have any MacOS experience but assuming it's similar to any *nix, let's go:

About the script: Isn't it missing some "make, make install" commands? The version you posted just run cmake to configure the build. Also for testing, I set -DCMAKE_INSTALL_PREFIX= for all modules. 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. 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. In the example below,

Here's a simple version of a build script(works on 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). :)

This script will download all packages into /tmp/pyside-build, build each one in its own "build" directory and install everything into /tmp/sandbox. Then, I just had to set PYTHONPATH to /tmp/sandbox/lib/python2.6/site-packages and PySide worked fine.

熊抱啵儿 2024-09-09 12:53:23

作为对原始帖子的回答...

您的脚本要做的是生成必要的构建文件来构建 pyside 绑定,但它本身不会完成构建。要进行构建本身,您需要在每个构建目录中执行“make”,然后执行“make install”。


我已经完成了在 Mac (SnowLeopard 10.6.3) 上安装 pyside 0.3.1 并运行的大部分工作,但我在最后的编译步骤上挂断了。我的脚本比你的稍微简单一些,但本质上很相似。

我遇到并解决了许多问题以完成最终编译,并希望我可以帮助一些人以及我设计的解决方案/解决方法。另外,也许我们可以共同找出如何完成最后一步。

我将包含我正在使用的构建脚本,以及我必须在发行版中进行的更改日志才能使其运行。但首先,我坚持的步骤...主要是,我不理解错误消息,并且请求的文件似乎不存在...

我希望这将有助于推动对 mac 的支持。 ..

我无法将其直接发布在堆栈溢出上,因为它太长了,所以这里是 pyside 邮件列表上该帖子的链接。

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

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. To do the build itself you'd need to execute a 'make', then a 'make install' in each of the build directories.


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. 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...

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.

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

如日中天 2024-09-09 12:53:23

虽然这个问题最初被问到已经有几个月了,但我遇到了官方的 PySide 构建脚本存储库:

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

自述文件涵盖了构建过程:

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

这似乎是相当自动的,到目前为止我唯一的警告是它通过brew拉下libxslt - 我可以'不能权威地说 libxslt 是否随 Snow Leopard 一起提供 - 但默认情况下它肯定在 Lion 中。

似乎唯一的手动安装步骤是将 cmake 安装到您的系统上。

While it's a been couple months since this question originally was asked I ran across the official PySide build script repo at:

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

The README covers the build process:

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.

Seemingly the only manual install step is putting cmake on your system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文