Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion freecad/plot/PlotGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,32 @@
import FreeCADGui
import os

from . import Plot_rc
def CompileResources():
import subprocess as sub
# try to create a resource file
# assume either pyside2-rcc or pyside-rcc are available.
# if both are available pyside2-rcc is used.
rc_input = os.path.abspath(os.path.join(os.path.dirname(__file__), "resources", "Plot.qrc"))
rc_output = os.path.join(os.path.dirname(__file__), "Plot_rc.py")
try:
try:
proc = sub.Popen(["pyside2-rcc", "-o", rc_output, rc_input], stdout=sub.PIPE, stderr=sub.PIPE, universal_newlines=True)
out, err = proc.communicate()
except FileNotFoundError:
proc = sub.Popen(["pyside-rcc", "-o", rc_output, rc_input], stdout=sub.PIPE, stderr=sub.PIPE, universal_newlines=True)
out, err = proc.communicate()
print(out)
print(err)
except Exception as e:
print("An error occured while trying to create the resource file: \n" + str(e))


try:
from . import Plot_rc
except ImportError:
print("Plot: Trying to compile resources")
CompileResources()
from . import Plot_rc


FreeCADGui.addLanguagePath(":/Plot/translations")
Expand Down
20 changes: 2 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
from setuptools import setup
import os
import subprocess as sub
from freecad.plot.PlotGui import CompileResources

version_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
"freecad", "plot", "version.py")
with open(version_path) as fp:
exec(fp.read())

# try to create a resource file
# assume either pyside2-rcc or pyside-rcc are available.
# if both are available pyside2-rcc is used.
rc_input = os.path.abspath(os.path.join("freecad", "plot", "resources", "Plot.qrc"))
rc_output = os.path.join("freecad", "plot", "Plot_rc.py")
try:
try:
proc = sub.Popen(["pyside2-rcc", "-o", rc_output, rc_input], stdout=sub.PIPE, stderr=sub.PIPE)
out, err = proc.communicate()
except FileNotFoundError:
proc = sub.Popen(["pyside-rcc", "-o", rc_output, rc_input], stdout=sub.PIPE, stderr=sub.PIPE)
out, err = proc.communicate()
except Exception as e:
print("An error occured while trying to create the resource file: \n" + str(e))

print(out.decode("utf8"))
print(err.decode("utf8"))
CompileResources()

setup(name='freecad.plot',
version=str(__version__),
Expand Down