我有一个小的 python 程序,它只依赖于 wxPython。我在 Linux 上开发了这个,我已经设法在 Travis CI(github 上的 seguid_calculator)上使用 wine 设置自动构建 Windows 可执行文件。
我的解决方案结合了最近发布的 wine 和 Pyinstaller。
我想为 MacOS 做类似的事情。我知道 Travis 上也有一个 MacOSX 构建环境。我对 MacOSX 操作系统的经验为零,而且我没有 Mac。我了解到您可以使用名为“自制软件”的东西安装第三方软件包
有没有我想要做的例子?一个示例 travis.yml 文件会很棒!
感谢您的任何输入, /比约恩
* 编辑 *
我创建了一个只打开一个窗口的示例 wxpython 应用程序。它位于 https://github.com/BjornFJohansson/macapp . 我使用下面的 .travis.yml 生成无法运行的可执行文件。
os:
- osx
language: objective-c
python:
- '2.7'
before_install:
- brew update
- brew outdated xctool || brew upgrade xctool
- brew install python
- brew install wxpython
- pip install pyinstaller
- pyinstaller --noconsole --onefile hw.py
- ls
- ls dist/
- hdiutil create dist/hw.dmg -srcfolder dist/ -ov
install: true
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: VK1oVWQCRomgcFNVua00B3YSsotezzU1p6/fh73/0vwQFzVMolVnAsnfSq6EAwIcJvakU0TI9pqZR+0S3PKnUs+Kn3Ar8OwQ88t2azZNwewBfKua3tM2/7BF4y7O0gOtN1F29Yxyu0zPInIVY17BqGygibQ1kthBTm+tj3YyNW8=
file:
- "dist/hw"
- "dist/hw.dmg"
on:
tags: true
all_branches: true
repo: BjornFJohansson/macapp
基本上,首先我会更新 xtools(我看到很多人这样做,所以我决定也这样做)。然后我 brew 安装 python 和 wxpython。然后我 pip 安装 pyinstaller。我使用 pyinstaller 命令生成可执行文件 (hw) 和 ./dist 下的“hw.app”文件夹。
我没有设法部署 .app 文件夹,所以我使用 hdiutil 创建了一个 .dmg。 然后我部署到 github 版本。
有人能告诉我这个设置可能有什么问题吗?
Travis 日志可以在这里找到:https://travis-ci.org/BjornFJohansson/macapp
最佳答案
它不起作用的原因是通过自制软件安装的 wxPython 版本不是 32 位。您需要从 wxPython 主页安装 dmg。我在那里找到了一个脚本:https://github.com/ayufan/travis-osx-vm-templates/blob/master/scripts/packages.sh
我 fork 你的例子并设法让它运行 ( https://github.com/paulmueller/macapp/releases )。
.travis.yml 现在看起来像这样:
language: objective-c
python:
- '2.7'
before_install:
- which python
- brew install python --universal --framework
- brew install wget
- which python
- export VERSIONER_PYTHON_PREFER_32_BIT=yes
- defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
- which python
- python --version
# https://github.com/Homebrew/homebrew/issues/34470
#- arch -i386 brew install wxpython --universal
- mkdir dl
- cd dl
- wget http://downloads.sourceforge.net/wxpython/wxPython3.0-osx-3.0.2.0-cocoa-py2.7.dmg
- ls
- cd ..
- sudo ./packages.sh
- arch -i386 python -c "import wx; print wx.__version__"
- arch -i386 pip install pyinstaller
- arch -i386 pyinstaller --noconsole --onefile hw.py
- ls
- hdiutil create dist/hw.dmg -srcfolder dist/ -ov
- zip -r dist/hw.zip dist/hw.app
- ls dist/
install: true
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: KjdN4hSHWU3ZDg6lpDNMB2we9jLayM9C8pwyQrV/Xzq8HNH5eNHP8ScI64tvnS0yJegOXnHFwUhUrkMtEs3X29TKrom+8tJ5E52IdBO7xO8fqOfeugC2239vLzc3tNI6RJX/K7CZTsSRu5U++1RJVgcWYjrCln87DuXG+HZRdOI=
file:
- "dist/hw.dmg"
- "dist/hw.zip"
on:
tags: true
all_branches: true
repo: paulmueller/macapp
关于python - 如何在 Travis CI 上构建 MacOSX 可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29587581/