Merge pull request #115 from pythoninthegrass/tooling

Add tooling
This commit is contained in:
Roy 2023-08-11 14:08:12 -07:00 committed by GitHub
commit b5ab5d691a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 631 additions and 11 deletions

View File

@ -0,0 +1,13 @@
!poetry.lock
!pyproject.toml
.cache
.devcontainer
.git
.gitignore
.pytest_cache
.tool-versions
.venv
.vscode
**/__pycache__
Dockerfile*
README.md

136
.devcontainer/Dockerfile Normal file
View File

@ -0,0 +1,136 @@
# syntax=docker/dockerfile:1.6
# full semver just for python base image
ARG PYTHON_VERSION=3.11.4
FROM python:${PYTHON_VERSION}-slim-bullseye AS builder
# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive
# update apt repos and install dependencies
RUN apt -qq update && apt -qq install \
--no-install-recommends -y \
curl \
gcc \
libpq-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# pip env vars
ENV PIP_NO_CACHE_DIR=off
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
ENV PIP_DEFAULT_TIMEOUT=100
# poetry env vars
ENV POETRY_HOME="/opt/poetry"
ENV POETRY_VERSION=1.5.1
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
ENV POETRY_NO_INTERACTION=1
# path
ENV VENV="/opt/venv"
ENV PATH="$POETRY_HOME/bin:$VENV/bin:$PATH"
COPY requirements.txt requirements.txt
RUN python -m venv $VENV \
&& . "${VENV}/bin/activate"\
&& python -m pip install "poetry==${POETRY_VERSION}" \
&& python -m pip install -r requirements.txt
FROM python:${PYTHON_VERSION}-slim-bullseye AS runner
# setup standard non-root user for use downstream
ENV USER_NAME=appuser
ENV USER_GROUP=appuser
ENV HOME="/home/${USER_NAME}"
ENV HOSTNAME="${HOST:-localhost}"
ENV VENV="/opt/venv"
ENV PATH="${VENV}/bin:${VENV}/lib/python${PYTHON_VERSION}/site-packages:/usr/local/bin:${HOME}/.local/bin:/bin:/usr/bin:/usr/share/doc:$PATH"
# standardise on locale, don't generate .pyc, enable tracebacks on seg faults
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
# workers per core
# https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker/blob/master/README.md#web_concurrency
ENV WEB_CONCURRENCY=2
# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive
# install dependencies
RUN apt -qq update && apt -qq install \
--no-install-recommends -y \
bat \
curl \
dpkg \
git \
iputils-ping \
lsof \
p7zip \
perl \
shellcheck \
tldr \
tree \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd $USER_NAME \
&& useradd -m $USER_NAME -g $USER_GROUP
# create read/write dirs
RUN <<EOF
#!/usr/bin/env bash
mkdir -p /app/{certs,staticfiles}
chown -R "${USER_NAME}:${USER_GROUP}" /app/
EOF
USER $USER_NAME
WORKDIR $HOME
COPY --from=builder --chown=${USER_NAME}:${USER_GROUP} $VENV $VENV
# qol: tooling
RUN <<EOF
#!/usr/bin/env bash
# gh
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt update && apt install gh -y
apt remove dpkg -y
rm -rf /var/lib/apt/lists/*
# fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
yes | ~/.fzf/install
EOF
# qol: .bashrc
RUN tee -a $HOME/.bashrc <<EOF
# shared history
HISTFILE=/var/tmp/.bash_history
HISTFILESIZE=100
HISTSIZE=100
stty -ixon
[ -f ~/.fzf.bash ] && . ~/.fzf.bash
# aliases
alias ..='cd ../'
alias ...='cd ../../'
alias ll='ls -la --color=auto'
EOF
# $PATH
ENV PATH=$VENV_PATH/bin:$HOME/.local/bin:$PATH
# port needed by app
EXPOSE 8000
CMD ["sleep", "infinity"]

View File

@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Dev Environment",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"aaron-bond.better-comments",
"codezombiech.gitignore",
"eamodio.gitlens",
"EditorConfig.EditorConfig",
"GitHub.copilot-chat",
"GitHub.copilot",
"mads-hartmann.bash-ide-vscode",
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-vscode.atom-keybindings",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
"timonwong.shellcheck",
"yzhang.markdown-all-in-one"
]
}
},
// "forwardPorts": [
// 8080,
// 8081
// ]
}

View File

@ -0,0 +1,21 @@
asttokens==2.2.1
backcall==0.2.0
decorator==5.1.1
executing==1.2.0
ipython==8.14.0
jedi==0.19.0
markdown-it-py==3.0.0
matplotlib-inline==0.1.6
mdurl==0.1.2
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
prompt-toolkit==3.0.39
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.16.1
rich==13.5.2
six==1.16.0
stack-data==0.6.2
traitlets==5.9.0
wcwidth==0.2.6

34
.editorconfig Normal file
View File

@ -0,0 +1,34 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines and whitespace cleanup
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = true
# Protect whitespace in markdown files
[*.md]
trim_trailing_whitespace = false
# general formatting
[*.{bash,go,sh,zsh,justfile,Makefile}]
indent_style = tab
indent_size = 4
# Set default charset
[*.{html,xml,js,css,py}]
charset = utf-8
# python
[*.py]
indent_style = space
indent_size = 4
# webdev et al
[*.{html,xml,js,css,json,gql,lua,tf,tfvars,yml,yaml}]
indent_style = space
indent_size = 2

18
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#directory
version: 2
updates:
- package-ecosystem: "pip" # package manager
directory: "/" # Files stored in repository root
schedule:
interval: "weekly"
day: "saturday"
time: "10:00"
timezone: "America/Chicago"
open-pull-requests-limit: 5
versioning-strategy: increase-if-necessary

163
.gitignore vendored Normal file
View File

@ -0,0 +1,163 @@
# ETC
*.out
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

1
.shellcheckrc Normal file
View File

@ -0,0 +1 @@
disable=SC2153,SC2155,SC2046,SC1073,SC1078,SC1079,SC2016,SC1091,SC2034,SC2086,SC2153,SC2155,SC2236,SC2317,SC3037,SC3045,SC2046

2
.tool-versions Normal file
View File

@ -0,0 +1,2 @@
python 3.11.4
poetry 1.5.1

92
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,92 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// pytest: https://stackoverflow.com/questions/70259564/how-to-debug-the-current-python-test-file-with-pytest-in-vs-code
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${fileDirname}",
"pythonArgs": [
"-Xfrozen_modules=off"
],
"env": {
"PYDEVD_DISABLE_FILE_VALIDATION": "1"
}
// "args": ["-i", "response.xml", "-o", "response.csv"],
// "args": ["-d", "/Volumes/Data"],
// "args": ["-f", "menubar.dmg"],
// "args": ["-h"],
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver"
],
"django": true,
"justMyCode": true
},
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/.venv/bin/flask",
"console": "integratedTerminal",
"args": [
"run",
"--host",
"0.0.0.0",
"--port",
"8000"
],
"justMyCode": true
},
{
"name": "Python: Flet",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/.venv/bin/flet",
"console": "integratedTerminal",
"args": [
"run",
"main.py",
"-d"
],
"env": {
"PYDEVD_DISABLE_FILE_VALIDATION": "1",
},
"justMyCode": true
},
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"module": "pytest",
"args": [
"${file}"
],
"console": "integratedTerminal"
},
{
"name": "Node: Current File",
"type": "node",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"skipFiles": [
"<node_internals>/**"
],
// "runtimeExecutable": "${env:HOME}/.n/bin/node"
}
],
"ansible.python.interpreterPath": "${workspaceFolder}/.venv/bin/python"
}

14
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
"[python]": {
"editor.insertSpaces": true,
"editor.tabSize": 4,
},
"python.testing.pytestArgs": [
"."
],
// ! only disable analysis (pylance) if ruff is installed
// https://github.com/astral-sh/ruff-vscode
// "python.analysis.ignore": [
// "*"
// ],
}

116
README.md
View File

@ -2,12 +2,14 @@
<p align="center"> <p align="center">
<img src="https://github.com/cchrkk/NSLOSD-DL/raw/main/logo.svg" width=40% height=auto <img src="https://github.com/cchrkk/NSLOSD-DL/raw/main/logo.svg" width=40% height=auto
</p> </p>
<h1 align="center"> <h1 align="center">
NonSteamLaunchers 🚀 NonSteamLaunchers 🚀
</h1> </h1>
This script installs the latest GE-Proton, installs NonSteamLaunchers under one unique Proton prefix folder in your compatdata folder path called "NonSteamLaunchers" and adds them to your Steam Library. This script installs the latest GE-Proton, installs NonSteamLaunchers under one unique Proton prefix folder in your compatdata folder path called "NonSteamLaunchers" and adds them to your Steam Library.
So you can use them on Desktop or in Game Mode. So you can use them on Desktop or in Game Mode.
<h1 align="center"> <h1 align="center">
Features ✅ Features ✅
</h1> </h1>
@ -54,10 +56,11 @@ Supported Streaming Sites for games and as well as any website. 🌐
<h1 align="left"> <h1 align="left">
Find Games Find Games
</h1> </h1>
Use the "Find Games" button to load [Boilr](https://github.com/PhilipK/BoilR) this will open Boilr for you to set your settings so you can find your games easier. Use the "Find Games" button to load [Boilr](https://github.com/PhilipK/BoilR) this will open Boilr for you to set your settings so you can find your games easier.
<h1 align="center"> <h1 align="center">
How to Install🔧 How to Install 🔧
</h1> </h1>
<p align="center"> <p align="center">
@ -65,11 +68,12 @@ How to Install🔧
</p> </p>
<!--- Thanks https://github.com/Heus-Sueh --> <!--- Thanks https://github.com/Heus-Sueh -->
+ Go to desktop mode, right click the download button above and save the .desktop file to your Steam Deck desktop. * Go to desktop mode, right click the download button above and save the .desktop file to your Steam Deck desktop.
+ Go to your desktop, click the NonSteamLaunchers icon, it will download and run the latest NonSteamLaunchers.sh from this repository and run it. * Go to your desktop, click the NonSteamLaunchers icon, it will download and run the latest NonSteamLaunchers.sh from this repository and run it.
+ You will simply have to choose which launcher to install and let the script handle the rest. 💻 No files are left in your "Downloads" they are deleted after installation. * You will simply have to choose which launcher to install and let the script handle the rest. 💻 No files are left in your "Downloads" they are deleted after installation.
+ After running the script, launch Steam on your Steam Deck. You'll find the new launchers in your library under the non-steam tab. Click a launcher to see your installed games from that store, and launch them directly from Steam! Even in gamemode 🥳 * After running the script, launch Steam on your Steam Deck. You'll find the new launchers in your library under the non-steam tab. Click a launcher to see your installed games from that store, and launch them directly from Steam! Even in gamemode 🥳
<!--- TODO: handful of broken icons (cf. 🡺🡺🡺 ); probably should remove or replace them with more common font to handle unicode-->
<p align="center"> <p align="center">
▶️ YouTube Tutorial 🡺🡺🡺 https://www.youtube.com/watch?v=svOj4MTEAVc 🡸🡸🡸 ▶️ ▶️ YouTube Tutorial 🡺🡺🡺 https://www.youtube.com/watch?v=svOj4MTEAVc 🡸🡸🡸 ▶️
@ -89,21 +93,111 @@ How to Uninstall 🗑
Currently Working On 👷‍♂️ Currently Working On 👷‍♂️
</h1> </h1>
- Decky Loader Plugin ❌ * Decky Loader Plugin ❌
- Auto-download images and set them for library entries ❌ * Auto-download images and set them for library entries ❌
- Integrate better with [BoilR](https://github.com/PhilipK/BoilR) ❌ * Integrate better with [BoilR](https://github.com/PhilipK/BoilR) ❌
#
<h1 align="center"> <h1 align="center">
Contributing 🤝 Contributing 🤝
</h1> </h1>
If you have any suggestions or improvements for this script, feel free to open an issue or submit a pull request. If you have any suggestions or improvements for this script, feel free to open an issue or submit a pull request.
You can donate me on [ko-fi](https://ko-fi.com/moraroy), [liberapay](https://liberapay.com/moraroy) or [sponsor me on github](https://github.com/sponsors/moraroy)
You can donate to me on [ko-fi](https://ko-fi.com/moraroy), [liberapay](https://liberapay.com/moraroy), or [sponsor me on github](https://github.com/sponsors/moraroy)
## Development Environment
### Dev Container
Install [Docker](https://docs.docker.com/compose/install/). Once installed, a clean dev environment with a Docker container [native to VSCode](https://code.visualstudio.com/docs/devcontainers/create-dev-container#_dockerfile) is spun up automatically.
* [Command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (⇧⌘P) > Dev Containers: Reopen in Container
* F5 for debug
* May need to select interpreter (e.g., `/opt/venv/bin/python`) first
**VSCode Extensions (Dev Container)**
* [Atom Keymap](https://marketplace.visualstudio.com/items?itemName=ms-vscode.atom-keybindings)
* [Bash IDE](https://marketplace.visualstudio.com/items?itemName=mads-hartmann.bash-ide-vscode)
* [Better Comments](https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments)
* [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)
* [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
* [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot)
* [GitHub Copilot Chat](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat)
* [gitignore](https://marketplace.visualstudio.com/items?itemName=codezombiech.gitignore)
* [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)
* [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one)
* [MS Visual Studio Live Share](https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare)
* [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
* [Shellcheck](https://marketplace.visualstudio.com/items?itemName=timonwong.shellcheck)
### Manual Docker Instance
If VSCode isn't present or only the python portion (cf. `__init__.py`) is being worked on, it's possible to just run a Docker container on its own. The container installs the correct version of python and any dependencies (e.g., ipython, rich) in `requirements.txt`.
```bash
# navigate to directory with Dockerfile
cd .devcontainer/
# build image
docker build -t nonsteamlaunchers .
# run container
docker run -it --rm --name=mynonsteamlaunchers --workdir=/app -v $(pwd):/app nonsteamlaunchers bash
# exit container
exit
```
### Python virtual environment
Useful for the python module(s), but extra compared to the [dev container](#dev-container) portion that covers the core shell script.
```bash
# create virtual environment
python -m venv .venv
# activate virtual environment
source .venv/bin/activate
# install dependencies
python -m pip install -r requirements.txt
```
### Additional tooling
Additional tooling includes but is not limited to:
#### asdf
* Install [asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf)
* Usage
```bash
# add python plugin
asdf plugin-add python
# install stable python
asdf install python <latest|3.11.4>
# set stable to system python
asdf global python latest
# add poetry asdf plugin
asdf plugin-add poetry https://github.com/asdf-community/asdf-poetry.git
# install latest version via asdf
asdf install poetry <latest|1.5.1>
# set latest version as default
asdf global poetry latest
```
#### shellcheck
`.shellcheckrc` excludes various [bash language rules](https://github.com/koalaman/shellcheck/wiki/Ignore#ignoring-one-or-more-types-of-errors-forever). Useful to control noise vs. legitimate warnings/errors when using the shellcheck extension.
<h1 align="center"> <h1 align="center">
License 📝 License 📝
</h1> </h1>
This project is licensed under the MIT License. See the `LICENSE` file for more information. This project is licensed under the MIT License. See the `LICENSE` file for more information.