Skip to content

Commit

Permalink
Install Max package on setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eliottparis committed Jun 19, 2023
1 parent 7b8ff9a commit 2aac596
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions build-system/scripts/erbb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def setup (args):
sys.exit (1)

setup.install_python_requirements ()
setup.install_max_package ()
setup.optimize_kicad_pcb_sch_read ()
setup.check_toolchain ()

Expand Down
42 changes: 42 additions & 0 deletions build-system/setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


import os
from pathlib import Path
import platform
import shutil
import subprocess
Expand Down Expand Up @@ -477,6 +478,47 @@ def install_python_requirements ():



"""
==============================================================================
Name: install_max_package
==============================================================================
"""

def install_max_package ():
if platform.system () == 'Linux':
return

max8_packages_path = os.path.join (Path.home (), 'Documents', 'Max 8', 'Packages')
src_path = os.path.join (PATH_ROOT, 'max', 'Eurorack-blocks')
dst_path = os.path.join (max8_packages_path, 'Eurorack-blocks')

def is_link (path):
try:
return os.path.islink (path) or bool (os.readlink (path))
except OSError:
return False

def create_erbb_max_package_symlink ():
if platform.system () == 'Windows':
import _winapi
_winapi.CreateJunction (src_path, dst_path)
else:
os.symlink (src_path, dst_path)

if os.path.exists (max8_packages_path) and os.path.isdir (max8_packages_path):
if os.path.exists (dst_path):
if os.path.samefile (dst_path, src_path):
pass # package already installed
elif is_link (dst_path):
os.remove (dst_path)
create_erbb_max_package_symlink ()
else:
print (f'\033[33mwarning:\033[0m"Eurorack-blocks" file in max packages already exist.\nPlease remove "{dst_path}" and run `erbb setup` again.')
else:
create_erbb_max_package_symlink ()



"""
==============================================================================
Name: optimize_kicad_pcb_sch_read
Expand Down

0 comments on commit 2aac596

Please sign in to comment.