2016-07-11 23:01:57 +02:00
|
|
|
#!/usr/bin/env python3
|
2016-03-26 11:12:14 +01:00
|
|
|
|
2017-05-05 07:59:50 +02:00
|
|
|
import glob
|
|
|
|
import os
|
2018-04-15 11:51:49 +02:00
|
|
|
import sys
|
2018-10-27 19:03:09 +02:00
|
|
|
from subprocess import check_output, CalledProcessError
|
2016-03-26 11:12:14 +01:00
|
|
|
from setuptools import setup, find_packages
|
2017-02-25 20:01:03 +01:00
|
|
|
from setuptools.command.build_py import build_py
|
2017-05-05 07:59:50 +02:00
|
|
|
|
2017-02-25 20:01:03 +01:00
|
|
|
|
|
|
|
class CustomBuildExtCommand(build_py):
|
|
|
|
"""Customized setuptools install command - prints a friendly greeting."""
|
|
|
|
|
|
|
|
def buildInkscapeExt(self):
|
2018-04-15 11:51:49 +02:00
|
|
|
os.system("%s %s %s" % (sys.executable,
|
|
|
|
os.path.join("scripts", "boxes2inkscape"),
|
|
|
|
"inkex"))
|
2017-02-25 20:01:03 +01:00
|
|
|
|
2019-04-21 10:57:04 +02:00
|
|
|
def updatePOT(self):
|
|
|
|
os.system("%s %s %s" % (
|
|
|
|
sys.executable,
|
|
|
|
os.path.join("scripts", "boxes2pot"),
|
|
|
|
"po/boxes.py.pot"))
|
|
|
|
os.system("%s %s" % (
|
2022-05-14 16:10:30 +02:00
|
|
|
"xgettext -L Python -j --from-code=utf-8 -o po/boxes.py.pot",
|
2019-04-21 10:57:04 +02:00
|
|
|
"boxes/*.py scripts/boxesserver scripts/boxes"))
|
|
|
|
|
2019-04-22 21:54:55 +02:00
|
|
|
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("msgfmt %s -o locale/%s/LC_MESSAGES/boxes.py.mo" % (po, lang))
|
|
|
|
self.distribution.data_files.append(
|
2019-09-01 02:26:54 +02:00
|
|
|
(os.path.join("share", "locale", lang, "LC_MESSAGES"),
|
|
|
|
[os.path.join("locale", lang, "LC_MESSAGES", "boxes.py.mo")]))
|
2019-04-22 21:54:55 +02:00
|
|
|
|
2017-02-25 20:01:03 +01:00
|
|
|
def run(self):
|
2019-04-22 21:54:55 +02:00
|
|
|
if self.distribution.data_files is None:
|
|
|
|
self.distribution.data_files = []
|
2019-04-21 10:57:04 +02:00
|
|
|
self.execute(self.updatePOT, ())
|
2019-04-22 21:54:55 +02:00
|
|
|
self.execute(self.generate_mo_files, ())
|
2017-02-25 20:01:03 +01:00
|
|
|
self.execute(self.buildInkscapeExt, ())
|
2019-10-31 15:05:10 +01:00
|
|
|
|
2019-11-01 10:58:17 +01:00
|
|
|
if 'CURRENTLY_PACKAGING' in os.environ:
|
|
|
|
# we are most probably building a Debian package
|
2019-10-31 15:05:10 +01:00
|
|
|
# let us define a simple path!
|
|
|
|
path="/usr/share/inkscape/extensions"
|
2017-02-25 20:01:03 +01:00
|
|
|
self.distribution.data_files.append(
|
2018-07-24 20:38:34 +02:00
|
|
|
(path,
|
2017-05-05 07:59:50 +02:00
|
|
|
[i for i in glob.glob(os.path.join("inkex", "*.inx"))]))
|
2018-08-22 17:59:18 +02:00
|
|
|
self.distribution.data_files.append((path, ['scripts/boxes']))
|
2023-02-10 20:34:25 +01:00
|
|
|
self.distribution.data_files.append((path, ['scripts/boxes_proxy.py']))
|
2019-10-31 15:05:10 +01:00
|
|
|
else:
|
|
|
|
# we are surely not building a Debian package
|
|
|
|
# then here is the default behavior:
|
|
|
|
try:
|
2021-04-20 22:32:37 +02:00
|
|
|
path = check_output(["inkscape", "--system-data-directory"]).decode().strip()
|
|
|
|
path = os.path.join(path, "extensions")
|
2020-02-23 13:57:39 +01:00
|
|
|
if not os.access(path, os.W_OK): # Can we install globally
|
2019-10-31 15:05:10 +01:00
|
|
|
# Not tested on Windows and Mac
|
|
|
|
path = os.path.expanduser("~/.config/inkscape/extensions")
|
|
|
|
self.distribution.data_files.append(
|
|
|
|
(path,
|
|
|
|
[i for i in glob.glob(os.path.join("inkex", "*.inx"))]))
|
2023-02-10 20:34:25 +01:00
|
|
|
self.distribution.data_files.append((path, ['scripts/boxes']))
|
2023-01-23 23:24:56 +01:00
|
|
|
self.distribution.data_files.append((path, ['scripts/boxes_proxy.py']))
|
2019-10-31 15:05:10 +01:00
|
|
|
except CalledProcessError:
|
|
|
|
pass # Inkscape is not installed
|
2018-10-27 19:03:09 +02:00
|
|
|
|
2017-02-25 20:01:03 +01:00
|
|
|
build_py.run(self)
|
2016-03-26 11:12:14 +01:00
|
|
|
|
2017-05-05 07:59:50 +02:00
|
|
|
setup(
|
|
|
|
name='boxes',
|
2020-04-28 16:27:39 +02:00
|
|
|
version='0.9',
|
2017-05-05 07:59:50 +02:00
|
|
|
description='Boxes generator for laser cutters',
|
|
|
|
author='Florian Festi',
|
|
|
|
author_email='florian@festi.info',
|
|
|
|
url='https://github.com/florianfesti/boxes',
|
|
|
|
packages=find_packages(),
|
2022-12-27 14:26:59 +01:00
|
|
|
python_requires='>=3.7',
|
2022-06-05 09:24:54 +02:00
|
|
|
install_requires=['affine>=2.0', 'markdown', 'shapely>=1.8.2'],
|
2017-05-05 07:59:50 +02:00
|
|
|
scripts=['scripts/boxes', 'scripts/boxesserver'],
|
|
|
|
cmdclass={
|
|
|
|
'build_py': CustomBuildExtCommand,
|
|
|
|
},
|
2023-01-20 21:45:34 +01:00
|
|
|
classifiers=[ # https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
2021-03-18 17:06:47 +01:00
|
|
|
"Development Status :: 5 - Production/Stable",
|
2017-05-05 07:59:50 +02:00
|
|
|
"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"], )
|