Skip to content
This repository was archived by the owner on Oct 13, 2024. It is now read-only.

Commit 3c242bf

Browse files
refactor: restructure source code
1 parent 6d5e727 commit 3c242bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+785
-442
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ jobs:
5151
- name: Checkout
5252
uses: actions/checkout@v4
5353

54-
- name: Install Python 3.9
54+
- name: Setup Python
5555
uses: actions/setup-python@v5
5656
with:
57-
python-version: '3.9'
57+
python-version: '3.12'
5858
architecture: ${{ matrix.architecture }}
5959

60-
- name: Set up Python Dependencies
60+
- name: Setup Python Dependencies
6161
run: |
62-
python -m pip install --upgrade pip setuptools
63-
python -m pip install -r requirements-dev.txt --no-warn-script-location
62+
python -m pip install --upgrade pip setuptools wheel
63+
python -m pip install -r requirements-dev.txt
6464
6565
- name: Compile Locale Translations
6666
run: |
@@ -108,7 +108,7 @@ jobs:
108108
--tb=native \
109109
--verbose \
110110
--color=yes \
111-
--cov=pyra \
111+
--cov=src \
112112
tests
113113
114114
- name: Upload coverage

.github/workflows/localize.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ on:
66
branches: [master]
77
paths: # prevents workflow from running unless these files change
88
- '.github/workflows/localize.yml'
9-
- 'retroarcher.py'
109
- 'locale/retroarcher.po'
11-
- 'pyra/**.py'
10+
- 'src/**.py'
1211
- 'web/templates/**'
1312
workflow_dispatch:
1413

@@ -21,14 +20,14 @@ jobs:
2120
- name: Checkout
2221
uses: actions/checkout@v4
2322

24-
- name: Install Python 3.9
23+
- name: Install Python
2524
uses: actions/setup-python@v5 # https://github.com/actions/setup-python
2625
with:
27-
python-version: '3.9'
26+
python-version: '3.12'
2827

29-
- name: Set up Python 3.9 Dependencies
28+
- name: Setup Python Dependencies
3029
run: |
31-
python -m pip install --upgrade pip setuptools
30+
python -m pip install --upgrade pip setuptools wheel
3231
python -m pip install -r requirements.txt
3332
3433
- name: Update Strings

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,5 @@ cython_debug/
155155
node_modules/
156156
*package-lock.json
157157

158-
# RetroArcher directories
159-
logs/
160-
161-
# RetroArcher files
162-
*config.ini
158+
# project files and directories
159+
config/

.readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ version: 2
88

99
# Set the version of Python
1010
build:
11-
os: ubuntu-20.04
11+
os: ubuntu-22.04
1212
tools:
13-
python: "3.9"
13+
python: "3.12"
1414
jobs:
1515
pre_build:
1616
- python ./scripts/_locale.py --compile

DOCKER_README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
### lizardbyte/retroarcher
1+
# Docker
22

3-
#### Using docker run
3+
## lizardbyte/retroarcher
4+
5+
### Using docker run
46
Create and run the container (substitute your `<values>`):
57

68
```bash
@@ -28,7 +30,7 @@ docker pull lizardbyte/retroarcher
2830
docker run -d ...
2931
```
3032

31-
#### Using docker-compose
33+
### Using docker-compose
3234

3335
Create a `docker-compose.yml` file with the following contents (substitute your `<values>`):
3436

@@ -63,7 +65,7 @@ docker-compose pull
6365
docker-compose up -d
6466
```
6567

66-
#### Parameters
68+
### Parameters
6769
You must substitute the `<values>` with your own settings.
6870

6971
Parameters are split into two halves separated by a colon. The left side represents the host and the right side the
@@ -83,7 +85,7 @@ Therefore `-p 9696:9696` would expose port `9696` from inside the container to b
8385
| `-e PGID=<gid>` | Group ID | `1001` | False |
8486
| `-e TZ=<timezone>` | Lookup TZ value [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | `America/New_York` | True |
8587

86-
#### User / Group Identifiers:
88+
### User / Group Identifiers:
8789

8890
When using data volumes (-v flags) permissions issues can arise between the host OS and the container. To avoid this
8991
issue you can specify the user PUID and group PGID. Ensure the data volume directory on the host is owned by the same

Dockerfile

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
# artifacts: false
2-
# platforms: linux/386,linux/amd64
3-
FROM python:3.9.6-slim-bullseye as retroarcher-base
2+
# platforms: linux/amd64,linux/arm64/v8
3+
FROM python:3.12-slim-bookworm AS base
44

5-
FROM retroarcher-base as retroarcher-build
5+
FROM base AS build
6+
7+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
68

79
# install build dependencies
8-
RUN apt-get update -y \
9-
&& apt-get install -y --no-install-recommends \
10-
build-essential \
11-
nodejs \
12-
npm \
13-
pkg-config \
14-
libopenblas-dev \
15-
&& apt-get clean \
16-
&& rm -rf /var/lib/apt/lists/*
10+
RUN <<_DEPS
11+
#!/bin/bash
12+
set -e
13+
14+
dependencies=(
15+
"build-essential"
16+
"libjpeg-dev" # pillow
17+
"npm" # web dependencies
18+
"pkg-config"
19+
"libopenblas-dev"
20+
"zlib1g-dev" # pillow
21+
)
22+
apt-get update -y
23+
apt-get install -y --no-install-recommends "${dependencies[@]}"
24+
apt-get clean
25+
rm -rf /var/lib/apt/lists/*
26+
_DEPS
1727

1828
# python virtualenv
1929
RUN python -m venv /opt/venv
@@ -25,44 +35,72 @@ WORKDIR /build
2535
COPY . .
2636

2737
# setup python requirements
28-
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel && \
29-
python -m pip install --no-cache-dir -r requirements.txt
38+
RUN <<_REQUIREMENTS
39+
#!/bin/bash
40+
set -e
41+
python -m pip install --no-cache-dir --upgrade pip setuptools wheel
42+
python -m pip install --no-cache-dir -r requirements.txt
43+
_REQUIREMENTS
3044

3145
# compile locales
3246
RUN python scripts/_locale.py --compile
3347

3448
# setup npm and dependencies
35-
RUN npm install && \
36-
mv -f ./node_modules/ ./web/
49+
RUN <<_NPM
50+
#!/bin/bash
51+
set -e
52+
npm install
53+
mv -f ./node_modules/ ./web/
54+
_NPM
3755

3856
# compile docs
3957
WORKDIR /build/docs
4058
RUN sphinx-build -M html source build
4159

42-
FROM retroarcher-base as retroarcher
60+
FROM base AS app
4361

4462
# copy app from builder
45-
COPY --from=retroarcher-build /build/ /app/
63+
COPY --from=build /build/ /app/
4664

4765
# copy python venv
48-
COPY --from=retroarcher-build /opt/venv/ /opt/venv/
66+
COPY --from=build /opt/venv/ /opt/venv/
4967
# use the venv
5068
ENV PATH="/opt/venv/bin:$PATH"
5169
# site-packages are in /opt/venv/lib/python<version>/site-packages/
5270

5371
# setup remaining env variables
5472
ENV RETROARCHER_DOCKER=True
55-
ENV TZ=UTC
73+
74+
# network setup
75+
EXPOSE 9696
5676

5777
# setup user
58-
RUN groupadd -g 1000 retroarcher && \
59-
useradd -u 1000 -g 1000 retroarcher
78+
ARG PGID=1000
79+
ENV PGID=${PGID}
80+
ARG PUID=1000
81+
ENV PUID=${PUID}
82+
ENV TZ="UTC"
83+
ARG UNAME=lizard
84+
ENV UNAME=${UNAME}
6085

61-
# create config directory
62-
RUN mkdir -p /config
86+
ENV HOME=/home/$UNAME
87+
88+
# setup user
89+
RUN <<_SETUP_USER
90+
#!/bin/bash
91+
set -e
92+
groupadd -f -g "${PGID}" "${UNAME}"
93+
useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}"
94+
mkdir -p ${HOME}/.config/retroarcher
95+
ln -s ${HOME}/.config/retroarcher /config
96+
chown -R ${UNAME} ${HOME}
97+
_SETUP_USER
98+
99+
# mounts
63100
VOLUME /config
64101

65-
CMD ["python", "retroarcher.py"]
102+
USER ${UNAME}
103+
WORKDIR ${HOME}
66104

67-
EXPOSE 9696
68-
HEALTHCHECK --start-period=90s CMD python retroarcher.py --docker_healthcheck || exit 1
105+
ENTRYPOINT ["python", "./src/retroarcher.py"]
106+
HEALTHCHECK --start-period=90s CMD python ./src/retroarcher.py --docker_healthcheck || exit 1

crowdin.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"base_path": "."
33
"base_url": "https://api.crowdin.com" # optional (for Crowdin Enterprise only)
44
"preserve_hierarchy": false # flatten tree on crowdin
5+
"pull_request_title": "chore(l10n): update translations"
56
"pull_request_labels": [
67
"crowdin",
78
"l10n"

docs/source/about/docker.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
Docker
2-
------
3-
4-
.. mdinclude:: ../../../DOCKER_README.md
1+
.. include:: ../../../DOCKER_README.md
2+
:parser: myst_parser.docutils_

docs/source/conf.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@
66

77
# standard imports
88
from datetime import datetime
9+
import os
10+
import sys
911

1012

1113
# -- Path setup --------------------------------------------------------------
1214

1315
# If extensions (or modules to document with autodoc) are in another directory,
1416
# add these directories to sys.path here. If the directory is relative to the
1517
# documentation root, use os.path.abspath to make it absolute, like shown here.
16-
import os
17-
import sys
1818

1919
script_dir = os.path.dirname(os.path.abspath(__file__)) # the directory of this file
2020
source_dir = os.path.dirname(script_dir) # the source folder directory
2121
root_dir = os.path.dirname(source_dir) # the root folder directory
22+
src_dir = os.path.join(root_dir, 'src') # the src folder directory
2223

2324
try:
24-
sys.path.insert(0, root_dir)
25-
from pyra import definitions # put this in a try/except to prevent flake8 warning
26-
except Exception:
25+
sys.path.insert(0, src_dir)
26+
from common import definitions # put this in a try/except to prevent flake8 warning
27+
except Exception as e:
28+
print(f"Unable to import definitions from {root_dir}: {e}")
2729
sys.exit(1)
2830

2931
# -- Project information -----------------------------------------------------
@@ -42,10 +44,11 @@
4244
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4345
# ones.
4446
extensions = [
45-
'm2r2', # enable markdown files
47+
'myst_parser', # enable markdown files
4648
'numpydoc', # this automatically loads `sphinx.ext.autosummary` as well
4749
'sphinx.ext.autodoc', # autodocument modules
4850
'sphinx.ext.autosectionlabel',
51+
'sphinx.ext.intersphinx', # link to other projects' documentation
4952
'sphinx.ext.todo', # enable to-do sections
5053
'sphinx.ext.viewcode' # add links to view source code
5154
]
@@ -59,13 +62,16 @@
5962
exclude_patterns = ['toc.rst']
6063

6164
# Extensions to include.
62-
source_suffix = ['.rst', '.md']
65+
source_suffix = {
66+
'.rst': 'restructuredtext',
67+
'.md': 'markdown',
68+
}
6369

6470

6571
# -- Options for HTML output -------------------------------------------------
6672

6773
# images
68-
html_favicon = os.path.join(definitions.Paths().ROOT_DIR, 'web', 'images', 'retroarcher.ico')
74+
html_favicon = os.path.join(definitions.Paths().ROOT_DIR, 'web', 'images', 'favicon.ico')
6975
html_logo = os.path.join(definitions.Paths().ROOT_DIR, 'web', 'images', 'logo-circle.png')
7076

7177
# Add any paths that contain custom static files (such as style sheets) here,
@@ -102,3 +108,13 @@
102108
# disable epub mimetype warnings
103109
# https://github.com/readthedocs/readthedocs.org/blob/eadf6ac6dc6abc760a91e1cb147cc3c5f37d1ea8/docs/conf.py#L235-L236
104110
suppress_warnings = ["epub.unknown_project_files"]
111+
112+
python_version = f'{sys.version_info.major}.{sys.version_info.minor}'
113+
114+
intersphinx_mapping = {
115+
'python': ('https://docs.python.org/{}/'.format(python_version), None),
116+
}
117+
118+
numpydoc_show_class_members = True
119+
numpydoc_show_inherited_class_members = False
120+
numpydoc_xref_param_type = True

docs/source/contributing/localization.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Localization
22
============
33
RetroArcher is being localized into various languages. The default language is `en` (English).
44

5-
.. image:: https://app.lizardbyte.dev/uno/crowdin/LizardByte_graph.svg
5+
.. image:: https://app.lizardbyte.dev/dashboard/crowdin/LizardByte_graph.svg
66

77
CrowdIn
88
-------
@@ -43,7 +43,7 @@ situations. For example the system tray icon is user interfacing and therefore s
4343
- In order for strings to be extracted from python code, the following lines must be added.
4444
.. code-block:: python
4545
46-
from pyra import locales
46+
from common import locales
4747
_ = locales.get_text()
4848
4949
- Wrap the string to be extracted in a function as shown.
@@ -76,8 +76,7 @@ any of the following paths are modified.
7676

7777
.. code-block:: yaml
7878
79-
- 'retroarcher.py'
80-
- 'pyra/**.py'
79+
- 'src/**.py'
8180
- 'web/templates/**'
8281
8382
When testing locally it may be desirable to manually extract, initialize, update, and compile strings.

docs/source/pyra_docs/config.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/hardware.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/source/pyra_docs/helpers.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)