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

Update Django and Python #575

Merged
merged 11 commits into from
Oct 26, 2024
1 change: 0 additions & 1 deletion .envs/.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ AWS_SECRET_ACCESS_KEY=minio123
MINIO_ROOT_USER=minio
MINIO_ROOT_PASSWORD=minio123
AWS_STORAGE_BUCKET_NAME=jandig-cdn
AWS_PRIVATE_STORAGE_BUCKET_NAME=jandig-private-cdn
AWS_S3_REGION_NAME=us-east-2
AWS_STATIC_LOCATION=static
MINIO_S3_ENDPOINT_URL=http://storage:9000
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.13
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.13"
- name: Installing flake8
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
run: |
cp .envs/.example .envs/.env
docker load -i docker_image_$GITHUB_SHA
docker-compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
docker compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
- name: Test migrations
run: |
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\
Expand All @@ -81,7 +81,7 @@ jobs:
run: |
cp .envs/.example .envs/.env
docker load -i docker_image_$GITHUB_SHA
docker-compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
docker compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
- name: Running users tests
run: |
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Docker pipeline
on:
push:
branches:
- develop
- master

# TODO: Change environment and login envs
jobs:
Expand Down
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM python:3.10-slim-bullseye

FROM python:3.13.0-slim-bookworm

RUN apt-get update && \
apt-get install -y --no-install-recommends \
gettext \
docutils-common \
curl \
pipx \
wget

COPY ./pyproject.toml /pyproject.toml
Expand All @@ -16,16 +18,15 @@ ENV PATH="$PATH:/root/.local/bin" \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
TINI_VERSION=v0.19.0 \
# poetry:
POETRY_VERSION=1.3.1
POETRY_VERSION=1.8.4

# Installing `poetry` package manager:
# https://github.com/python-poetry/poetry
RUN curl -sSL https://install.python-poetry.org | python3 - \
&& poetry --version

RUN pip install --upgrade pip
RUN pipx install --python python3 poetry==${POETRY_VERSION}
RUN poetry install


RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${dpkgArch}" -O /usr/local/bin/tini \
&& chmod +x /usr/local/bin/tini && tini --version
Expand Down
1 change: 0 additions & 1 deletion docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ services:
until (/usr/bin/mc config host add myminio $${MINIO_S3_ENDPOINT_URL} $${MINIO_ROOT_USER} $${MINIO_ROOT_PASSWORD}) do echo '...waiting...' && sleep 1; done;
/usr/bin/mc mb myminio/$${AWS_STORAGE_BUCKET_NAME};
/usr/bin/mc policy set download myminio/$${AWS_STORAGE_BUCKET_NAME};
/usr/bin/mc mb myminio/$${AWS_PRIVATE_STORAGE_BUCKET_NAME};
/usr/bin/mc admin user add myminio $${MINIO_USER_ACCESS_KEY} $${MINIO_USER_SECRET_KEY};
/usr/bin/mc admin policy set myminio readwrite user=$${MINIO_USER_ACCESS_KEY};
exit 0;
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
- ./locale/:/jandig/locale/
- ./run.sh:/jandig/run.sh
- ./tasks.py:/jandig/tasks.py
- ./poetry.lock:/poetry.lock
- ./pyproject.toml:/pyproject.toml
env_file:
- .envs/.example
depends_on:
Expand Down Expand Up @@ -65,7 +67,6 @@ services:
until (/usr/bin/mc config host add myminio $${MINIO_S3_ENDPOINT_URL} $${MINIO_ROOT_USER} $${MINIO_ROOT_PASSWORD}) do echo '...waiting...' && sleep 1; done;
/usr/bin/mc mb myminio/$${AWS_STORAGE_BUCKET_NAME};
/usr/bin/mc policy set download myminio/$${AWS_STORAGE_BUCKET_NAME};
/usr/bin/mc mb myminio/$${AWS_PRIVATE_STORAGE_BUCKET_NAME};
/usr/bin/mc admin user add myminio $${MINIO_USER_ACCESS_KEY} $${MINIO_USER_SECRET_KEY};
/usr/bin/mc admin policy set myminio readwrite user=$${MINIO_USER_ACCESS_KEY};
exit 0;
Expand Down
42 changes: 21 additions & 21 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,27 @@

# -- Project information -----------------------------------------------------

project = 'Jandig ARte Help'
copyright = '2019, pablodiegoss, rodrigocam, vjpixel, hvalois'
author = 'pablodiegoss, rodrigocam, vjpixel, hvalois'
project = "Jandig ARte Help"
copyright = "2019, pablodiegoss, rodrigocam, vjpixel, hvalois"
author = "pablodiegoss, rodrigocam, vjpixel, hvalois"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
extensions = []

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'pt_BR'
language = "pt_BR"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -51,28 +50,29 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

html_theme_options = {
'logo': 'logo.png',
'github_user': 'memeLab',
'github_repo': 'Jandig',
'html_sidebars': {
'**': [
'search.html',
'navigation.html',
]
"logo": "logo.png",
"github_user": "memeLab",
"github_repo": "Jandig",
"html_sidebars": {
"**": [
"search.html",
"navigation.html",
]
},
'extra_nav_links': {
'Official Site': 'https://jandig.app',
'Github': 'https://github.com/memelab/Jandig'
"extra_nav_links": {
"Official Site": "https://jandig.app",
"Github": "https://github.com/memelab/Jandig",
},
}


def setup(app):
app.add_css_file('reset.css')
app.add_css_file("reset.css")
30 changes: 15 additions & 15 deletions etc/scripts/compilemessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import glob
import os
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen

program = 'msgfmt'
program_options = ['--check-format', '-f']
program = "msgfmt"
program_options = ["--check-format", "-f"]


def main():
Expand All @@ -14,26 +14,26 @@ def main():
django.core.management.commands.compilemessages
"""
# Walk entire tree, looking for locale directories
basedirs = ['locale']
for dirpath, dirnames, filenames in os.walk('.', topdown=True):
basedirs = ["locale"]
for dirpath, dirnames, filenames in os.walk(".", topdown=True):
for dirname in dirnames:
if dirname == 'locale':
if dirname == "locale":
basedirs.append(os.path.join(dirpath, dirname))
basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs)))

# Build locale list
all_locales = []
for basedir in basedirs:
locale_dirs = filter(os.path.isdir, glob.glob(f'{basedir}/*'))
locale_dirs = filter(os.path.isdir, glob.glob(f"{basedir}/*"))
all_locales.extend(map(os.path.basename, locale_dirs))
locales = set(all_locales)

for basedir in basedirs:
dirs = [os.path.join(basedir, locale, 'LC_MESSAGES') for locale in locales]
dirs = [os.path.join(basedir, locale, "LC_MESSAGES") for locale in locales]
locations = []
for ldir in dirs:
for dirpath, dirnames, filenames in os.walk(ldir):
locations.extend((dirpath, f) for f in filenames if f.endswith('.po'))
locations.extend((dirpath, f) for f in filenames if f.endswith(".po"))
compile_messages(locations)


Expand All @@ -42,21 +42,21 @@ def compile_messages(locations):
Locations is a list of tuples: [(directory, file), ...]
"""
for _, (dirpath, f) in enumerate(locations):
print(f'processing file {f} in {dirpath}\n')
print(f"processing file {f} in {dirpath}\n")

# Program args
po_path = os.path.join(dirpath, f)
base_path = os.path.splitext(po_path)[0]
extra_args = ['-o', base_path + '.mo', base_path + '.po']
extra_args = ["-o", base_path + ".mo", base_path + ".po"]
args = [program] + program_options + extra_args

# Execute command
__, errors, status = popen_wrapper(args)
if status:
if errors:
msg = f'Execution of {program} failed: {errors}'
msg = f"Execution of {program} failed: {errors}"
else:
msg = f'Execution of {program} failed'
msg = f"Execution of {program} failed"
raise RuntimeError(msg)


Expand All @@ -68,8 +68,8 @@ def popen_wrapper(args, os_err_exc_type=RuntimeError):
with Popen(args, shell=False, stdout=PIPE, stderr=PIPE, close_fds=True) as p:
output, errors = p.communicate()
return output, errors, p.returncode
raise os_err_exc_type('Error executing')
raise os_err_exc_type("Error executing")


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading
Loading