1
0
Fork 0
mirror of synced 2024-06-26 10:11:19 +12:00

Merge pull request #44 from ChemicalXandco/windows_desktop_shortcut

Use windows .msi installer for desktop shortcut
This commit is contained in:
Dummerle 2021-05-11 14:05:41 +02:00 committed by GitHub
commit ec168a4c5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 109 additions and 27 deletions

View file

@ -46,7 +46,7 @@ jobs:
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update AUR package
pyinstaller-windows:
cx-freeze-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
@ -55,25 +55,16 @@ jobs:
python-version: '3.8'
- name: Install python deps
run: |
pip3 install pyinstaller setuptools wheel
pip3 install cx_Freeze setuptools wheel
pip3 install -r requirements.txt
- name: Prepare
run: cp rare/__main__.py ./
- name: Build
run: pyinstaller
--icon=rare/styles/Logo.ico
--onefile
--name Rare
--add-data="Rare/languages/*;Rare/languages"
--add-data="Rare/Styles/*;Rare/Styles"
--windowed
__main__.py
run: python3 freeze.py bdist_msi
- name: Upload files to GitHub
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/Rare.exe
asset_name: Rare.exe
file: dist/Rare*.msi
asset_name: Rare.msi
tag: ${{ github.ref }}
overwrite: true

4
.gitignore vendored
View file

@ -6,5 +6,7 @@ __pycache__
/.vscode
/build
/dist
/deb_dist
*.tar.gz
/Rare.egg-info/
/venv
/venv

View file

@ -41,11 +41,11 @@ Install via `pip`.
## Run from source
1. Run `pip install -r requirements.txt` to get dependencies. If you use `pacman` you can run `sudo pacman --needed -S python-wheel python-setuptools python-pyqt5 python-qtawesome python-requests python-pillow`
2. For unix operating systems run `sh start.sh`. For windows run `set PYTHONPATH=%CD% && python Rare`
2. For unix operating systems run `sh start.sh`. For windows run `set PYTHONPATH=%CD% && python rare`
## Why Rare?
- Rare uses much less RAM than electron based apps such as [HeroicGL](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher) and EpicGL which allows the games to run better.
- Rare only uses ~50MB of RAM which is much less than the electron based [HeroicGamesLauncher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher) uses.
- Rare supports all major platforms (Windows, Linux, macOS) unlike the alternatives.
## Features

74
freeze.py Normal file
View file

@ -0,0 +1,74 @@
import sys
from cx_Freeze import setup, Executable
from rare import __version__
# Packages to include
python_packages = []
# Modules to include
python_modules = []
base = None
name = None
build_options = {}
build_exe_options = {}
shortcutName = None
shortcutDir = None
bdist_msi_options = None
src_files = []
external_so_files = []
if sys.platform == 'win32':
base = 'Win32GUI'
name = 'Rare.exe'
shortcut_table = [
('DesktopShortcut', # Shortcut
'DesktopFolder', # Directory
'Rare', # Name
'TARGETDIR', # Component
'[TARGETDIR]'+name, # Target
None, # Arguments
'A gui for Legendary.', # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # Working Directory
)]
msi_data = {"Shortcut": shortcut_table}
bdist_msi_options = {'data': msi_data, "all_users": True}
build_options["bdist_msi"] = bdist_msi_options
else:
name = 'Rare'
src_files += [
'LICENSE',
'README.md',
'rare/styles/Logo.ico',
]
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options["packages"] = python_packages
build_exe_options["include_files"] = src_files + external_so_files
build_exe_options["includes"] = python_modules
build_exe_options["excludes"] = ["setuptools", "tkinter", "pkg_resources"]
# Set options
build_options["build_exe"] = build_exe_options
setup(name = 'Rare',
version = __version__,
description = 'A gui for Legendary.',
options = build_options,
executables = [
Executable('rare/__main__.py',
targetName=name,
icon='rare/styles/Logo.ico',
base=base,
shortcutName=shortcutName,
shortcutDir=shortcutDir,
),
],
)

View file

@ -8,6 +8,10 @@ import requests
from PIL import Image, UnidentifiedImageError
from PyQt5.QtCore import pyqtSignal, QLocale, QSettings
# Windows
if os.name == "nt":
from win32com.client import Dispatch
from rare import lang_path, __version__, style_path
from custom_legendary.core import LegendaryCore
@ -174,12 +178,22 @@ def create_desktop_link(app_name, core: LegendaryCore, type_of_link="desktop"):
# Windows
elif os.name == "nt":
if type_of_link == "desktop":
path = os.path.expanduser(f"~/Desktop/")
elif type_of_link == "start_menu":
logger.info("Startmenu link is not supported on windows")
return
else:
return
with open(path+igame.title+".bat", "w") as desktop_file:
desktop_file.write(f"rare launch {app_name}")
# Target of shortcut
target = sys.argv[0]
# Name of link file
linkName = igame.title + '.lnk'
desktopFolder = os.path.expanduser('~/Desktop/')
# Path to location of link file
pathLink = os.path.join(desktopFolder, linkName)
# Add shortcut
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(pathLink)
shortcut.Targetpath = target
shortcut.Arguments = f'launch {app_name}'
shortcut.WorkingDirectory = os.getcwd()
shortcut.IconLocation = os.path.join(os.getcwd(), 'Logo.ico')
shortcut.save()

View file

@ -4,4 +4,5 @@ PyQt5
QtAwesome
notify-py
psutil
pypresence
pypresence
pywin32; platform_system == "Windows"