From bdd287976e818abf31a9ebd8d3775bac1ba6f065 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Sat, 20 Jul 2024 09:26:40 -0600 Subject: [PATCH] Mods --- README.md | 2 ++ cromulant/manifest.json | 8 +++++ setup.py | 69 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 cromulant/manifest.json create mode 100644 setup.py diff --git a/README.md b/README.md index 8696c9a..0e26bbf 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ Then a random number between 1 and 10 is picked. For each number an action happens to produce an update. +The top score is calculated as (Triumph - Hits). + ## Technology This is made with python + qt (pyside6) diff --git a/cromulant/manifest.json b/cromulant/manifest.json new file mode 100644 index 0000000..2f699ea --- /dev/null +++ b/cromulant/manifest.json @@ -0,0 +1,8 @@ +{ + "version": "1.0.0", + "title": "Cromulant", + "program": "cromulant", + "author": "madprops", + "repo": "github.com/madprops/cromulant", + "description": "Toy game about ants" +} \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..bb89bae --- /dev/null +++ b/setup.py @@ -0,0 +1,69 @@ +from setuptools import setup, find_packages +from pathlib import Path +import shutil +import json +import platform + +with open("cromulant/manifest.json", "r") as file: + manifest = json.load(file) + +title = manifest["title"] +program = manifest["program"] +version = manifest["version"] + + +def _post_install(): + system = platform.system() + + if system == "Linux": + try: + _copy_icon_file() + _create_desktop_file() + except Exception as e: + print(f"Error during post install: {e}") + + +def _copy_icon_file(): + source = Path(f"{program}/img/icon_1.jpg").expanduser().resolve() + destination = Path(f"~/.local/share/icons/{program}.png").expanduser().resolve() + shutil.copy2(source, destination) + + +def _create_desktop_file(): + content = f"""[Desktop Entry] +Version=1.0 +Name={title} +Exec={Path(f"~/.local/bin/{program}").expanduser().resolve()} +Icon={Path(f"~/.local/share/icons/{program}.png").expanduser().resolve()} +Terminal=false +Type=Application +Categories=Utility; +""" + + file_path = Path(f"~/.local/share/applications/{program}.desktop").expanduser().resolve() + + with open(file_path, 'w') as f: + f.write(content) + + +with open("requirements.txt") as f: + requirements = f.read().splitlines() + +package_data = {} +package_data[program] = ["*.png", "*.jpg", "*.json", "*.mp3"] + +setup( + name=title, + version=version, + install_requires=requirements, + packages=find_packages(where="."), + package_dir={"": "."}, + package_data=package_data, + entry_points={ + "console_scripts": [ + f"{program}={program}.main:main", + ], + }, +) + +_post_install() \ No newline at end of file