Skip to content

Commit

Permalink
feat: add pyinstaller release
Browse files Browse the repository at this point in the history
  • Loading branch information
0xArdi committed Jul 4, 2024
1 parent 382287b commit e978c86
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 133 deletions.
84 changes: 52 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,68 @@ on:
- 'v*.*.*'

jobs:
release-middleware:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/checkout@master
- uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get autoremove
sudo apt-get autoclean
python -m pip install --upgrade pip
pip install poetry twine
- name: Build wheels and source tarball
run: |
poetry build
- name: Publish Olas Operate Middleware
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip-existing: true
packages-dir: dist/
build-macos-pyinstaller:
runs-on: macos-latest
strategy:
matrix:
arch: [ x64, arm64 ]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: '1.4.0'
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-path: ~/my-custom-path
installer-parallel: true

- name: Install dependencies
run: poetry install

- name: Get trader bin
run: |
python -c "import yaml; config = yaml.safe_load(open('templates/trader.yaml')); trader_version = config['configuration']['trader_version']; print(f'::set-output name=trader_version::{trader_version}')"
mkdir dist && curl -L -o dist/aea_bin https://github.com/valory-xyz/trader/releases/download/${{ steps.extract.outputs.trader_version }}/trader_bin_${{ matrix.arch }}
- name: Build with PyInstaller
run: |
poetry run pyinstaller operate/services/utils/tendermint.py --onefile
poetry run pyinstaller --collect-data eth_account --collect-all aea --collect-all autonomy --collect-all operate --collect-all aea_ledger_ethereum --collect-all aea_ledger_cosmos --collect-all aea_ledger_ethereum_flashbots --hidden-import aea_ledger_ethereum --hidden-import aea_ledger_cosmos --hidden-import aea_ledger_ethereum_flashbots operate/pearl.py --add-binary dist/aea_bin:. --add-binary dist/tendermint:. --onefile --name pearl_${{ matrix.arch }}
- name: Upload Release Assets
uses: actions/upload-artifact@v2
with:
name: pearl_${{ matrix.arch }}
path: dist/pearl_${{ matrix.arch }}

release-operate:
runs-on: macos-latest
needs:
- "release-middleware"
steps:
- "build-macos-pyinstaller"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/setup-node@v1
with:
node-version: "20.11"
- name: Download binary
run: mkdir electron/bins && curl -L -o electron/bins/pearl_arm64 https://tempfileserver.staging.autonolas.tech/pearl_arm64 && chmod +x electron/bins/pearl_arm64 && curl -L -o electron/bins/pearl_x64 https://tempfileserver.staging.autonolas.tech/pearl_arm64 && chmod +x electron/bins/pearl_x64
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: pearl_x64
path: electron/bins/
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: pearl_arm64
path: electron/bins/
- uses: snok/install-poetry@v1
with:
version: "1.7.1"
Expand Down
9 changes: 9 additions & 0 deletions operate/pearl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
# ------------------------------------------------------------------------------

"""File used for pyinstaller to create a single executable file."""
import os
import sys
from pathlib import Path
import aea.configurations.validation as validation_module

# patch for the _CUR_DIR value
validation_module._CUR_DIR = Path(sys._MEIPASS) / validation_module._CUR_DIR
validation_module._SCHEMAS_DIR = os.path.join(validation_module._CUR_DIR, "schemas")


# pylint: disable=all
# mypy: ignore-errors
Expand Down
10 changes: 10 additions & 0 deletions operate/pyinstaller_cur_dir_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys
from pathlib import Path


# Define a runtime hook to patch the _CUR_DIR value
def patch_cur_dir():
import your_module_name
if getattr(sys, 'frozen', False):
your_module_name._CUR_DIR = Path(sys._MEIPASS) / your_module_name._CUR_DIR

63 changes: 0 additions & 63 deletions pearl_operate.spec

This file was deleted.

1 change: 1 addition & 0 deletions templates/trader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ description: "A single-agent service (sovereign agent) placing bets on Omen"
hash: bafybeihrogxx2kgl7euvhqsbh33fi4tzuupxodoheraqxd6lkvtvljewtu
image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75
configuration:
trader_version: v0.16.4
nft: bafybeidok5gwivdabwiuqigy3qzq5ulbw6uqgrlc7aq2ihrazxvil2lxkm
rpc: http://localhost:8545 # User provided
agent_id: 14
Expand Down
38 changes: 0 additions & 38 deletions tendermint.spec

This file was deleted.

0 comments on commit e978c86

Please sign in to comment.