Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP - DO NOT USE] Pythonic and simpler refactor of wemod-launcher #138

Draft
wants to merge 77 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
245b5b2
refactor: Rename files, set executable bit
shymega Jul 11, 2024
f6d1c09
refactor: Update references to renamed modules
shymega Jul 12, 2024
97e6dc6
refactor: Move Python files to directory, fix some typos
shymega Jul 12, 2024
08e535b
refactor: Convert project to Poetry, with Nix flake
shymega Jul 12, 2024
3f69cb1
feat: Add initial util modules
shymega Jul 12, 2024
6b24c6a
fix: Update Poetry+Flake to work with Nix
shymega Jul 12, 2024
087c184
refactor: Refactor Log and Configuration utils
shymega Jul 12, 2024
ceb3683
fix: Fix broken LoggingHandler class
shymega Jul 12, 2024
2712573
refactor: Begin tidy up of `consts.py`
shymega Jul 12, 2024
ed57407
refactor: Prepare components for Python packaging
shymega Jul 12, 2024
3a8fdac
chore(flake): Remove unused overrides
shymega Jul 12, 2024
f7747f8
chore: Add note for later fix
shymega Jul 12, 2024
660a463
feat: Add script to Poetry
shymega Jul 12, 2024
45ea2bf
feat: Add initial start-up msg to CLI
shymega Jul 12, 2024
591b517
refactor: Move from YAML to TOML
shymega Jul 12, 2024
c5674b4
feat: Add initial Consts class, with `pathlib` support
shymega Jul 12, 2024
cf0fe74
feat; Get CLI to print STEAM_COMPAT_DATA_DIR
shymega Jul 12, 2024
e1fb882
feat(flake): Add overlay to Flake
shymega Jul 12, 2024
3e92732
chore: Bump deps and remove deps
shymega Jul 12, 2024
0e92c37
fix: Fix typo in STEAM_COMPAT_DATA_PATH env var
shymega Jul 12, 2024
364de04
fix: Remove debug print in `Configuration` class
shymega Jul 12, 2024
e70d570
fix: Rename import in accordance with dependency change to stdlib
shymega Jul 12, 2024
d2da431
chore: Run `black` on `utils/`
shymega Jul 13, 2024
c7e7b1e
fix(logger): Add optional env override for log file path
shymega Jul 13, 2024
28979d4
feat: Add initial GFX module - and welcome screen
shymega Jul 13, 2024
28b56f1
feat: Add initial Prefix module
shymega Jul 13, 2024
270c10f
chore: Use Nixpkgs 24.05
shymega Jul 13, 2024
a09fa72
fix: Allow for Tkinter to work
shymega Jul 13, 2024
362e784
chore: Remove unused print in CLI
shymega Jul 13, 2024
5c73e2b
refactor: Simplify gfx/WelcomeScreenGfx
shymega Jul 13, 2024
990307f
refactor: Return `None` rather than fail on non-existsent cfg key
shymega Jul 13, 2024
b385e7f
fix: Change Flake description
shymega Jul 13, 2024
819134f
chore: Add notes in pyproject.toml
shymega Jul 13, 2024
d122478
chore: Remove erroneous pyproject.toml
shymega Jul 13, 2024
1431003
fix: Add fallback to STEAM_COMPAT_DATA_PATH const
shymega Jul 13, 2024
62a5ad5
chore: Bump Poetry lock
shymega Jul 13, 2024
ce75bb9
fix: Make logging less chatty
shymega Jul 13, 2024
6cc5a43
refactor(Logger): Refactor `Logger` class
shymega Jul 13, 2024
1bdb2e8
fix: Fix typo in Flake overlay
shymega Jul 13, 2024
83395cf
fix: Adjust path in Configuration class and fix Flake
shymega Jul 13, 2024
835bc95
feat: Add `devenv` support, hooks & flake-compat support
shymega Jul 13, 2024
96f8be6
fix: Fix `actionlint` warning
shymega Jul 13, 2024
9643d2d
feat: Add 'devcontainer' support
shymega Jul 13, 2024
ea4cea9
fix: Remove unnecessary `.expanduser()`
shymega Jul 13, 2024
ac7e7ac
fix: Remove `.`/`_` replacement logic for logging module
shymega Jul 13, 2024
562c0aa
refactor: Use pyright and pass inputs to devenv
shymega Jul 13, 2024
e109423
feat: Add replacement `winepath`/`unixpath`
shymega Jul 13, 2024
eeab391
feat: Add more consts
shymega Jul 13, 2024
554301b
refactor: Use absolute module paths
shymega Jul 13, 2024
a0b2b2b
feat: Add initial (broken) PyInstaller support
shymega Jul 13, 2024
4082493
fix: Fix lint error with literals in Logger
shymega Jul 13, 2024
9432d96
fix: Lock Python to Python 3.11
shymega Jul 13, 2024
ef91166
chore: Format `devenv.nix`
shymega Jul 13, 2024
131db0f
feat: Export Tcl/Tk libraries
shymega Jul 13, 2024
8300ccf
chore: Remove erroneous print statement
shymega Jul 13, 2024
0603d15
fix(core_nodeps): Revert debugging change
shymega Jul 13, 2024
2af0447
fix: Fix missing `--env=` prefix on Flatpak
shymega Jul 13, 2024
cb54e7d
fix(CI): Fix CI workflow with new structure for codebase
shymega Jul 13, 2024
01f059a
fix(WineUtils): Fix potential breakages in WinNT path test
shymega Jul 13, 2024
60073e1
feat: Add caching for WeMod logo download
shymega Jul 13, 2024
08191c9
fix(CI): Fix typo in CI
shymega Jul 13, 2024
53b691e
fix: Simplify pyinstaller.py script (Poetry)
shymega Jul 13, 2024
1c04a30
fix(envrc): Use devenv in envrc
shymega Jul 13, 2024
8477c6d
refactor: Migrate to PDM from Poetry
shymega Nov 16, 2024
1b524e2
chore: Run lints on Nix files
shymega Nov 16, 2024
645a12f
Resolve conflicts
Dec 1, 2024
b3a21e8
Add helpers and move nix files
Dec 1, 2024
3a7d1f1
Add missing AGPL to dev.sh and move remaning nix file
Dec 1, 2024
d05de36
Merge remote-tracking branch 'origin/refactor-up' into refactor-spell…
Dec 2, 2024
3d834ff
Add usage warning
marvin1099 Dec 2, 2024
af540e0
Merge pull request #7 from marvin1099/refactor-spell+licence
marvin1099 Dec 2, 2024
ad55913
Merge pull request #141 from marvin1099/refactor-shymega
marvin1099 Dec 2, 2024
dbc2c29
Add PDM to pyinstaller and add build helper
marvin1099 Dec 2, 2024
e12da7f
Make a new consts.py version
marvin1099 Dec 4, 2024
acdefc5
Now the config manager uses Atribute read
marvin1099 Dec 4, 2024
1d77b49
A update for const and conf and new logger
marvin1099 Dec 5, 2024
41b3ec5
Revert Nix file movement
Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"customizations": {
"vscode": {
"extensions": [
"mkhl.direnv"
]
}
},
"image": "ghcr.io/cachix/devenv:latest",
"overrideCommand": false,
"updateContentCommand": "devenv test"
}
10 changes: 10 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

watch_file flake.nix
watch_file flake.lock
if ! use flake . --impure
then
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
18 changes: 9 additions & 9 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
- name: Check if Python files or wemod file changed
id: check_files
run: |
if echo "${{ steps.changed_files.outputs.added_modified }}" | grep -E '\.py$|wemod' > /dev/null; then
echo "PYTHON_FILES_CHANGED=true" >> $GITHUB_ENV
if echo "${{ steps.changed_files.outputs.added_modified }}" | grep -E 'wemod_launcher/\.py$' > /dev/null; then
echo "PYTHON_FILES_CHANGED=true" >> "$GITHUB_ENV"
else
echo "PYTHON_FILES_CHANGED=false" >> $GITHUB_ENV
echo "PYTHON_FILES_CHANGED=false" >> "$GITHUB_ENV"
fi

- name: Set up Python
Expand All @@ -53,7 +53,7 @@ jobs:
if: env.PYTHON_FILES_CHANGED == 'true'
id: run_black
run: |
black -l 78 -t py312 ./*.py ./wemod
black -l 78 -t py312 ./wemod_launcher/

- name: Increment version number
if: steps.run_black.outcome == 'success' && env.PYTHON_FILES_CHANGED == 'true'
Expand All @@ -64,13 +64,13 @@ jobs:
new_ver = ver + 0.001;
printf(" script_version = \"%.3f\"\n", new_ver);
}
!/script_version = "/ { print $0 }' coreutils.py > coreutils.py.tmp && mv coreutils.py.tmp coreutils.py
!/script_version = "/ { print $0 }' wemod_launcher/coreutils.py > wemod_launcher/coreutils.py.tmp && mv wemod_launcher/coreutils.py.tmp wemod_launcher/coreutils.py

current_ver=$(awk '/script_version = "/ {print $3}' coreutils.py | tr -d '"')
current_ver=$(awk '/script_version = "/ {print $3}' wemod_launcher/coreutils.py | tr -d '"')
awk -v ver="$current_ver" '/The WeMod Launcher is currently on version / {
printf("**The WeMod Launcher is currently on version %.3f.**\n", ver);
}
!/The WeMod Launcher is currently on version / { print $0 }' readme.md > readme.tmp && mv readme.tmp readme.md
!/The WeMod Launcher is currently on version / { print $0 }' README.md > README.tmp && mv README.tmp README.md

- name: Commit changes on dev
if: github.ref == 'refs/heads/dev' && steps.run_black.outcome == 'success' && env.PYTHON_FILES_CHANGED == 'true'
Expand All @@ -79,7 +79,7 @@ jobs:
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git update-index --chmod=+x *.py wemod
git update-index --chmod=+x wemod_launcher/**.py
git commit -m 'Github actions automatic code formatting on dev branch' -m 'This is an automatic task, run by a GitHub workflow, to automatically format the Python code in the repo, with the code formatter "black"' || echo "No changes to commit"
git push
env:
Expand All @@ -92,7 +92,7 @@ jobs:
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git update-index --chmod=+x *.py wemod
git update-index --chmod=+x wemod_launcher/**.py
git commit -m 'Github actions automatic code formatting on main branch' -m 'This is an automatic task, run by a GitHub workflow, to automatically format the Python code in the repo, with the code formatter "black"' || echo "No changes to commit"
git push
env:
Expand Down
19 changes: 17 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
.cache/
logs/
wemod_bin/
wemod_data/
wemod_venv/
__pycache__/

wemod.conf
wemod.log
winetricks
pip.pyz
poetry.lock

# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml

dist/
.pdm-build/
.pdm-python
2 changes: 2 additions & 0 deletions readme.md → README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# WeMod Launcher (Wemod for Linux)
**The WeMod Launcher is currently on version 1.506.**

### This refactor is under development, do not use yet.

## DISCLAIMER
This project is *NOT* affiliated with, funded by, or paid by WeMod.
The work done here is purely from the contributors who donate their time and efforts.
Expand Down
15 changes: 15 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2024 The DeckCheatz Developers
#
# SPDX-License-Identifier: Apache-2.0

(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }).defaultNix
66 changes: 66 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{ pkgs
, self
, inputs
, ...
}:
let
freesimplegui = pkgs.python3Packages.buildPythonApplication rec {
pname = "freesimplegui";
version = "5.1.1";
src = pkgs.fetchPypi {
inherit pname version;
sha256 = "sha256-LwlGx6wiHJl5KRgcvnUm40L/9fwpGibR1yYoel3ZZPs=";
};
};
in
{
packages =
with pkgs;
[
git
pdm
pyright
]
++ (with pkgs.python3Packages; [
requests
pyxdg
setuptools
pyinstaller
tkinter
])
++ [ freesimplegui ];

languages = {
nix.enable = true;
python = {
enable = true;
package = pkgs.python313Full;
};
shell.enable = true;
};

difftastic.enable = true;
devcontainer.enable = true;

pre-commit.hooks = {
shellcheck.enable = true;
shfmt.enable = true;
# FIXME: Fix Flake8 lints.
# flake8.enable = true;
actionlint.enable = true;
nixpkgs-fmt.enable = true;
black = {
enable = true;
settings.flags = "-l 78 -t py312";
};
# FIXME: Fix Markdown lints.
# markdownlint.enable = true;
statix.enable = true;
};

enterShell = ''
export TK_LIBRARY="${pkgs.tk.outPath}/lib/${pkgs.tk.libPrefix}"
export TCL_LIBRARY="${pkgs.tcl.outPath}/lib/${pkgs.tcl.libPrefix}"
'';

}
Loading