Ensure we can version scripting properly

Adds Version() and FullVersion() calls to support reporting version to
scripts and scripting window

Fixes https://gitlab.com/kicad/code/kicad/issues/10079

(cherry picked from commit 0a13f15a9d)
This commit is contained in:
Seth Hillbrand 2022-02-03 15:53:12 -08:00
parent 7dadc9d2f0
commit 917845cf00
4 changed files with 40 additions and 1 deletions

View File

@ -420,6 +420,7 @@ set( SWIG_FLAGS
-I${CMAKE_SOURCE_DIR}/pcbnew/python/scripting
-I${CMAKE_SOURCE_DIR}/common/swig
-I${CMAKE_SOURCE_DIR}/libs/kimath/include
-I${CMAKE_BINARY_DIR}
)
if( DEBUG )
@ -481,6 +482,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx
DEPENDS python/swig/track.i
DEPENDS python/swig/units.i
DEPENDS python/swig/typeinfo.i
DEPENDS python/swig/version.i
DEPENDS python/swig/zone.i
DEPENDS python/swig/zone_settings.i

View File

@ -135,5 +135,6 @@ HANDLE_EXCEPTIONS(WriteDRCReport)
%include footprint.i
%include plugins.i
%include units.i
%include version.i

View File

@ -0,0 +1,35 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
/**
* @file version.i
* @brief KiCad version routine
*/
%include kicad_build_version.h
%pythoncode
%{
def Version():
"""Return the semantic version of KiCad"""
return KICAD_SEMANTIC_VERSION
def FullVersion():
"""Return the full, git-based version of KiCad"""
return KICAD_VERSION_FULL
%}

View File

@ -20,6 +20,7 @@ Pgm() returns a nullptr and Kicad crashes when Pgm is invoked.
import wx
import sys
import os
import pcbnew
from wx.py import crust, version, dispatcher
@ -136,7 +137,7 @@ class KiCadPyShell(KiCadEditorNotebookFrame):
"""Display an About window."""
title = 'About : KiCad - Python Shell'
text = "Enhanced Python Shell for KiCad\n\n" + \
"KiCad Revision: %s\n" % "??.??" + \
"KiCad Revision: %s\n" % pcbnew.FullVersion() + \
"Platform: %s\n" % sys.platform + \
"Python Version: %s\n" % sys.version.split()[0] + \
"wxPython Version: %s\n" % wx.VERSION_STRING + \