aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-02-06 09:34:02 +0100
committerjaseg <git@jaseg.de>2021-02-06 09:34:02 +0100
commit1e9d0c62f99025e0985b272fe6f7749f265f0cc4 (patch)
tree139be45c96ccf27ed42a5b9252b7bb52ba870130
parent06c2d5295db88243b88c6644d2c57f9a121670ee (diff)
downloadgerbolyze-1e9d0c62f99025e0985b272fe6f7749f265f0cc4.tar.gz
gerbolyze-1e9d0c62f99025e0985b272fe6f7749f265f0cc4.tar.bz2
gerbolyze-1e9d0c62f99025e0985b272fe6f7749f265f0cc4.zip
Fix svg-flatten install location
-rwxr-xr-xsetup.py38
1 files changed, 5 insertions, 33 deletions
diff --git a/setup.py b/setup.py
index 46ce755..f1f7388 100755
--- a/setup.py
+++ b/setup.py
@@ -12,51 +12,23 @@ def readme():
with open('README.rst') as f:
return f.read()
-
-def get_virtualenv_path():
- """Used to work out path to install compiled binaries to."""
- if hasattr(sys, 'real_prefix'):
- return sys.prefix
-
- if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
- return sys.prefix
-
- if 'conda' in sys.prefix:
- return sys.prefix
-
- return '/usr/local'
-
-def compile_and_install_svgflatten():
+def compile_and_install_svgflatten(target_dir):
src_path = 'svg-flatten'
try:
subprocess.run(['make', 'check-deps'], cwd=src_path, check=True)
subprocess.run(['make', '-j', str(cpu_count()), 'all'], cwd=src_path, check=True)
- subprocess.run(['make', 'install', f'PREFIX={get_virtualenv_path()}'], cwd=src_path, check=True)
+ bin_dir = target_dir / ".."
+ bin_dir.mkdir(parents=True, exist_ok=True)
+ subprocess.run(['make', 'install', f'PREFIX={bin_dir.resolve()}'], cwd=src_path, check=True)
except subprocess.CalledProcessError:
print('Error building svg-flatten C++ binary. Please see log above for details.', file=sys.stderr)
sys.exit(1)
-def has_usvg():
- checks = ['usvg', str(Path.home() / '.cargo' / 'bin' / 'usvg')]
- if 'USVG' in os.environ:
- checks = [os.environ['USVG'], *checks]
-
- for check in checks:
- try:
- subprocess.run(['usvg'], capture_output=True)
- return True
-
- except FileNotFoundError:
- pass
-
- else:
- return False
-
class CustomInstall(install):
"""Custom handler for the 'install' command."""
def run(self):
- compile_and_install_svgflatten()
+ compile_and_install_svgflatten(Path(self.install_scripts))
super().run()
setup(