1
0
Fork 0
mirror of synced 2024-05-19 12:02:54 +12:00

Rare: Update scripts to use the new entry point

This commit is contained in:
loathingKernel 2023-09-02 22:23:36 +03:00
parent bdbb61d3a6
commit ff2b9f2605
No known key found for this signature in database
GPG key ID: CE0C72D0B53821FD
9 changed files with 46 additions and 46 deletions

View file

@ -31,7 +31,7 @@ jobs:
deb-package: deb-package:
needs: version needs: version
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- name: Install Makedeb - name: Install Makedeb
run: | run: |
@ -41,9 +41,9 @@ jobs:
sudo apt install makedeb sudo apt install makedeb
- name: Prepare source directory - name: Prepare source directory
run: | run: |
git clone https://mpr.hunterwittenborn.com/rare.git build git clone https://mpr.makedeb.org/rare build
sed -i 's/source=.*/source=("rare-test::git+$url")/g' build/PKGBUILD sed -i 's/source=.*/source=("rare-test::git+$url")/g' build/PKGBUILD
sed -i "s/\$pkgver/test/g" build/PKGBUILD sed -i "s/\$pkgver/${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}/g" build/PKGBUILD
- name: build deb - name: build deb
run: | run: |
@ -73,7 +73,6 @@ jobs:
sudo pip3 install appimage-builder sudo pip3 install appimage-builder
- name: Build - name: Build
run: | run: |
cp rare/__main__.py .
appimage-builder --skip-test appimage-builder --skip-test
mv Rare-*.AppImage Rare.AppImage mv Rare-*.AppImage Rare.AppImage
mv Rare-*.AppImage.zsync Rare.AppImage.zsync mv Rare-*.AppImage.zsync Rare.AppImage.zsync
@ -198,7 +197,7 @@ jobs:
pip3 install -r requirements-presence.txt pip3 install -r requirements-presence.txt
pip3 install . pip3 install .
- name: Build - name: Build
run: cxfreeze -c rare/__main__.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI run: cxfreeze -c rare/main.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI
- name: Compress - name: Compress
run: | run: |
python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'dist')" python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'dist')"

View file

@ -35,7 +35,7 @@ jobs:
twine upload dist/* twine upload dist/*
deb-package: deb-package:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- name: Install Makedeb - name: Install Makedeb
run: | run: |
@ -78,7 +78,6 @@ jobs:
sudo pip3 install appimage-builder sudo pip3 install appimage-builder
- name: Build - name: Build
run: | run: |
cp rare/__main__.py .
appimage-builder --skip-test appimage-builder --skip-test
mv Rare-*.AppImage Rare.AppImage mv Rare-*.AppImage Rare.AppImage
mv Rare-*.AppImage.zsync Rare.AppImage.zsync mv Rare-*.AppImage.zsync Rare.AppImage.zsync
@ -212,7 +211,7 @@ jobs:
pip3 install -r requirements-presence.txt pip3 install -r requirements-presence.txt
pip3 install . pip3 install .
- name: Build - name: Build
run: cxfreeze -c rare/__main__.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI run: cxfreeze -c rare/main.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI
- name: Compress - name: Compress
run: | run: |
python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'dist')" python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'dist')"

View file

@ -3,13 +3,12 @@ version: 1
script: script:
# Remove any previous build # Remove any previous build
- rm -rf AppDir Rare | true - rm -rf AppDir | true
# Make usr and icons dirs # Make usr and icons dirs
- mkdir -p AppDir/usr/src - mkdir -p AppDir/usr/src
- mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps/ - mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps/
# Copy source files # Copy source files
- cp -r rare AppDir/usr/src/rare - cp -r rare AppDir/usr/src/rare
- mv AppDir/usr/src/rare/__main__.py AppDir/usr/src/
# copy Logo # copy Logo
- cp AppDir/usr/src/rare/resources/images/Rare.png AppDir/usr/share/icons/hicolor/256x256/apps/ - cp AppDir/usr/src/rare/resources/images/Rare.png AppDir/usr/share/icons/hicolor/256x256/apps/
# Install application dependencies # Install application dependencies
@ -23,7 +22,7 @@ AppDir:
icon: Rare icon: Rare
version: 1.10.7 version: 1.10.7
exec: usr/bin/python3 exec: usr/bin/python3
exec_args: $APPDIR/usr/src/__main__.py $@ exec_args: $APPDIR/usr/src/rare/main.py $@
apt: apt:
arch: amd64 arch: amd64
allow_unauthenticated: true allow_unauthenticated: true

View file

@ -31,9 +31,11 @@ bdist_msi_options = {
base = "Win32GUI" base = "Win32GUI"
exe = Executable( exe = Executable(
"rare/__main__.py", "rare/main.py",
base=base, icon="rare/resources/images/Rare.ico", base=base,
target_name="Rare") icon="rare/resources/images/Rare.ico",
target_name=name
)
setup( setup(
name=name, name=name,

View file

@ -35,7 +35,7 @@ legendary-gl = "^0.20.34"
typing-extensions = "^4.3.0" typing-extensions = "^4.3.0"
[tool.poetry.scripts] [tool.poetry.scripts]
start = "rare.__main__:main" start = "rare.main:main"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
Nuitka = "^1.0.6" Nuitka = "^1.0.6"

View file

@ -4,7 +4,5 @@ __codename__ = "Garlic Crab"
# For PyCharm profiler # For PyCharm profiler
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
from argparse import Namespace from rare.main import main
from rare import client sys.exit(main())
status = client.start(Namespace(debug=True, silent=False, offline=False, test_start=False))
sys.exit(status)

27
rare/__main__.py Executable file → Normal file
View file

@ -1,29 +1,4 @@
import os
import pathlib
import sys
if __name__ == "__main__": if __name__ == "__main__":
import sys
from rare.main import main from rare.main import main
# run from source
# insert raw legendary submodule
# sys.path.insert(
# 0, os.path.join(pathlib.Path(__file__).parent.absolute(), "legendary")
# )
# insert source directory
if "__compiled__" not in globals():
sys.path.insert(0, str(pathlib.Path(__file__).parents[1].absolute()))
# If we are on Windows, and we are in a "compiled" GUI application form
# stdout (and stderr?) will be None. So to avoid `'NoneType' object has no attribute 'write'`
# errors, redirect both of them to devnull
if os.name == "nt" and (getattr(sys, "frozen", False) or ("__compiled__" in globals())):
# Check if stdout and stderr are None before redirecting
# This is useful in the case of test builds that enable console
if sys.stdout is None:
sys.stdout = open(os.devnull, 'w')
if sys.stderr is None:
sys.stderr = open(os.devnull, 'w')
sys.exit(main()) sys.exit(main())

28
rare/main.py Normal file → Executable file
View file

@ -1,9 +1,22 @@
import multiprocessing import multiprocessing
import os import os
import pathlib
import sys
from argparse import ArgumentParser from argparse import ArgumentParser
def main() -> int: def main() -> int:
# If we are on Windows, and we are in a "compiled" GUI application form
# stdout (and stderr?) will be None. So to avoid `'NoneType' object has no attribute 'write'`
# errors, redirect both of them to devnull
if os.name == "nt" and (getattr(sys, "frozen", False) or ("__compiled__" in globals())):
# Check if stdout and stderr are None before redirecting
# This is useful in the case of test builds that enable console
if sys.stdout is None:
sys.stdout = open(os.devnull, 'w')
if sys.stderr is None:
sys.stderr = open(os.devnull, 'w')
# fix cx_freeze # fix cx_freeze
multiprocessing.freeze_support() multiprocessing.freeze_support()
@ -101,3 +114,18 @@ def main() -> int:
from rare.components import start from rare.components import start
return start(args) return start(args)
if __name__ == "__main__":
# run from source
# insert raw legendary submodule
# sys.path.insert(
# 0, os.path.join(pathlib.Path(__file__).parent.absolute(), "legendary")
# )
# insert source directory if running `main.py` as python script
# Required by AppImage
if "__compiled__" not in globals():
sys.path.insert(0, str(pathlib.Path(__file__).parents[1].absolute()))
sys.exit(main())

View file

@ -142,7 +142,7 @@ def get_rare_executable() -> List[str]:
if sys.executable == os.path.abspath(sys.argv[0]): if sys.executable == os.path.abspath(sys.argv[0]):
executable = [sys.executable] executable = [sys.executable]
else: else:
executable = [sys.executable, os.path.abspath(sys.argv[0])] executable = [os.path.abspath(sys.argv[0])]
elif platform.system() == "Windows": elif platform.system() == "Windows":
executable = [sys.executable] executable = [sys.executable]