From dd3c24faf8372057436b9b001bbc3ffb3457fc05 Mon Sep 17 00:00:00 2001 From: Martin Aberg Date: Wed, 20 Jun 2018 19:57:18 +0200 Subject: [PATCH] Generate PYTHONPATH from CMake information The CMake scripts calculate the install path for python scripts by distutils.sysconfig.get_python_lib( plat_specific=0, standard_lib=0, prefix='' ) which generates a string in line with lib/python2.7/site-packages This string ends up in the CMake variable PYTHON_DEST and is used by the install step as destination directory for pcbnew.py. There has been a hard-coded assumption on the content of that string in PcbNew which is not compatible with FreeBSD 11.1. This commit eliminates the hard-coded assumption in PcbNew and reuses the install path as known by CMake. Fixes: lp:1777921 * https://bugs.launchpad.net/kicad/+bug/1777921 --- CMakeModules/config.h.cmake | 3 +++ pcbnew/pcbnew.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake index 77ce2ee196..a32b8d15f6 100644 --- a/CMakeModules/config.h.cmake +++ b/CMakeModules/config.h.cmake @@ -72,4 +72,7 @@ #define KIFACE_SUFFIX "@KIFACE_SUFFIX@" #define KIFACE_PREFIX "@KIFACE_PREFIX@" +/// Allows scripts install directory to be referenced by the program code. +#define PYTHON_DEST "@PYTHON_DEST@" + #endif // CONFIG_H_ diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 0e3249a034..1f1a4bd74c 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -263,10 +263,10 @@ static bool scriptingSetup() wxSetEnv( "PYTHONPATH", pypath ); #else - // Linux-specific setup wxString pypath; - pypath = Pgm().GetExecutablePath() + wxT( "../lib/python2.7/dist-packages" ); + // PYTHON_DEST is the scripts install dir as determined by the build system. + pypath = Pgm().GetExecutablePath() + wxT( "../" PYTHON_DEST ); if( !wxIsEmpty( wxGetenv( wxT( "PYTHONPATH" ) ) ) ) pypath = wxString( wxGetenv( wxT( "PYTHONPATH" ) ) ) + wxT( ":" ) + pypath;