Skip to content
xfangfang edited this page Jan 27, 2022 · 2 revisions

Macast is built by GitHub-Actions, and can be compiled without local deployment environment. Build script is at build-macast.yaml.

If you want to build Macast locally, you can refer to the following content.

1. i18n

Macast supports multiple languages with the help of multiple contributors. If you want to have languages support in the compiled Macast, you need to compile it first.

If you want to add new languages to Macast or see which languages are currently supported, please check: Translation

build *.mo files

  • Linux / macOS

    # linux: install gettext
    sudo apt install -y gettext
    # macos: install gettext
    brew install gettext
    
    # run msgfmt
    for file in i18n/*; do msgfmt -o $file/LC_MESSAGES/macast.mo $file/LC_MESSAGES/macast.po;echo $file;done
  • Windows

    # download gettext
    $client.DownloadFile('https://github.com/xfangfang/Macast/releases/download/v0.1/gettext0.21-iconv1.16-static-64.zip','gettext.zip')
    7z x -ogettext gettext.zip bin/msgfmt.exe
    
    # run msgfmt
    Get-ChildItem i18n | ForEach-Object -Process{gettext/bin/msgfmt -o $_/LC_MESSAGES/macast.mo $_/LC_MESSAGES/macast.po;echo $_.name}

2. Run && Build

Development under MacOS

1. download mpv

wget https://laboratory.stolendata.net/~djinn/mpv_osx/mpv-latest.tar.gz
mkdir -p bin && tar --strip-components 2 -C bin -xzvf mpv-latest.tar.gz mpv.app/Contents/MacOS

2. run the source code

pip install -r requirements.txt
python Macast.py

3. package

pip install py2app
# try to install this version of setuptools if you cannot run Macast.app after build
pip install setuptools==44.0.0 
python setup.py py2app
cp -R bin dist/Macast.app/Contents/Resources/
open dist

Development under Windows

1. download mpv

You can download the latest MPV instead of using the MPV in the link below.

$client = new-object System.Net.WebClient
$client.DownloadFile('https://nchc.dl.sourceforge.net/project/mpv-player-windows/stable/mpv-0.33.0-x86_64.7z','mpv.7z')
7z x -obin mpv.7z *.exe

2. run the source code

pip install -r requirements.txt
python Macast.py

3. package

pip install pyinstaller
# build
pyinstaller --noconfirm -F -w ^
--additional-hooks-dir=. ^
--add-data="macast/.version;." ^
--add-data="macast/xml/*;macast/xml" ^
--add-data="i18n/zh_CN/LC_MESSAGES/*;i18n/zh_CN/LC_MESSAGES" ^
--add-data="macast/assets/*;macast/assets" ^
--add-data="macast/assets/fonts/*;macast/assets/fonts" ^
--add-binary="bin/mpv.exe;bin" ^
--icon=macast/assets/icon.ico ^
Macast.py

Development under Linux (example: Ubuntu)

1. install mpv

sudo apt install mpv

2. run the source code

pip install -r requirements.txt
python Macast.py
# if there is something wrong, try this:
export PYSTRAY_BACKEND=gtk && python3 Macast.py

Tips: Make sure you can use gi:

$ python3
Python 3.7.10 (default, Jun  3 2021, 17:51:26)
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>>

if there is something wrong, try: sudo apt-get install python3-gi

if you are using conda, check this https://stackoverflow.com/a/40303128

For details of GUI support, please refer to: https://pystray.readthedocs.io/en/latest/usage.html#selecting-a-backend

3. build with docker (x64)

To avoid the differences between different Linux operating systems, we use docker to build Macast.

docker run --rm -v "$(pwd):/src/" xfangfang/build-macast \
'pip install -r requirements.txt && \
pip install -U pyinstaller && \
pyinstaller --noconfirm -F -w \
--additional-hooks-dir=. \
--add-data="macast/.version:." \
--add-data="macast/xml/*:macast/xml" \
--add-data="i18n/zh_CN/LC_MESSAGES/*:i18n/zh_CN/LC_MESSAGES" \
--add-data="macast/assets/*:macast/assets" \
--add-data="macast/assets/fonts/*:macast/assets/fonts" \
--exclude-module=tkinter \
--distpath="app" \
Macast.py'

The docker image used in the construction can be built from the dockerfile in the root directory of this project or you can also use our pre built image: xfangfang/build-macast:latest