From 62d5473d0ac97b1ab25b1ea32f8b2cd17d88f676 Mon Sep 17 00:00:00 2001 From: "Janisch, Mirco" Date: Sun, 15 Oct 2023 17:17:06 +0200 Subject: [PATCH] try with cx_freeze for windows --- README.md | 5 +++++ requirements-dev.txt | 3 ++- setup.py | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 setup.py diff --git a/README.md b/README.md index a22e773..ba8bf45 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ - [Install](#install) - [Precompiled binaries](#precompiled-binaries) - [Run from source](#run-from-source) + - [Build from source](#build-from-source) - [Setup the `config.json`](#setup-the-configjson) - [Command line arguments](#command-line-arguments) - [Future ideas](#future-ideas) @@ -57,6 +58,10 @@ python3 -m source.main > :warning: These instructions are intended for Linux-based systems. If you're using Windows, you can achieve similar results with PowerShell. You cannot use the `apt` command, so you'll need to manually [install Python](https://www.python.org/downloads/windows/) and change the `source.venv/bin/activate` command with `.\.venv\Scripts\Activate.ps1`. +### Build from source + +If you want to take this even further and compile your own executable, you can either run the appropriate build script ([`build.linux.sh`](build.linux.sh) or [`build.windows.ps1`](build.windows.ps1)) or you follow their instructions on your own. + ## Setup the `config.json` No matter if you run from source or you prefer the precompiled binaries, both come with the [`config.example.json`](https://github.com/R3tr0BoiDX/smwc-browser/blob/master/config.example.json). You will need to **rename** this to `config.json` and fill out all the entries. It will look something like this: diff --git a/requirements-dev.txt b/requirements-dev.txt index 960c169..7296403 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,4 +2,5 @@ pylint deptry flake8 mypy -pyinstaller \ No newline at end of file +pyinstaller +cx_Freeze \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..dc3dacf --- /dev/null +++ b/setup.py @@ -0,0 +1,40 @@ +import os + +# from cx_Freeze import setup, Executable + + +def find_all_scripts(directory): + script_list = [] + for root, _, files in os.walk(directory): + for file in files: + if file.endswith(".py"): + script_list.append(os.path.relpath(os.path.join(root, file))) + return script_list + + +def parse_requirements(requirements_file): + with open(requirements_file, mode="r", encoding="utf-8") as file: + return [line.strip() for line in file] + + +all_scripts = find_all_scripts("source") +print(all_scripts) + +required_modules = parse_requirements("requirements.txt") +print(required_modules) + + +# build_exe_options = {"packages": ["os"], "includes": ["tkinter"]} +# executables=[Executable("source/main.py", base=base)] + +# setup( +# name="smwc-browser", +# version="1.0", +# description="A browser for SMW Central", +# executables=[Executable(script) for script in all_scripts], +# options={ +# "build_exe": { +# "packages": required_modules, +# } +# }, +# )