diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b4dbc8c..d62952c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,9 +102,6 @@ jobs: - name: cx_freeze run: pip3 install --upgrade cx_freeze wheel - - name: prepare Files - run: mv rare/__main__.py rare/Rare.py - - name: Build run: python freeze.py bdist_msi @@ -119,33 +116,3 @@ jobs: asset_name: Rare.msi tag: ${{ github.ref }} overwrite: true - - mac_os: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - - name: Rare Dependencies - run: pip install -r requirements.txt - - - name: install pyinstaller - run: pip install pyinstaller - - - name: copy files - run: mv rare/__main__.py __main__.py - - - name: run pyinstaller - run: pyinstaller -F --name Rare --add-data "rare/languages/*:rare/languages" --add-data "rare/resources/colors/*:rare/resources/colors" --add-data "rare/resources/images/*:rare/resources/images/" --add-data "rare/resources/stylesheets/RareStyle/*:rare/resources/stylesheets/RareStyle/" --windowed --icon rare/resources/images/Rare.icns __main__.py - - - name: upload to GitHub - uses: svenstaro/upload-release-action@2.2.1 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: dist/Rare.app - asset_name: Rare_MacOS.app - tag: ${{ github.ref }} - overwrite: true \ No newline at end of file diff --git a/freeze.py b/freeze.py index 537de341..f991141e 100644 --- a/freeze.py +++ b/freeze.py @@ -1,82 +1,35 @@ -import sys - from cx_Freeze import setup, Executable from rare import __version__ -# Packages to include -python_packages = [ - "PyQt5", - 'requests', - 'PIL', - 'qtawesome', - 'psutil', - 'pypresence', - 'win32com' +shortcut_table = [ + ("DesktopShortcut", # Shortcut + "DesktopFolder", # Directory_ + "Rare", # Name + "TARGETDIR", # Component_ + "[TARGETDIR]Rare.exe", # Target + None, # Arguments + None, # Description + None, # Hotkey + None, # Icon + None, # IconIndex + None, # ShowCmd + 'TARGETDIR' # WkDir + ) ] -# Modules to include -python_modules = [] +msi_data = {"Shortcut": shortcut_table} +bdist_msi_options = {'data': msi_data} +base = "Win32GUI" -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": False} - build_options["bdist_msi"] = bdist_msi_options -else: - name = 'Rare' - -src_files += [ - 'LICENSE', - 'README.md', - 'rare/resources/images/Rare.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/Rare.py', - target_name=name, - icon='rare/resources/images/Rare.ico', - base=base, - shortcut_name=shortcutName, - shortcut_dir=shortcutDir, - ), - ], - ) +setup( + name="Rare", + version=__version__, + description="A GUI for Legendary", + options={ + "bdist_msi": bdist_msi_options, + }, + executables=[Executable("rare/__main__.py", + base=base, icon="rare/resources/images/Rare.ico", + target_name="Rare")] +) diff --git a/rare/__main__.py b/rare/__main__.py index 02206555..5b125cd9 100644 --- a/rare/__main__.py +++ b/rare/__main__.py @@ -8,6 +8,7 @@ from rare.utils import singleton, utils def main(): + parser = ArgumentParser() parser.add_argument("-V", "--version", action="store_true", help="Shows version and exits") parser.add_argument("-S", "--silent", action="store_true", @@ -53,12 +54,14 @@ def main(): args.silent = True # fix error in cx_freeze - import multiprocessing - multiprocessing.freeze_support() from rare.app import start start(args) if __name__ == '__main__': + import multiprocessing + + multiprocessing.freeze_support() + main() diff --git a/rare/utils/utils.py b/rare/utils/utils.py index 90ce4268..7b5f6e9e 100644 --- a/rare/utils/utils.py +++ b/rare/utils/utils.py @@ -347,8 +347,12 @@ def create_desktop_link(app_name, core: LegendaryCore, type_of_link="desktop") - # Add shortcut shell = Dispatch('WScript.Shell') shortcut = shell.CreateShortCut(pathLink) - shortcut.Targetpath = sys.executable - shortcut.Arguments = f'{target} launch {app_name}' + if sys.executable.endswith("Rare.exe"): + executable = sys.executable + else: + executable = f"{sys.executable} {os.path.abspath(sys.argv[0])}" + shortcut.Targetpath = executable + shortcut.Arguments = f'launch {app_name}' shortcut.WorkingDirectory = os.getcwd() # Icon