Use inkscape to find its install dir
Calls "inkscape -x" to find the extensions directory and if it is unwritable uses the users local folder
This commit is contained in:
parent
e95f36a18a
commit
b9f652ee71
15
setup.py
15
setup.py
|
@ -3,6 +3,7 @@
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from subprocess import check_output, CalledProcessError
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
from setuptools.command.build_py import build_py
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
@ -17,17 +18,21 @@ class CustomBuildExtCommand(build_py):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.execute(self.buildInkscapeExt, ())
|
self.execute(self.buildInkscapeExt, ())
|
||||||
if os.name == "posix":
|
try:
|
||||||
if sys.platform == "darwin":
|
path = check_output(["inkscape", "-x"])
|
||||||
path = "/usr/local/share/inkscape/extensions/"
|
if not os.access(path, os.W_OK): # Can we install globaly
|
||||||
else:
|
# Not tested on Windows and Mac
|
||||||
path = "/usr/share/inkscape/extensions/"
|
path = os.path.expanduser("~/.config/inkscape/extensions")
|
||||||
|
|
||||||
if self.distribution.data_files is None:
|
if self.distribution.data_files is None:
|
||||||
self.distribution.data_files = []
|
self.distribution.data_files = []
|
||||||
self.distribution.data_files.append(
|
self.distribution.data_files.append(
|
||||||
(path,
|
(path,
|
||||||
[i for i in glob.glob(os.path.join("inkex", "*.inx"))]))
|
[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']))
|
||||||
|
except CalledProcessError:
|
||||||
|
pass # Inkscape is not installed
|
||||||
|
|
||||||
build_py.run(self)
|
build_py.run(self)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
Loading…
Reference in New Issue