Commit Graph

50 Commits

Author SHA1 Message Date
Jon Evans c04e19f9ac Include optimization: move some things from common.h to point-of-use 2021-03-20 12:09:18 -04:00
Jon Evans 1ab17dd2e7 MSVC: don't set python home when running from build dir
This allows you to specify your python home via the
environment and get a working python setup when running
in-place.
2021-02-14 09:34:25 -05:00
Marek Roszko b21da9672f Adjust py_sethome for the new path 2021-02-10 21:44:33 -05:00
Marek Roszko 30ba3aa240 Get python loading the new "user scripting" paths 2021-01-28 23:45:53 -05:00
Marek Roszko 2807a37fc0 Create a stock scripting path helper 2021-01-27 19:12:18 -05:00
Marek Roszko 28c6967dbc Start trying to shuffle around path management 2021-01-27 19:12:18 -05:00
qu1ck 07d4a28024 Improvements to pcbnew action plugins settings panel
1. Add open plugins directory button (same as in tools menu)
2. Add show plugin errors button to help debug issues
2021-01-20 09:09:53 +00:00
Seth Hillbrand e3e9bfc1b8 Fix compile error 2021-01-13 13:21:27 -08:00
Seth Hillbrand 605dcfbedf Fix Windows script location
Windows has arbitrary installation locations, so reference relative to
the executable
2021-01-13 13:11:26 -08:00
Seth Hillbrand b57ad4b2f9 Correct SWIG path
Don't offset from executable, this is an absolute path

Fixes https://gitlab.com/kicad/code/kicad/issues/7089
2021-01-13 12:34:04 -08:00
Seth Hillbrand 2cb8dff650 Use KICAD_DATA for data path lookup in scripting
Fixes https://gitlab.com/kicad/code/kicad/issues/7036
2021-01-12 08:22:17 -08:00
Marek Roszko 84dd78e01d Fix the install location for vcpkg built python modules 2021-01-07 00:08:11 -05:00
Thomas Pointhuber 3b25e7344a Fix deprecation warning. PyEval_InitThreads() is not needed for Python >= 3.7
See: https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads

With Python 3.7 this function is called by Py_Initialize()
With Python 3.9 this function is deprecated and does nothing
2020-12-27 19:18:49 +01:00
jean-pierre charras f6b4b66a86 Avoid include wx/wx.h in many files that do not actually use this include.
Including wx.h includes the full set of wxWidgets include files, that is not good,
and can create some conflicts with some Windows headers on msys2.
2020-10-18 18:21:34 +02:00
jean-pierre charras 0b23cb7dbb more cleanup about removing useless include 2020-10-03 15:26:03 +02:00
Jon Evans 8ef888e115 Add a path for scripting console to work from build dir for debugging 2020-09-22 20:25:44 -04:00
Mark Roszko 610f0372d3 Initialize Py_SetPythonHome for msvc/vcpkg 2020-09-23 00:02:32 +00:00
Seth Hillbrand 45ca1709bb Unify scripting dirs and open user-based
This consolidates python scripting in two locations: the system-wide
package-based location and the user configuration location.  It also
updates the "Show Scripting Folder" action to open the user
configuration location instead of the package-based one.

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

Fixes https://gitlab.com/kicad/code/kicad/issues/5115
2020-09-16 20:09:23 -07:00
Ian McInerney 47f7c616f8 Fix Python environment variable handling
The variables in the common settings struct are only updated on
save, so Python must use the ones from Pgm to get its values.
This does lead to the observation that Python's changes to the
variables do affect KiCad (they can break resolvers). So apparently
it can mess with us but we can't mess with it easily.

Also, improve the environment variable tracing infrastructure to capture
more changes.
2020-08-12 00:14:19 +01:00
Ian McInerney 0a0ed9e064 Escape all env var strings sent to the Python interpreter
Fixes https://gitlab.com/kicad/code/kicad/issues/5130
2020-08-11 00:51:02 +01:00
Ian McInerney c458b50fd9 Ensure the environment variables are synchronized between KiCad and Python
Before this, the environment variables inside Python wouldn't reflect
the updates to them made after the interpreter was started in Pcbnew.
This will call into Python and set the variables when they are changed,
since Python can't synchronize itself when running in an embedded
interpreter.

Fixes https://gitlab.com/kicad/code/kicad/issues/5071
2020-08-09 19:56:12 +01:00
Seth Hillbrand 4d2e953f42 Cleanup: Replace C-only deprecated headers
This replaces headers deprecated by C++14 with their equivalent
replacement
2019-12-05 11:03:15 -08:00
Wayne Stambaugh 816f6db310 Pcbnew: Python scripting support clean up.
Always check the return value of PyRun_SimpleString() for errors when a
Python script is run and show an error message rather than fail silently.

Enable Python interpreter I/O redirection in debug builds so that script
string errors will be shown when PyRun_SimpleString() is called.

Do not call PyErr_Print() after a PyRun_SimpleString() call failure.  It
doesn't do anything useful.

Do not call Py_Finalize() after a PyRun_SimpleString() call failure.  It
seems to cause Pcbnew to crash.
2019-05-24 07:32:38 -04:00
Seth Hillbrand ff9d814fbd Fix unused vars in wxpython3 2019-01-24 21:25:39 -08:00
Seth Hillbrand 8b060799eb python: Fix Phoenix app setting
Phoenix doesn't have the same initialization as wxpython3 and so the
namespace doesn't get the wxApp() initialized to the existing instance.
In python, this is worked around by starting a new wxApp.
Unfortunately, this appears to overwrite the existing global instance
variable.  The issue _appears_ to be in Phoenix but for now we work
around it by saving and resetting the instance pointer in the main app.
The downside is that Python likely won't be able to respond to events
from C++

Fixes: lp:1809913
* https://bugs.launchpad.net/kicad/+bug/1809913
2019-01-24 19:41:07 -08:00
Thomas Pointhuber 0e0b4d52a2 Add initial support for Phoenix (new wxPython binding)
Based on the work of @mmccoo:
https://kicad.mmccoo.com/2017/11/23/learnings-from-moving-kicad-to-wxpython-4-0/
and this additional patchset to remove wxpy_api.h dependency:
http://mmccoo.com/random/0001-Remove-dependence-on-pywx_api.h.patch

Please note CreatePythonShellWindow changed quite a lot. Throughful testing
should be made for the old as well as new wxPython version on all platforms
2018-10-26 13:21:11 +02:00
Thomas Pointhuber e39eeb2f92 Remove debug printf and fix indentation inside of block 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 95e55eb17a Fix coding style issue (space after if) 2018-10-19 09:59:06 +02:00
Thomas Pointhuber e09785db1d Introduce PyStringToWx helper to remove code duplication 2018-10-19 09:59:06 +02:00
Thomas Pointhuber ce471ec898 Fix braces 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 6ac444f587 Fix style issue 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 0812f71bd3 Fix builtins import in Python3 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 7365cb8e52 Get Exception handling working with Python 3
The old way to get the full stacktrace was incorrect, and does not work
with Python 3:
https://stackoverflow.com/questions/3702675/how-to-print-the-full-traceback-without-halting-the-program#comment84297600_33723119
2018-10-19 09:59:06 +02:00
Thomas Pointhuber 88d04f3bcb Get Action Plugins working with Python 3, fix some unicode string errors 2018-10-19 09:59:06 +02:00
Thomas Pointhuber e9da6811a6 Fix initialisation of the pcbnew python module 2018-10-19 09:59:05 +02:00
Thomas Pointhuber 284904b72c Rewrite C extensions to also support Python 3 2018-10-19 09:59:05 +02:00
jean-pierre charras c585964da9 fix coding style issues. 2018-07-17 19:55:33 +02:00
Baranovskiy Konstantin 5e1605af19 Values of argc and argv transfers to python environment. 2018-07-08 08:10:44 +02:00
jean-pierre charras ccce376e33 Refinements for commit 986b904
(Add comments and a minor fix)
2018-04-27 16:01:59 +02:00
jean-pierre charras 986b90424b Fix an issue in LoadPlugins(bundlepath=None) python method (Windows specific).
For some obscure (for me) reason, the path separators in bundlepath are seen as escape seq, and the path can be incorrectly handled
(when \n or \r are found in this string).
it happens only for this path, not for other paths in LoadPlugins.
For bundlepath parameter, unix separator is now used.

Fixes: lp:1766879
https://bugs.launchpad.net/kicad/+bug/1766879
2018-04-27 14:04:24 +02:00
jean-pierre charras 30e3f2e781 fix forgotten change after renaming files 2018-01-29 17:34:12 +01:00
John Beard c523ba45e1 Fix shadowed variable in python_scripting.cpp 2017-03-10 09:08:45 +01:00
Jon Evans a52250a91e Change from EDA_COLOR_T to COLOR4D globally; arbitrary color support
eeschema now supports arbitrary colors for all object types, and
pcbnew does in GAL canvas.  When switching from GAL to legacy canvas,
pcbnew will convert colors to the nearest legacy color.
2017-02-22 17:35:00 +01:00
jean-pierre charras 4f46f79cf0 dialog_footprint_wizard_list.cpp: allows updating (on request) python modules from this dialog.
This option reloads modules which are more recent than already loaded modules, and load new modules.
2017-01-09 14:44:24 +01:00
jean-pierre charras e6a8294c56 dialog_footprint_wizard_list: add button to show the trace of errors when python scripts wizards failed to load. 2017-01-07 20:43:39 +01:00
jean-pierre charras 44cc728b25 enforce a control to avoid crash if pcbnew.py is an incorrect version (bad install). 2017-01-07 16:25:11 +01:00
jean-pierre charras 76a82dcd3b Dialog footprint wizard selector: better dialog (displays the wizard search path list) and allows double click to select a wizard 2017-01-07 13:39:47 +01:00
jean-pierre charras 56f8e10eb4 Footprint wizards management: Now display the list of not loadable footprint wizards in footprint wizard dialog.
Not loadable wizards are Python scripts having a syntax error or are not compatible scripts due to changes in API.
2017-01-06 20:15:23 +01:00
Oliver 636e060c99 A few enhancements from a larger patch, not yet committed, for footprint wizards 2016-12-28 10:26:01 +01:00
Dick Hollenbeck 7311f07eaf SWIG Improvements
*) Extend SWIG support deeper into the BOARD class.
*) Move swig *.i files into a directory identified for SWIG, in preparation
   for a parallel universe involving Phoenix's SIP.
*) Move swig files which will be common to both eeschema and pcbnew into
   common/swig.
*) Sketch out a "common" python module, and plan on dovetailing that into a
   libkicad_shared.{dll,so}
*) Add common/swig/ki_exceptions.i and define a macro HANDLE_EXCEPTIONS()
   which is to be applied to any function which needs C++ to python
   exception translation.
*) Move the test for SWIG tool into top level CMakeLists.txt file for use
   in all python modules beyond pcbnew, i.e. eeschema and common.
*) Add SWIG_MODULE_pcbnew_EXTRA_DEPS which generates a better Makefile, one
   which rebuilds the swig generated *.cxx file when one of its dependencies
   change.
*) Re-architect the board.i file so that it can be split into multiple *.i
   files easily.
*) Make some KIWAY from python progress, in preparation for Modular KiCad
   phase III.
2016-09-20 11:59:43 -04:00
Renamed from scripting/python_scripting.cpp (Browse further)