diff options
author | jaseg <git@jaseg.de> | 2021-02-06 09:34:02 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-02-06 09:34:02 +0100 |
commit | 1e9d0c62f99025e0985b272fe6f7749f265f0cc4 (patch) | |
tree | 139be45c96ccf27ed42a5b9252b7bb52ba870130 /setup.py | |
parent | 06c2d5295db88243b88c6644d2c57f9a121670ee (diff) | |
download | gerbolyze-1e9d0c62f99025e0985b272fe6f7749f265f0cc4.tar.gz gerbolyze-1e9d0c62f99025e0985b272fe6f7749f265f0cc4.tar.bz2 gerbolyze-1e9d0c62f99025e0985b272fe6f7749f265f0cc4.zip |
Fix svg-flatten install location
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 38 |
1 files changed, 5 insertions, 33 deletions
@@ -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( |