Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
WIP: Move building to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Jul 30, 2024
1 parent 10a023b commit 26972fe
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 129 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build
on: pull_request
jobs:
build:
strategy:
matrix:
os: [windows-latest] # [macos-12, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Check-out repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
**/requirements.txt
- name: Install Dependencies
run: |
pip install -r requirements.txt
python build/locate_libsodium.py
- name: Build Executable
uses: Nuitka/Nuitka-Action@main
env:
PYTHONPATH: "pyipv8;src"
with:
nuitka-version: main
script-name: 'src/run_tribler.py'
standalone: true
macos-create-app-bundle: true
static-libpython: 'auto'
include-package: 'tribler'
nofollow-import-to: 'tribler.test_*'
include-onefile-external-data: 'libsodium*'
user-package-configuration-file: 'build/nuitka.yml'
enable-plugins: 'pony'
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }} Build
path: |
build/*.exe
*.dll
build/*.bin
build/*.app/**/*
8 changes: 8 additions & 0 deletions build/locate_libsodium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from sys import platform


if platform == "win32":
import shutil
from ctypes.util import find_library

shutil.copyfile(find_library("libsodium"), "libsodium.dll")
8 changes: 8 additions & 0 deletions build/nuitka.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- module-name: 'aiohttp_apispec'
data-files:
dirs:
- 'static'
- module-name: 'pony'
implicit-imports:
- depends:
- 'pony.orm.dbproviders.*'
19 changes: 0 additions & 19 deletions requirements-build.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ pillow
pony
pystray
pywin32;sys_platform=="win32"

PyQt5
numpy
pyqtgraph
102 changes: 0 additions & 102 deletions setup.py

This file was deleted.

9 changes: 6 additions & 3 deletions src/run_tribler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import pystray
from PIL import Image
from tribler.core.session import Session
from tribler.tribler_config import TriblerConfigManager

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -53,6 +51,9 @@ async def main() -> None:
"""
The main script entry point.
"""
from tribler.core.session import Session
from tribler.tribler_config import TriblerConfigManager

parsed_args = parse_args()
logging.basicConfig(level=parsed_args["log_level"], stream=sys.stdout)
logger.info("Run Tribler: %s", parsed_args)
Expand Down Expand Up @@ -85,7 +86,7 @@ async def main() -> None:
session = Session(config)
await session.start()

image_path = Path(__file__).absolute() / "../tribler/ui/public/tribler.png"
image_path = (Path("dist") / "tribler.png").absolute() # TODO: Temporary fix for build
image = Image.open(image_path.resolve())
url = f"http://localhost:{session.rest_manager.get_api_port()}/ui/#/downloads/all?key={config.get('api/key')}"
menu = (pystray.MenuItem('Open', lambda: webbrowser.open_new_tab(url)),
Expand All @@ -100,5 +101,7 @@ async def main() -> None:


if __name__ == "__main__":
if sys.platform == "win32":
os.add_dll_directory(str(Path(".").absolute()))
asyncio.set_event_loop(asyncio.SelectorEventLoop())
asyncio.run(main())
2 changes: 1 addition & 1 deletion src/tribler/core/restapi/webui_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self) -> None:
self._logger = logging.getLogger(self.__class__.__name__)
self.app.add_routes([web.get('/{path:.*}', self.return_files)])

self.webui_root = (pathlib.Path(__file__).absolute() / "../../../ui/").resolve()
self.webui_root = pathlib.Path(".").absolute().resolve() # TODO: Temporary fix for build
self.has_dist = (self.webui_root / 'dist').exists()
self.session = ClientSession() if not self.has_dist else None

Expand Down

0 comments on commit 26972fe

Please sign in to comment.