Skip to content

Commit

Permalink
Create releasable version
Browse files Browse the repository at this point in the history
  • Loading branch information
Grub4K committed Jun 18, 2024
1 parent 0ca9905 commit e73b0c1
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: Grub4K
21 changes: 21 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Checks
on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
check:
name: Code check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install hatch
run: pip install hatch
- name: Run check
run: hatch fmt --check
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
push:
tags:
- '*'

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
permissions:
# trusted publishing
id-token: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install hatch
run: pip install hatch

- name: Build package
run: hatch build

- name: Create release
env:
GH_TOKEN: ${{ github.token }}
tag: ${{ github.ref_name }}
run: |
gh release create --notes-from-tag "${tag}" dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.pyc
/dist/
/vrcar/_version.py
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# vrcar
VR controlled Raspberry Pi car

Initially developed using the [Freenove 4WD](<https://store.freenove.com/products/fnk0043>), a [Raspberry Pi 4 Model B 4GB](<https://www.raspberrypi.com/products/raspberry-pi-4-model-b/?variant=raspberry-pi-4-model-b-4gb>) and a [Meta Quest 3](<https://www.meta.com/de/en/quest/quest-3>)

## Usage
The client is easiest installed using [`pipx`](<https://pipx.pypa.io/>):

```shell
pipx install "vrcar[pygame,vr]"
```

These are what the available groups will be able to load:
- `pygame`
- Window with the camera video feed
- Keyboard controls
- Joystick controls
- `vr`
- Camera video feed in the headset
- Headset rotation controls camera rotation

## License
`vrcar` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
`vrcar` is distributed under the terms of the [MIT](<https://spdx.org/licenses/MIT.html>) license.
22 changes: 5 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -34,9 +34,6 @@ vr = [
# "PyOpenGL-accelerate",
"Pillow",
]
server = [
# TODO
]

[project.scripts]
vrcar = "vrcar.__main__:main"
Expand All @@ -47,7 +44,10 @@ Issues = "https://github.com/Grub4K/vrcar/issues"
Source = "https://github.com/Grub4K/vrcar"

[tool.hatch.version]
path = "vrcar/__init__.py"
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "vrcar/_version.py"

[tool.hatch.envs.default]
path = ".venv"
Expand All @@ -62,18 +62,6 @@ init = "pre-commit install -c pre-commit.yml"
deinit = "pre-commit uninstall"
vrcar = "python -m vrcar {args}"

[tool.hatch.envs.testing]
installer = "uv"
features = ["testing"]

[tool.hatch.envs.testing.scripts]
testing = "python -m vrcar.client.provider.testing"

[tool.hatch.envs.server]
detached = true
installer = "uv"
features = ["server"]

[tool.hatch.envs.hatch-static-analysis]
dependencies = ["ruff==0.4.*"]
config-path = "pyproject.toml"
Expand Down
5 changes: 3 additions & 2 deletions vrcar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

__version__ = "0.1.0"
version_tuple = tuple(map(int, __version__.split(".")))
from vrcar._version import __version__, __version_tuple__

__all__ = ["__version__", "__version_tuple__"]
7 changes: 7 additions & 0 deletions vrcar/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ def parse_args():


def main():
import logging

import vrcar
import vrcar.log

logger = logging.getLogger(vrcar.__name__)

vrcar.log.setup(name_length=30, debug=True)
logger.info(f"{vrcar.__name__} v{vrcar.__version__}")

args = parse_args()

if args.mode == "server":
Expand Down
Empty file removed vrcar/client/provider/__init__.py
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import importlib.resources
import importlib.util
import logging
import threading
Expand All @@ -23,6 +24,7 @@
import io

logger = logging.getLogger(__name__)
resources = importlib.resources.files()


class OpenXRProvider:
Expand All @@ -36,8 +38,8 @@ def __init__(self):
self._context = xr.ContextObject(
instance_create_info=xr.InstanceCreateInfo(
application_info=xr.ApplicationInfo(
application_name="vrcar",
application_version=xr.Version(*vrcar.version_tuple),
application_name=vrcar.__name__,
application_version=xr.Version(*vrcar.__version_tuple__),
),
enabled_extension_names=[
xr.KHR_OPENGL_ENABLE_EXTENSION_NAME,
Expand All @@ -59,11 +61,8 @@ def __enter__(self):

self._texture = GL.glGenTextures(1)

with open("shader/plane.vert") as file:
vertex_shader_data = file.read()

with open("shader/plane.frag") as file:
fragment_shader_data = file.read()
vertex_shader_data = resources.joinpath("plane.vert").read_text()
fragment_shader_data = resources.joinpath("plane.frag").read_text()

try:
vertex_shader = shaders.compileShader(
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions vrcar/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@

class PrettyFormatter(logging.Formatter):
LOG_FORMAT = (
"{record.asctime}"
"{record.asctime}.{record.msecs:03}"
" | {record.levelname:<8}"
" | {record.name:<{name_length}}"
" | {record.message}"
)
LOG_FORMAT_COLOR = (
"\x1b[30;1m{record.asctime}\x1b[0m"
"\x1b[32;1m{record.asctime}.{record.msecs:03}\x1b[0m"
" | {level_color}{record.levelname:<8}\x1b[0m"
" | \x1b[35m{record.name:<{name_length}}\x1b[0m"
" | {record.message}"
)
EXC_FORMAT = "{record.exc_text}"
EXC_FORMAT_COLOR = "\x1b[31m{record.exc_text}\x1b[0m"
LEVEL_COLORS: Mapping[int, str] = {
logging.DEBUG: "\x1b[96;1m",
logging.DEBUG: "\x1b[36;1m",
logging.INFO: "\x1b[34;1m",
logging.WARNING: "\x1b[33;1m",
logging.ERROR: "\x1b[31m",
logging.CRITICAL: "\x1b[41m",
logging.ERROR: "\x1b[31m;1",
logging.CRITICAL: "\x1b[41m;1",
}

def __init__(
Expand All @@ -41,7 +41,7 @@ def __init__(
self._exc_format = self.EXC_FORMAT_COLOR if use_color else self.EXC_FORMAT
# HACK: preformat name length so we don't have to store it for later
self._log_format = self._log_format.replace("{name_length}", str(name_length))
super().__init__(self._log_format, style="{")
super().__init__(self._log_format, style="{", datefmt="%Y-%m-%d %H:%M:%s")

def format(self, /, record: logging.LogRecord) -> str:
record.asctime = self.formatTime(record, self.datefmt)
Expand Down

0 comments on commit e73b0c1

Please sign in to comment.