← Back to team overview

kicad-developers team mailing list archive

Re: Packaging the python footprint wizards for the release

 

On 30 September 2015 at 21:19, Wayne Stambaugh <stambaughw@xxxxxxxxx> wrote:
> I just committed a fix so at least the python plugins will get installed
> in share/kicad/scripting which seems to work properly on msys2/mingw64
> builds.  I'll test it on Linux when I get a chance.  I'm going to pass
> on the python scripting example folder unless someone can confirm that
> all of the example python scripts work correctly.

It's broken on Linux too, the script path is broken. I've attached a
patch to fix it ( a one liner )

There's also a patch which helps when you install locally rather than
globally (like me!) so I can have more than one install at a time, but
it's tied specifically to a python version so is useless. We can fix
all this properly after the stable release. For now the one-liner fix
will work for system-wide installs.

Best Regards,

Brian.
=== modified file 'pcbnew/pcbnew.cpp'
--- pcbnew/pcbnew.cpp	2015-08-08 13:54:32 +0000
+++ pcbnew/pcbnew.cpp	2015-09-30 22:55:40 +0000
@@ -282,7 +282,7 @@
 
 #else
     // Add this default search path:
-    path_frag = wxT( "/usr/local/kicad/bin/scripting/plugins" );
+    path_frag = Pgm().GetExecutablePath() + wxT( "../share/kicad/scripting/plugins" );
 #endif
 
     if( ! pcbnewInitPythonScripting( TO_UTF8( path_frag ) ) )

=== modified file 'pcbnew/pcbnew.cpp'
--- pcbnew/pcbnew.cpp	2015-08-08 13:54:32 +0000
+++ pcbnew/pcbnew.cpp	2015-09-30 22:47:38 +0000
@@ -281,10 +281,22 @@
     wxSetEnv( "PYTHONPATH", pypath );
 
 #else
+    /* Linux-specific setup */
+    wxString pypath;
+
+    pypath = Pgm().GetExecutablePath() + wxT( "../lib/python2.7/dist-packages" );
+
+    if( !wxIsEmpty( wxGetenv("PYTHONPATH") ) )
+        pypath = wxString( wxGetenv("PYTHONPATH") ) + wxT( ":" ) + pypath;
+
+    wxSetEnv( "PYTHONPATH", pypath );
+
     // Add this default search path:
-    path_frag = wxT( "/usr/local/kicad/bin/scripting/plugins" );
+    path_frag = Pgm().GetExecutablePath() + wxT( "../share/kicad/scripting/plugins" );
 #endif
 
+    printf( "python: %s\n", static_cast<const char*>(path_frag) );
+
     if( ! pcbnewInitPythonScripting( TO_UTF8( path_frag ) ) )
     {
         wxLogError( wxT( "pcbnewInitPythonScripting() failed." ) );


Follow ups

References