Giter Club home page Giter Club logo

Comments (7)

florianfesti avatar florianfesti commented on May 26, 2024

The xgettext and msgfmt shipped with your Python version are kinda weird. They seem to be implemented in Python, while they are binary programs here on Linux.

While

boxes/setup.py

Line 20 in 494e445

os.system("{} {}".format("xgettext -L Python -j --from-code=utf-8 -o po/boxes.py.pot", "boxes/*.py scripts/boxesserver scripts/boxes"))

creates warnings about not supported parameters the actual error comes from

boxes/setup.py

Line 31 in 494e445

os.system(f"msgfmt {po} -o locale/{lang}/LC_MESSAGES/boxes.py.mo")

May be you are missing a native gettext implementation that was used previously. Or it is no longer found earlier in the path.

from boxes.

vmario89 avatar vmario89 commented on May 26, 2024

Hi Florian. Thank you for looking into it.

Indeed i just missed to install https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.21-v1.16/gettext0.21-iconv1.16-static-64.exe. but it continues with another issue now:

Building wheels for collected packages: boxes
  Building wheel for boxes (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      running bdist_wheel
      running build
      running build_py
      updatePOT()
      xgettext: Öffnen der Datei »boxes/*.py« zum Lesen fehlgeschlagen: Invalid argument
      generate_mo_files()
      buildInkscapeExt()
      error: [WinError 2] Das System kann die angegebene Datei nicht finden
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for boxes
  Running setup.py clean for boxes
Failed to build boxes
ERROR: Could not build wheels for boxes, which is required to install pyproject.toml-based projects

i checked my really old legacy documentation but it seems to be an issue which already exists for years, as i had the same problem in 2019 or so.

The following procedure will make boxes.py work or install and therefore run on cli or inkscape, but we have to do a lot of manual steps. What works:

git clone https://github.com/florianfesti/boxes.git boxes

cd boxes
 
#fix PO/MO translations manually by running the following commands:
xgettext -L Python -j --from-code=UTF-8 -o po/boxes.py.pot C:\boxes\po\boxes.py.pot -D C:\boxes\boxes
xgettext -L Python -j --from-code=UTF-8 -o po/boxes.py.pot C:\boxes\po\boxes.py.pot -D C:\boxes\boxes\generators
xgettext -L Python -j --from-code=UTF-8 -o po/boxes.py.pot C:\boxes\po\boxes.py.pot -D C:\boxes\scripts\boxesserver
xgettext -L Python -j --from-code=UTF-8 -o po/boxes.py.pot C:\boxes\po\boxes.py.pot -D C:\boxes\scripts\boxes
  
#returns errors like above - ignore that
python.exe setup.py build
 
#returns errors - ignore
python.exe setup.py install

The best for regular users will be to install boxes.py directly with pip install git+<mirror> and thats it.

btw. on the website documentation the qrcode lib is not mentioned -> https://florianfesti.github.io/boxes/html/install.html

from boxes.

vmario89 avatar vmario89 commented on May 26, 2024

xgettext: Öffnen der Datei »boxes/*.py« zum Lesen fehlgeschlagen: Invalid argument gets definetely produced by the wildcard character. i not am successfull running xgettext -L Python -j --from-code=utf-8 -o po/boxes.py.pot boxes/*.py scripts/boxesserver scripts/boxes on Windows cmd shell manually. I already tried to switch or escape that stuff. Maybe xgettext on Windows is not capable handling this ...

from boxes.

vmario89 avatar vmario89 commented on May 26, 2024

the following seems to work on Widows:

dir /s /b /o:gn boxes\*.py > PYFILES
xgettext -L Python -j --from-code=utf-8 -o po/boxes.py.pot -n --files-from=PYFILES scripts/boxesserver scripts/boxes

from boxes.

vmario89 avatar vmario89 commented on May 26, 2024

The error: [WinError 2] Das System kann die angegebene Datei nicht finden comes from inkscape not being on %PATH%

from boxes.

vmario89 avatar vmario89 commented on May 26, 2024

The WinError can be ommited adding a path check using shutil -> if shutil.which("inkscape") is not None::

#!/usr/bin/env python3

import glob
import os
import sys
import shutil
from subprocess import CalledProcessError, check_output
from setuptools import find_packages, setup
from setuptools.command.build_py import build_py


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

    def buildInkscapeExt(self):
        os.system("{} {} {}".format(sys.executable, os.path.join("scripts", "boxes2inkscape"), "inkex"))

    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 -n --files-from=PYFILES", "scripts/boxesserver scripts/boxes"))

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

        for po in pos:
            lang = po.split(os.sep)[1][:-3].replace("-", "_")
            try:
                os.makedirs(os.path.join("locale", lang, "LC_MESSAGES"))
            except FileExistsError:
                pass
            os.system(f"msgfmt {po} -o locale/{lang}/LC_MESSAGES/boxes.py.mo")
            self.distribution.data_files.append(
                (os.path.join("share", "locale", lang, "LC_MESSAGES"),
                 [os.path.join("locale", lang, "LC_MESSAGES", "boxes.py.mo")]))

    def run(self):
        if self.distribution.data_files is None:
            self.distribution.data_files = []
        self.execute(self.updatePOT, ())
        self.execute(self.generate_mo_files, ())
        self.execute(self.buildInkscapeExt, ())

        if 'CURRENTLY_PACKAGING' in os.environ:
            # we are most probably building a Debian package
            # let us define a simple path!
            path="/usr/share/inkscape/extensions"
            self.distribution.data_files.append((path, [i for i in glob.glob(os.path.join("inkex", "*.inx"))]))
            self.distribution.data_files.append((path, ['scripts/boxes']))
            self.distribution.data_files.append((path, ['scripts/boxes_proxy.py']))
        else:
            # we are surely not building a Debian package
            # then here is the default behavior:
            try:
                if shutil.which("inkscape") is not None:
                    path = check_output(["inkscape", "--system-data-directory"]).decode().strip()
                    path = os.path.join(path, "extensions")
                    if not os.access(path, os.W_OK): # Can we install globally
                        # Not tested on Windows and Mac
                        path = os.path.expanduser("~/.config/inkscape/extensions")
                    print("5")
                    self.distribution.data_files.append((path, [i for i in glob.glob(os.path.join("inkex", "*.inx"))]))
                    self.distribution.data_files.append((path, ['scripts/boxes']))
                    self.distribution.data_files.append((path, ['scripts/boxes_proxy.py']))
            except CalledProcessError:
                pass # Inkscape is not installed

        build_py.run(self)


setup(
    name='boxes',
    version='0.9',
    description='Boxes generator for laser cutters',
    author='Florian Festi',
    author_email='[email protected]',
    url='https://github.com/florianfesti/boxes',
    packages=find_packages(),
    python_requires='>=3.8',
    install_requires=['affine>=2.0', 'markdown', 'shapely>=1.8.2', 'qrcode>=7.3.1'],
    scripts=['scripts/boxes', 'scripts/boxesserver'],
    cmdclass={
        'build_py': CustomBuildExtCommand,
    },
    classifiers=[ # https://pypi.python.org/pypi?%3Aaction=list_classifiers
        "Development Status :: 5 - Production/Stable",
        "Environment :: Console",
        "Environment :: Web Environment",
        "Intended Audience :: Manufacturing",
        "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
        "Programming Language :: Python :: 3",
        "Topic :: Multimedia :: Graphics :: Editors :: Vector-Based",
        "Topic :: Scientific/Engineering",
    ],
    keywords=["boxes", "box", "generator", "svg", "laser cutter"], )

from boxes.

florianfesti avatar florianfesti commented on May 26, 2024

Ok, fixed this slightly differently. The try except block was supposed to already catch this kind of failure but didn't.

I hope this allows you to get this finally built. Thanks for the thorough analysis!

from boxes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.