如何在Travis CI上构建MacOSX可执行文件?
我有一个只依赖wxPython的小型python程序。我在Linux上开发了这个工具,我设法使用Travis CI上的wine(github上的seguid_calculator)自动构建一个windows可执行文件。如何在Travis CI上构建MacOSX可执行文件?
我的解决方案涉及最近的葡萄酒版本和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(我见过很多这样做,所以我决定也这样做)。然后我酿造安装python和wxpython。然后我pip安装pyinstaller。我使用pyinstaller命令生成可执行文件(hw)和./dist下的“hw.app”文件夹。
我没有设法部署.app文件夹,所以我用hdiutil做了一个.dmg。 然后我部署到github版本。
有人能告诉我这个设置有什么问题吗?
特拉维斯日志可以在这里找到:https://travis-ci.org/BjornFJohansson/macapp
它没有工作的原因是通过自制软件安装的wxPython版本不是32位。您需要从wxPython主页安装dmg。我发现了一个脚本,在那里:https://github.com/ayufan/travis-osx-vm-templates/blob/master/scripts/packages.sh
我分叉了你的例子,并设法让它运行(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
This指出,他们目前不接受新的“多系统”的要求,所以你将不能够在任何情况下,以构建OS-X直到特拉维斯CI升级。
一般来说,你将需要得到接受的多操作系统再加入os: os-x
您.travis.yml
文件,(可能在一个分支),然后寻找如何设置蟒蛇,pyinstaller &的wxPython了在OS-X - 家所有3页在这方面都非常有帮助。
感谢,我创建了一个示例应用程序的OS X –
您不需要os:
部分。
我在使用Travis CI在Mac OSx上部署wxPython应用程序时遇到类似问题。不幸的是我的设置有点复杂,但它可能有助于解决您的问题。
我正在使用conda构建一切。
我特拉维斯配置:
# Mac OS X Python build
language:
- objective-c
python:
- "2.7"
install:
# install python via brew
- brew install python
# make brews python the system default
- brew link --overwrite python
- which python
- python --version
# pip init
- pip install --upgrade pip
# use anaconda
- pip install conda
- conda init
- conda install --yes matplotlib
- conda install --yes scipy numpy=1.8
- conda install --yes 'numpy<1.9.0'
- conda install --yes wxpython
# final pip installs
- pip install cython
- pip install wheel
- pip install sympy
- pip install git+git://github.com/pyinstaller/[email protected]e0ebcc914798
# show packages
- pip freeze
# build extensions
- python setup.py develop
script:
# Create wheel pacakge
- python setup.py bdist_wheel
# Create binary
- ./freeze_pyinstaller/macOSx_bundle_script.sh
before_deploy:
- export RELEASE_PKG_FILEA=$(ls ./dist/*bin.zip)
- export RELEASE_PKG_FILEB=$(ls ./dist/*app.zip)
- export RELEASE_PKG_FILEC=$(ls ./dist/*.whl)
- echo "deploying $RELEASE_PKG_FILEA to GitHub releases"
- echo "deploying $RELEASE_PKG_FILEB to GitHub releases"
- echo "deploying $RELEASE_PKG_FILEC to GitHub releases"
# This section was created with
# sudo apt-get install ruby1.9.1-dev
# sudo gem install travis
# travis setup releases
deploy:
provider: releases
api_key:
secure: gQu6BKSo5sucrieOvyLz/kn5Ai+vrnXK6Kdm+WMqzXE6keE0LzujXOHWQX2G2EBl1NCjzvt3HrEvJqwGEjLbduJBBPBHaOy71AfKuHaxRQPlFWMLn2iAVVval3q7xU4kEfjAdS50WmARqh6sT7gMj+pHpg1e3pz1SxybOeC40+k=
skip_cleanup: true
# Allow
file_glob: true
file:
- "${RELEASE_PKG_FILEA}"
- "${RELEASE_PKG_FILEB}"
- "${RELEASE_PKG_FILEC}"
on:
tags: true
repo: paulmueller/PyCorrFit
我不得不创建一个应用程序的问题(可能是由于我的古构建系统)。因此,我曾与含有一个脚本来代替应用程序文件夹中的二进制文件:
cd $(dirname "$0")
open -a Terminal.app ./MYAPP.bin
哪里MYAPP
是应用程序的名字,我以前曾改名为在应用文件夹中的二进制MYAPP.bin
。
当应用程序启动时,终端打开并启动二进制文件。
以下是使用版本内置特拉维斯:
https://github.com/paulmueller/PyCorrFit/releases/tag/0.8.7travis2
这是建立在一个旧的MacBook一个工作版本:
https://github.com/paulmueller/PyCorrFit/releases/tag/0.8.7
与特拉维斯内置的版本有一些种类的wxpython错误。我没有安装最新OSx的Mac。看看它可能会帮助你(也许我)。
我是用蟒蛇也考虑和畅达一路,也许不适去接近它的未来。 –
我有一位朋友在运行Yosemite(10.10.3)的Mac上测试您的可执行文件。以下是压缩应用[zip应用](https://drive.google.com/file/d/0ByF9bZqbql11UkxTYjJqanJ0a3dubzVTZk5HY1NnUmhZLTBN/view?usp=sharing)和[dmg](https://drive.google.com/file/d/0ByF9bZqbql11NWwxT1lOZEtGS0tNRW92NUVzRHgySkU2SGZR/view?usp = sharing) –
我会投这个答案,但是我没有足够的声望,谢谢。 –