sk1project / uniconvertor

UniConvertor is a cross-platform universal vector graphics translator
https://sk1project.net
GNU Affero General Public License v3.0
152 stars 41 forks source link

Won't work anymore on macOS #51

Open M-Rick opened 1 year ago

M-Rick commented 1 year ago

From macOS Monterey 12.x Uniconvertor won't work anymore. The installer will return an error and the uniconvertor command as well.

They are looking for /usr/bin/python which doesn't exist anymore.

But there's a work around.

First install Python 2.7 if it's not already existing. Then install the Uniconvertor package. There will have an installation error at the end because the post-install script cannot be executed.

Create a new text file like this:

#!/usr/bin/python3

import os
import sys

APP_DIR = '/opt/uniconvertor'
SYMLINKS = '%s/symlinks' % APP_DIR
BIN_FOLDER = '/usr/local/bin'

if not os.path.exists(SYMLINKS):
    sys.exit(1)

with open(SYMLINKS, 'rb') as fileptr:
    symlinks = fileptr.readline()

try:
    code = compile('symlinks=' + symlinks, '<string>', 'exec')
    exec code
except Exception:
    print 'Parsing error in "%s"' % symlinks
    sys.exit(1)

if not os.path.exists(BIN_FOLDER):
    os.makedirs(BIN_FOLDER)

for src, dst in symlinks:
    if os.path.exists(dst):
        os.remove(dst)
    os.symlink(src, dst)

os.system('chmod +x %s/bin/uniconvertor' % APP_DIR)
os.remove(SYMLINKS)

It's the post-install script of the installer which was returning an error. Execute it sudo python ~/Desktop/python.txt

Then you will have to edit the uniconvertor command which is a simple script, and change the python path in the header:

sudo nano /opt/uniconvertor/bin/uniconvertor

And just modify the first line like this: replace !/usr/bin/python by !/Library/Frameworks/Python.framework/Versions/2.7/bin/python

#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python
#
# Wrapper script to start UniConvertor application on macOS
#
# Copyright (C) 2019 Igor E. Novikov
#
# This library is covered by GNU Affero General Public License v3.
# For more info see LICENSE file in UniConvertor root directory.

import sys

sys.path.insert(1, '/opt/uniconvertor/pkgs')

import uc2

uc2.uc2_run()

That's all. Now Uniconvertor will work again on Monterey and Ventura macOS versions.