[KiCad Config] Give priority to KICAD_PATH

This commit is contained in:
Salvador E. Tropea 2023-04-13 11:21:35 -03:00
parent c8cbbcdd27
commit 4050936875
1 changed files with 10 additions and 1 deletions

View File

@ -194,7 +194,16 @@ class KiConf(object):
def _guess_kicad_data_dir(data_dir):
""" Tries to figure out where libraries are.
Only used if we failed to find the kicad_common file. """
Only used if we failed to find the kicad_common file.
On modern KiCad (6+) this is always used because KiCad doesn't store the path in kicad_common,
unless modified by the user. """
# Give priority to the KICAD_PATH environment variable
kpath = os.environ.get('KICAD_PATH')
if kpath and os.path.isdir(kpath):
dir = os.path.join(kpath, data_dir)
if os.path.isdir(dir):
return dir
# Try to guess according to the OS
system = platform.system()
share = os.path.join('share', GS.kicad_dir, data_dir)
if system == 'Linux':