From 1e9d0c62f99025e0985b272fe6f7749f265f0cc4 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 6 Feb 2021 09:34:02 +0100 Subject: Fix svg-flatten install location --- setup.py | 38 +++++--------------------------------- 1 file 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( -- cgit