Skip to content

Commit

Permalink
feat(setup): modernize script execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotzbua committed Jul 24, 2024
1 parent 2eac7b0 commit efa6370
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import glob
import os
import subprocess
import sys
from pathlib import Path
from subprocess import CalledProcessError, check_output

from setuptools import find_packages, setup
Expand All @@ -11,13 +13,22 @@

class CustomBuildExtCommand(build_py):
"""Customized setuptools install command - prints a friendly greeting."""
script_path: Path = Path("scripts")

def buildInkscapeExt(self):
os.system("{} {} {}".format(sys.executable, os.path.join("scripts", "boxes2inkscape"), "inkex"))
def buildInkscapeExt(self) -> None:
try:
subprocess.run([sys.executable, str(self.script_path / "boxes2inkscape"), "inkex"], check=True, capture_output=True, text=True)
except CalledProcessError as e:
print("Could not build inkscape extension because of error: ", e)
print("Output: ", e.output)

def updatePOT(self):
os.system("{} {} {}".format(sys.executable, os.path.join("scripts", "boxes2pot"), "po/boxes.py.pot"))
os.system("{} {}".format("xgettext -L Python -j --from-code=utf-8 -o po/boxes.py.pot", "boxes/*.py scripts/boxesserver scripts/boxes"))
def updatePOT(self) -> None:
try:
subprocess.run([sys.executable, str(self.script_path / "boxes2pot"), "po/boxes.py.pot"], check=True, capture_output=True, text=True)
subprocess.run(["xgettext -L Python -j --from-code=utf-8 -o po/boxes.py.pot", "boxes/*.py scripts/boxesserver scripts/boxes"], shell=True, check=True, capture_output=True, text=True)
except CalledProcessError as e:
print("Could not process translation because of error: ", e)
print("Output: ", e.output)

def generate_mo_files(self):
pos = glob.glob("po/*.po")
Expand Down

0 comments on commit efa6370

Please sign in to comment.